Mercurial > hg > xemacs-beta
annotate src/frame.c @ 5117:3742ea8250b5 ben-lisp-object ben-lisp-object-final-ws-year-2005
Checking in final CVS version of workspace 'ben-lisp-object'
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 26 Dec 2009 00:20:27 -0600 |
parents | facf3239ba30 |
children | e0db3c197671 |
rev | line source |
---|---|
428 | 1 /* Generic frame functions. |
2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | |
3025 | 3 Copyright (C) 1995, 1996, 2002, 2003, 2005 Ben Wing. |
428 | 4 Copyright (C) 1995 Sun Microsystems, Inc. |
5 | |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: FSF 19.30. */ | |
24 | |
25 /* This file has been Mule-ized. */ | |
26 | |
27 #include <config.h> | |
28 #include "lisp.h" | |
29 | |
30 #include "buffer.h" /* for Vbuffer_alist */ | |
31 #include "console.h" | |
872 | 32 #include "device-impl.h" |
428 | 33 #include "events.h" |
34 #include "extents.h" | |
35 #include "faces.h" | |
872 | 36 #include "frame-impl.h" |
428 | 37 #include "glyphs.h" |
38 #include "gutter.h" | |
39 #include "menubar.h" | |
2681 | 40 #include "process.h" /* for egetenv */ |
428 | 41 #include "redisplay.h" |
42 #include "scrollbar.h" | |
800 | 43 #include "toolbar.h" |
428 | 44 #include "window.h" |
45 | |
46 Lisp_Object Vselect_frame_hook, Qselect_frame_hook; | |
47 Lisp_Object Vdeselect_frame_hook, Qdeselect_frame_hook; | |
48 Lisp_Object Vcreate_frame_hook, Qcreate_frame_hook; | |
49 Lisp_Object Vdelete_frame_hook, Qdelete_frame_hook; | |
50 Lisp_Object Vmouse_enter_frame_hook, Qmouse_enter_frame_hook; | |
51 Lisp_Object Vmouse_leave_frame_hook, Qmouse_leave_frame_hook; | |
52 Lisp_Object Vmap_frame_hook, Qmap_frame_hook; | |
53 Lisp_Object Vunmap_frame_hook, Qunmap_frame_hook; | |
54 int allow_deletion_of_last_visible_frame; | |
55 Lisp_Object Vadjust_frame_function; | |
56 Lisp_Object Vmouse_motion_handler; | |
57 Lisp_Object Vsynchronize_minibuffers; | |
58 Lisp_Object Qsynchronize_minibuffers; | |
59 Lisp_Object Qbuffer_predicate; | |
60 Lisp_Object Qmake_initial_minibuffer_frame; | |
61 Lisp_Object Qcustom_initialize_frame; | |
62 | |
63 /* We declare all these frame properties here even though many of them | |
64 are currently only used in frame-x.c, because we should generalize | |
65 them. */ | |
66 | |
67 Lisp_Object Qminibuffer; | |
68 Lisp_Object Qunsplittable; | |
69 Lisp_Object Qinternal_border_width; | |
70 Lisp_Object Qtop_toolbar_shadow_color; | |
71 Lisp_Object Qbottom_toolbar_shadow_color; | |
72 Lisp_Object Qbackground_toolbar_color; | |
73 Lisp_Object Qtop_toolbar_shadow_pixmap; | |
74 Lisp_Object Qbottom_toolbar_shadow_pixmap; | |
75 Lisp_Object Qtoolbar_shadow_thickness; | |
76 Lisp_Object Qscrollbar_placement; | |
77 Lisp_Object Qinter_line_space; | |
78 Lisp_Object Qvisual_bell; | |
79 Lisp_Object Qbell_volume; | |
80 Lisp_Object Qpointer_background; | |
81 Lisp_Object Qpointer_color; | |
82 Lisp_Object Qtext_pointer; | |
83 Lisp_Object Qspace_pointer; | |
84 Lisp_Object Qmodeline_pointer; | |
85 Lisp_Object Qgc_pointer; | |
86 Lisp_Object Qinitially_unmapped; | |
87 Lisp_Object Quse_backing_store; | |
88 Lisp_Object Qborder_color; | |
89 Lisp_Object Qborder_width; | |
90 | |
91 Lisp_Object Qframep, Qframe_live_p; | |
92 Lisp_Object Qdelete_frame; | |
93 | |
94 Lisp_Object Qframe_title_format, Vframe_title_format; | |
95 Lisp_Object Qframe_icon_title_format, Vframe_icon_title_format; | |
96 | |
97 Lisp_Object Vdefault_frame_name; | |
98 Lisp_Object Vdefault_frame_plist; | |
99 | |
100 Lisp_Object Vframe_icon_glyph; | |
101 | |
102 Lisp_Object Qhidden; | |
103 | |
104 Lisp_Object Qvisible, Qiconic, Qinvisible, Qvisible_iconic, Qinvisible_iconic; | |
105 Lisp_Object Qnomini, Qvisible_nomini, Qiconic_nomini, Qinvisible_nomini; | |
106 Lisp_Object Qvisible_iconic_nomini, Qinvisible_iconic_nomini; | |
107 | |
442 | 108 Lisp_Object Qset_specifier, Qset_face_property; |
428 | 109 Lisp_Object Qface_property_instance; |
110 | |
111 Lisp_Object Qframe_property_alias; | |
112 | |
113 /* If this is non-nil, it is the frame that make-frame is currently | |
114 creating. We can't set the current frame to this in case the | |
115 debugger goes off because it would try and display to it. However, | |
116 there are some places which need to reference it which have no | |
117 other way of getting it if it isn't the selected frame. */ | |
118 Lisp_Object Vframe_being_created; | |
119 Lisp_Object Qframe_being_created; | |
120 | |
121 static void store_minibuf_frame_prop (struct frame *f, Lisp_Object val); | |
1125 | 122 |
123 typedef enum { | |
124 DISPLAYABLE_PIXEL_TO_CHAR, | |
125 TOTAL_PIXEL_TO_CHAR, | |
126 CHAR_TO_TOTAL_PIXEL, | |
1429 | 127 CHAR_TO_DISPLAYABLE_PIXEL |
1125 | 128 } pixel_to_char_mode_t; |
129 | |
130 static void frame_conversion_internal (struct frame *f, | |
131 pixel_to_char_mode_t pixel_to_char, | |
863 | 132 int *pixel_width, int *pixel_height, |
133 int *char_width, int *char_height, | |
134 int real_face); | |
438 | 135 static struct display_line title_string_display_line; |
136 /* Used by generate_title_string. Global because they get used so much that | |
137 the dynamic allocation time adds up. */ | |
867 | 138 static Ichar_dynarr *title_string_ichar_dynarr; |
428 | 139 |
140 | |
1204 | 141 |
142 extern const struct sized_memory_description gtk_frame_data_description; | |
143 extern const struct sized_memory_description mswindows_frame_data_description; | |
144 extern const struct sized_memory_description x_frame_data_description; | |
145 | |
146 static const struct memory_description frame_data_description_1 []= { | |
147 #ifdef HAVE_GTK | |
2551 | 148 { XD_BLOCK_PTR, gtk_console, 1, { >k_frame_data_description} }, |
1204 | 149 #endif |
150 #ifdef HAVE_MS_WINDOWS | |
2551 | 151 { XD_BLOCK_PTR, mswindows_console, 1, { &mswindows_frame_data_description} }, |
1204 | 152 #endif |
153 #ifdef HAVE_X_WINDOWS | |
2551 | 154 { XD_BLOCK_PTR, x_console, 1, { &x_frame_data_description} }, |
1204 | 155 #endif |
156 { XD_END } | |
157 }; | |
158 | |
159 static const struct sized_memory_description frame_data_description = { | |
160 sizeof (void *), frame_data_description_1 | |
161 }; | |
162 | |
163 extern const struct sized_memory_description expose_ignore_description; | |
164 | |
165 static const struct memory_description expose_ignore_description_1 [] = { | |
2367 | 166 { XD_BLOCK_PTR, offsetof (struct expose_ignore, next), |
2551 | 167 1, { &expose_ignore_description } }, |
1204 | 168 { XD_END } |
169 }; | |
170 | |
171 const struct sized_memory_description expose_ignore_description = { | |
172 sizeof (struct expose_ignore), | |
173 expose_ignore_description_1 | |
174 }; | |
175 | |
176 static const struct memory_description display_line_dynarr_pointer_description_1 []= { | |
2551 | 177 { XD_BLOCK_PTR, 0, 1, { &display_line_dynarr_description} }, |
1204 | 178 { XD_END } |
179 }; | |
180 | |
181 static const struct sized_memory_description display_line_dynarr_pointer_description = { | |
182 sizeof (display_line_dynarr *), display_line_dynarr_pointer_description_1 | |
183 }; | |
184 | |
185 static const struct memory_description frame_description [] = { | |
186 { XD_INT, offsetof (struct frame, frametype) }, | |
187 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (struct frame, x) }, | |
188 #define MARKED_SLOT_ARRAY(slot, size) \ | |
189 { XD_LISP_OBJECT_ARRAY, offsetof (struct frame, slot), size }, | |
190 #include "frameslots.h" | |
191 | |
2367 | 192 { XD_BLOCK_PTR, offsetof (struct frame, subwindow_exposures), |
2551 | 193 1, { &expose_ignore_description } }, |
2367 | 194 { XD_BLOCK_PTR, offsetof (struct frame, subwindow_exposures_tail), |
2551 | 195 1, { &expose_ignore_description } }, |
1204 | 196 |
197 #ifdef HAVE_SCROLLBARS | |
198 { XD_LISP_OBJECT, offsetof (struct frame, sb_vcache) }, | |
199 { XD_LISP_OBJECT, offsetof (struct frame, sb_hcache) }, | |
200 #endif /* HAVE_SCROLLBARS */ | |
201 | |
2367 | 202 { XD_BLOCK_ARRAY, offsetof (struct frame, current_display_lines), |
2551 | 203 4, { &display_line_dynarr_pointer_description } }, |
2367 | 204 { XD_BLOCK_ARRAY, offsetof (struct frame, desired_display_lines), |
2551 | 205 4, { &display_line_dynarr_pointer_description } }, |
1204 | 206 |
2367 | 207 { XD_BLOCK_PTR, offsetof (struct frame, framemeths), 1, |
2551 | 208 { &console_methods_description } }, |
1204 | 209 { XD_UNION, offsetof (struct frame, frame_data), |
2551 | 210 XD_INDIRECT (0, 0), { &frame_data_description } }, |
1204 | 211 { XD_END } |
212 }; | |
213 | |
428 | 214 static Lisp_Object |
215 mark_frame (Lisp_Object obj) | |
216 { | |
217 struct frame *f = XFRAME (obj); | |
218 | |
1204 | 219 #define MARKED_SLOT(x) mark_object (f->x); |
428 | 220 #include "frameslots.h" |
221 | |
222 if (FRAME_LIVE_P (f)) /* device is nil for a dead frame */ | |
223 MAYBE_FRAMEMETH (f, mark_frame, (f)); | |
224 | |
617 | 225 #ifdef HAVE_SCROLLBARS |
226 if (f->sb_vcache) | |
227 mark_object (wrap_scrollbar_instance (f->sb_vcache)); | |
228 if (f->sb_hcache) | |
229 mark_object (wrap_scrollbar_instance (f->sb_hcache)); | |
230 #endif | |
231 | |
232 mark_gutters (f); | |
233 | |
428 | 234 return Qnil; |
235 } | |
236 | |
237 static void | |
2286 | 238 print_frame (Lisp_Object obj, Lisp_Object printcharfun, |
239 int UNUSED (escapeflag)) | |
428 | 240 { |
241 struct frame *frm = XFRAME (obj); | |
242 | |
243 if (print_readably) | |
563 | 244 printing_unreadable_object ("#<frame %s 0x%x>", |
245 XSTRING_DATA (frm->name), frm->header.uid); | |
428 | 246 |
800 | 247 write_fmt_string (printcharfun, "#<%s-frame ", !FRAME_LIVE_P (frm) ? "dead" : |
248 FRAME_TYPE_NAME (frm)); | |
428 | 249 print_internal (frm->name, printcharfun, 1); |
800 | 250 write_fmt_string (printcharfun, " 0x%x>", frm->header.uid); |
428 | 251 } |
252 | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
253 DEFINE_NONDUMPABLE_LISP_OBJECT ("frame", frame, |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
254 mark_frame, print_frame, 0, 0, 0, |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
255 frame_description, |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
256 struct frame); |
428 | 257 |
258 static void | |
259 nuke_all_frame_slots (struct frame *f) | |
260 { | |
3017 | 261 ZERO_LCRECORD (f); |
617 | 262 |
1204 | 263 #define MARKED_SLOT(x) f->x = Qnil; |
428 | 264 #include "frameslots.h" |
265 } | |
266 | |
267 /* Allocate a new frame object and set all its fields to reasonable | |
268 values. The root window is created but the minibuffer will be done | |
269 later. */ | |
270 | |
271 static struct frame * | |
272 allocate_frame_core (Lisp_Object device) | |
273 { | |
274 /* This function can GC */ | |
275 Lisp_Object root_window; | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
276 Lisp_Object frame = ALLOC_LISP_OBJECT (frame); |
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
277 struct frame *f = XFRAME (frame); |
428 | 278 |
279 nuke_all_frame_slots (f); | |
280 | |
281 f->device = device; | |
282 f->framemeths = XDEVICE (device)->devmeths; | |
1204 | 283 f->frametype = get_console_variant (XDEVICE_TYPE (device)); |
428 | 284 f->buffer_alist = Fcopy_sequence (Vbuffer_alist); |
285 | |
286 root_window = allocate_window (); | |
287 XWINDOW (root_window)->frame = frame; | |
288 | |
289 /* 10 is arbitrary, | |
290 Just so that there is "something there." | |
291 Correct size will be set up later with change_frame_size. */ | |
292 | |
293 f->width = 10; | |
294 f->height = 10; | |
295 | |
296 XWINDOW (root_window)->pixel_width = 10; | |
297 XWINDOW (root_window)->pixel_height = 9; | |
298 | |
299 f->root_window = root_window; | |
300 f->selected_window = root_window; | |
301 f->last_nonminibuf_window = root_window; | |
302 | |
303 /* cache of subwindows visible on frame */ | |
442 | 304 f->subwindow_instance_cache = make_weak_list (WEAK_LIST_SIMPLE); |
428 | 305 |
306 /* associated exposure ignore list */ | |
307 f->subwindow_exposures = 0; | |
308 f->subwindow_exposures_tail = 0; | |
309 | |
442 | 310 FRAME_SET_PAGENUMBER (f, 1); |
311 | |
853 | 312 note_object_created (root_window); |
313 | |
428 | 314 /* Choose a buffer for the frame's root window. */ |
315 XWINDOW (root_window)->buffer = Qt; | |
316 { | |
317 Lisp_Object buf; | |
318 | |
319 buf = Fcurrent_buffer (); | |
320 /* If buf is a 'hidden' buffer (i.e. one whose name starts with | |
321 a space), try to find another one. */ | |
867 | 322 if (string_ichar (Fbuffer_name (buf), 0) == ' ') |
428 | 323 buf = Fother_buffer (buf, Qnil, Qnil); |
440 | 324 Fset_window_buffer (root_window, buf, Qnil); |
428 | 325 } |
326 | |
327 return f; | |
328 } | |
329 | |
330 static void | |
331 setup_normal_frame (struct frame *f) | |
332 { | |
333 Lisp_Object mini_window; | |
793 | 334 Lisp_Object frame = wrap_frame (f); |
335 | |
428 | 336 |
337 mini_window = allocate_window (); | |
338 XWINDOW (f->root_window)->next = mini_window; | |
339 XWINDOW (mini_window)->prev = f->root_window; | |
340 XWINDOW (mini_window)->mini_p = Qt; | |
341 XWINDOW (mini_window)->frame = frame; | |
342 f->minibuffer_window = mini_window; | |
343 f->has_minibuffer = 1; | |
344 | |
853 | 345 note_object_created (mini_window); |
346 | |
428 | 347 XWINDOW (mini_window)->buffer = Qt; |
440 | 348 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); |
428 | 349 } |
350 | |
351 /* Make a frame using a separate minibuffer window on another frame. | |
352 MINI_WINDOW is the minibuffer window to use. nil means use the | |
353 default-minibuffer-frame. */ | |
354 | |
355 static void | |
356 setup_frame_without_minibuffer (struct frame *f, Lisp_Object mini_window) | |
357 { | |
358 /* This function can GC */ | |
359 Lisp_Object device = f->device; | |
360 | |
361 if (!NILP (mini_window)) | |
362 CHECK_LIVE_WINDOW (mini_window); | |
363 | |
364 if (!NILP (mini_window) | |
365 && !EQ (DEVICE_CONSOLE (XDEVICE (device)), | |
366 FRAME_CONSOLE (XFRAME (XWINDOW (mini_window)->frame)))) | |
563 | 367 invalid_argument ("frame and minibuffer must be on the same console", Qunbound); |
428 | 368 |
442 | 369 /* Do not create a default minibuffer frame on printer devices. */ |
370 if (NILP (mini_window) | |
371 && DEVICE_DISPLAY_P (XDEVICE (FRAME_DEVICE (f)))) | |
428 | 372 { |
373 struct console *con = XCONSOLE (FRAME_CONSOLE (f)); | |
374 /* Use default-minibuffer-frame if possible. */ | |
375 if (!FRAMEP (con->default_minibuffer_frame) | |
376 || ! FRAME_LIVE_P (XFRAME (con->default_minibuffer_frame))) | |
377 { | |
378 /* If there's no minibuffer frame to use, create one. */ | |
379 con->default_minibuffer_frame | |
380 = call1 (Qmake_initial_minibuffer_frame, device); | |
381 } | |
382 mini_window = XFRAME (con->default_minibuffer_frame)->minibuffer_window; | |
383 } | |
384 | |
385 /* Install the chosen minibuffer window, with proper buffer. */ | |
442 | 386 if (!NILP (mini_window)) |
387 { | |
388 store_minibuf_frame_prop (f, mini_window); | |
389 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); | |
390 } | |
391 else | |
392 f->minibuffer_window = Qnil; | |
428 | 393 } |
394 | |
395 /* Make a frame containing only a minibuffer window. */ | |
396 | |
397 static void | |
398 setup_minibuffer_frame (struct frame *f) | |
399 { | |
400 /* This function can GC */ | |
401 /* First make a frame containing just a root window, no minibuffer. */ | |
402 Lisp_Object mini_window; | |
793 | 403 Lisp_Object frame = wrap_frame (f); |
404 | |
428 | 405 |
406 f->no_split = 1; | |
407 f->has_minibuffer = 1; | |
408 | |
409 /* Now label the root window as also being the minibuffer. | |
410 Avoid infinite looping on the window chain by marking next pointer | |
411 as nil. */ | |
412 | |
413 mini_window = f->minibuffer_window = f->root_window; | |
414 XWINDOW (mini_window)->mini_p = Qt; | |
415 XWINDOW (mini_window)->next = Qnil; | |
416 XWINDOW (mini_window)->prev = Qnil; | |
417 XWINDOW (mini_window)->frame = frame; | |
418 | |
419 /* Put the proper buffer in that window. */ | |
420 | |
440 | 421 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); |
428 | 422 } |
423 | |
424 static Lisp_Object | |
425 make_sure_its_a_fresh_plist (Lisp_Object foolist) | |
426 { | |
427 if (CONSP (Fcar (foolist))) | |
428 { | |
429 /* looks like an alist to me. */ | |
430 foolist = Fcopy_alist (foolist); | |
431 foolist = Fdestructive_alist_to_plist (foolist); | |
432 } | |
433 else | |
434 foolist = Fcopy_sequence (foolist); | |
435 | |
436 return foolist; | |
437 } | |
438 | |
558 | 439 static Lisp_Object |
546 | 440 restore_frame_list_to_its_unbesmirched_state (Lisp_Object kawnz) |
441 { | |
442 Lisp_Object lissed = XCDR (kawnz); | |
443 if (!EQ (lissed, Qunbound)) | |
444 DEVICE_FRAME_LIST (XDEVICE (XCAR (kawnz))) = lissed; | |
445 return Qnil; | |
446 } | |
447 | |
428 | 448 DEFUN ("make-frame", Fmake_frame, 0, 2, "", /* |
449 Create and return a new frame, displaying the current buffer. | |
450 Runs the functions listed in `create-frame-hook' after frame creation. | |
451 | |
452 Optional argument PROPS is a property list (a list of alternating | |
453 keyword-value specifications) of properties for the new frame. | |
454 \(An alist is accepted for backward compatibility but should not | |
455 be passed in.) | |
456 | |
457 See `set-frame-properties', `default-x-frame-plist', and | |
458 `default-tty-frame-plist' for the specially-recognized properties. | |
459 */ | |
460 (props, device)) | |
461 { | |
462 struct frame *f; | |
463 struct device *d; | |
464 Lisp_Object frame = Qnil, name = Qnil, minibuf; | |
465 struct gcpro gcpro1, gcpro2, gcpro3; | |
546 | 466 int speccount = specpdl_depth (), speccount2; |
428 | 467 int first_frame_on_device = 0; |
468 int first_frame_on_console = 0; | |
546 | 469 Lisp_Object besmirched_cons = Qnil; |
771 | 470 int frame_name_is_defaulted = 1; |
428 | 471 |
472 d = decode_device (device); | |
793 | 473 device = wrap_device (d); |
428 | 474 |
475 /* PROPS and NAME may be freshly-created, so make sure to GCPRO. */ | |
476 GCPRO3 (frame, props, name); | |
477 | |
478 props = make_sure_its_a_fresh_plist (props); | |
479 if (DEVICE_SPECIFIC_FRAME_PROPS (d)) | |
480 /* Put the device-specific props before the more general ones so | |
481 that they override them. */ | |
482 props = nconc2 (props, | |
483 make_sure_its_a_fresh_plist | |
484 (*DEVICE_SPECIFIC_FRAME_PROPS (d))); | |
485 props = nconc2 (props, make_sure_its_a_fresh_plist (Vdefault_frame_plist)); | |
486 Fcanonicalize_lax_plist (props, Qnil); | |
487 | |
488 name = Flax_plist_get (props, Qname, Qnil); | |
489 if (!NILP (name)) | |
771 | 490 { |
491 CHECK_STRING (name); | |
492 frame_name_is_defaulted = 0; | |
493 } | |
2681 | 494 else if (!initialized) |
495 { | |
496 /* We leave Vdefault_frame_name alone here so that it'll remain Qnil | |
497 in the dumped executable, and we can choose it at runtime. */ | |
498 name = build_string("XEmacs"); | |
499 } | |
500 else if (NILP (Vdefault_frame_name)) | |
501 { | |
502 if (egetenv ("USE_EMACS_AS_DEFAULT_APPLICATION_CLASS")) | |
503 { | |
504 Vdefault_frame_name = build_string ("emacs"); | |
505 } | |
506 else | |
507 { | |
508 Vdefault_frame_name = build_string ("XEmacs"); | |
509 } | |
510 } | |
511 | |
512 if (NILP(name) && STRINGP(Vdefault_frame_name)) | |
513 { | |
514 name = Vdefault_frame_name; | |
515 } | |
428 | 516 |
867 | 517 if (!NILP (Fstring_match (make_string ((const Ibyte *) "\\.", 2), name, |
428 | 518 Qnil, Qnil))) |
563 | 519 syntax_error (". not allowed in frame names", name); |
428 | 520 |
521 f = allocate_frame_core (device); | |
793 | 522 frame = wrap_frame (f); |
428 | 523 |
524 specbind (Qframe_being_created, name); | |
525 f->name = name; | |
526 | |
771 | 527 FRAMEMETH (f, init_frame_1, (f, props, frame_name_is_defaulted)); |
428 | 528 |
529 minibuf = Flax_plist_get (props, Qminibuffer, Qunbound); | |
530 if (UNBOUNDP (minibuf)) | |
531 { | |
532 /* If minibuf is unspecified, then look for a minibuffer X resource. */ | |
533 /* #### Not implemented any more. We need to fix things up so | |
534 that we search out all X resources and append them to the end of | |
535 props, above. This is the only way in general to assure | |
536 coherent behavior for all frame properties/resources/etc. */ | |
537 } | |
538 else | |
539 props = Flax_plist_remprop (props, Qminibuffer); | |
540 | |
541 if (EQ (minibuf, Qnone) || NILP (minibuf)) | |
542 setup_frame_without_minibuffer (f, Qnil); | |
543 else if (EQ (minibuf, Qonly)) | |
544 setup_minibuffer_frame (f); | |
545 else if (WINDOWP (minibuf)) | |
546 setup_frame_without_minibuffer (f, minibuf); | |
547 else if (EQ (minibuf, Qt) || UNBOUNDP (minibuf)) | |
548 setup_normal_frame (f); | |
549 else | |
563 | 550 invalid_argument ("Invalid value for `minibuffer'", minibuf); |
428 | 551 |
552 update_frame_window_mirror (f); | |
553 | |
554 if (initialized && !DEVICE_STREAM_P (d)) | |
555 { | |
556 if (!NILP (f->minibuffer_window)) | |
557 reset_face_cachels (XWINDOW (f->minibuffer_window)); | |
558 reset_face_cachels (XWINDOW (f->root_window)); | |
559 } | |
560 | |
561 /* If no frames on this device formerly existed, say this is the | |
562 first frame. It kind of assumes that frameless devices don't | |
563 exist, but it shouldn't be too harmful. */ | |
564 if (NILP (DEVICE_FRAME_LIST (d))) | |
565 first_frame_on_device = 1; | |
566 | |
546 | 567 /* It's possible for one of the init methods below to signal an error; |
568 in that case, let's make sure the device isn't besmirched by | |
569 having a half-initialized frame attached to it */ | |
570 speccount2 = specpdl_depth (); | |
571 record_unwind_protect (restore_frame_list_to_its_unbesmirched_state, | |
572 besmirched_cons = | |
573 Fcons (device, DEVICE_FRAME_LIST (d))); | |
574 | |
428 | 575 /* This *must* go before the init_*() methods. Those functions |
576 call Lisp code, and if any of them causes a warning to be displayed | |
577 and the *Warnings* buffer to be created, it won't get added to | |
578 the frame-specific version of the buffer-alist unless the frame | |
579 is accessible from the device. */ | |
580 | |
581 #if 0 | |
582 DEVICE_FRAME_LIST (d) = nconc2 (DEVICE_FRAME_LIST (d), Fcons (frame, Qnil)); | |
583 #endif | |
584 DEVICE_FRAME_LIST (d) = Fcons (frame, DEVICE_FRAME_LIST (d)); | |
585 RESET_CHANGED_SET_FLAGS; | |
586 | |
853 | 587 note_object_created (frame); |
588 | |
428 | 589 /* Now make sure that the initial cached values are set correctly. |
590 Do this after the init_frame method is called because that may | |
591 do things (e.g. create widgets) that are necessary for the | |
592 specifier value-changed methods to work OK. */ | |
593 recompute_all_cached_specifiers_in_frame (f); | |
594 | |
595 if (!DEVICE_STREAM_P (d)) | |
596 { | |
597 init_frame_faces (f); | |
598 | |
599 #ifdef HAVE_SCROLLBARS | |
600 /* Finish up resourcing the scrollbars. */ | |
601 init_frame_scrollbars (f); | |
602 #endif | |
603 | |
604 #ifdef HAVE_TOOLBARS | |
605 /* Create the initial toolbars. We have to do this after the frame | |
606 methods are called because it may potentially call some things itself | |
607 which depend on the normal frame methods having initialized | |
608 things. */ | |
609 init_frame_toolbars (f); | |
610 #endif | |
611 reset_face_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); | |
612 reset_glyph_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); | |
442 | 613 |
428 | 614 change_frame_size (f, f->height, f->width, 0); |
615 } | |
616 | |
617 MAYBE_FRAMEMETH (f, init_frame_2, (f, props)); | |
618 Fset_frame_properties (frame, props); | |
619 MAYBE_FRAMEMETH (f, init_frame_3, (f)); | |
620 | |
621 /* Hallelujah, praise the lord. */ | |
622 f->init_finished = 1; | |
623 | |
546 | 624 XCDR (besmirched_cons) = Qunbound; |
625 | |
771 | 626 unbind_to (speccount2); |
546 | 627 |
428 | 628 /* If this is the first frame on the device, make it the selected one. */ |
629 if (first_frame_on_device && NILP (DEVICE_SELECTED_FRAME (d))) | |
630 set_device_selected_frame (d, frame); | |
631 | |
632 /* If at startup or if the current console is a stream console | |
633 (usually also at startup), make this console the selected one | |
634 so that messages show up on it. */ | |
635 if (NILP (Fselected_console ()) || | |
636 CONSOLE_STREAM_P (XCONSOLE (Fselected_console ()))) | |
637 Fselect_console (DEVICE_CONSOLE (d)); | |
638 | |
639 first_frame_on_console = | |
640 (first_frame_on_device && | |
641 XINT (Flength (CONSOLE_DEVICE_LIST (XCONSOLE (DEVICE_CONSOLE (d))))) | |
642 == 1); | |
643 | |
644 /* #### all this calling of frame methods at various odd times | |
645 is somewhat of a mess. It's necessary to do it this way due | |
646 to strange console-type-specific things that need to be done. */ | |
647 MAYBE_FRAMEMETH (f, after_init_frame, (f, first_frame_on_device, | |
648 first_frame_on_console)); | |
649 | |
442 | 650 if (!DEVICE_STREAM_P (d)) |
651 { | |
652 /* Now initialise the gutters. This won't change the frame size, | |
653 but is needed as input to the layout that change_frame_size | |
654 will eventually do. Unfortunately gutter sizing code relies | |
655 on the frame in question being visible so we can't do this | |
656 earlier. */ | |
657 init_frame_gutters (f); | |
658 | |
659 change_frame_size (f, f->height, f->width, 0); | |
660 } | |
661 | |
428 | 662 if (first_frame_on_device) |
663 { | |
664 if (first_frame_on_console) | |
665 va_run_hook_with_args (Qcreate_console_hook, 1, DEVICE_CONSOLE (d)); | |
666 va_run_hook_with_args (Qcreate_device_hook, 1, device); | |
667 } | |
668 va_run_hook_with_args (Qcreate_frame_hook, 1, frame); | |
669 | |
670 /* Initialize custom-specific stuff. */ | |
671 if (!UNBOUNDP (symbol_function (XSYMBOL (Qcustom_initialize_frame)))) | |
672 call1 (Qcustom_initialize_frame, frame); | |
673 | |
1204 | 674 UNGCPRO; |
771 | 675 unbind_to (speccount); |
428 | 676 |
677 return frame; | |
678 } | |
679 | |
680 | |
681 /* this function should be used in most cases when a Lisp function is passed | |
682 a FRAME argument. Use this unless you don't accept nil == current frame | |
683 (in which case, do a CHECK_LIVE_FRAME() and then an XFRAME()) or you | |
684 allow dead frames. Note that very few functions should accept dead | |
685 frames. It could be argued that functions should just do nothing when | |
686 given a dead frame, but the presence of a dead frame usually indicates | |
687 an oversight in the Lisp code that could potentially lead to strange | |
688 results and so it is better to catch the error early. | |
689 | |
690 If you only accept X frames, use decode_x_frame(), which does what this | |
691 function does but also makes sure the frame is an X frame. */ | |
692 | |
693 struct frame * | |
694 decode_frame (Lisp_Object frame) | |
695 { | |
696 if (NILP (frame)) | |
697 return selected_frame (); | |
698 | |
699 CHECK_LIVE_FRAME (frame); | |
700 return XFRAME (frame); | |
701 } | |
702 | |
703 struct frame * | |
704 decode_frame_or_selected (Lisp_Object cdf) | |
705 { | |
706 if (CONSOLEP (cdf)) | |
707 cdf = CONSOLE_SELECTED_DEVICE (decode_console (cdf)); | |
708 if (DEVICEP (cdf)) | |
709 cdf = DEVICE_SELECTED_FRAME (decode_device (cdf)); | |
710 return decode_frame (cdf); | |
711 } | |
712 | |
872 | 713 Lisp_Object |
714 frame_device (struct frame *f) | |
715 { | |
716 return FRAME_DEVICE (f); | |
717 } | |
718 | |
719 int | |
720 frame_live_p (struct frame *f) | |
721 { | |
722 return FRAME_LIVE_P (f); | |
723 } | |
724 | |
428 | 725 |
726 void | |
727 invalidate_vertical_divider_cache_in_frame (struct frame *f) | |
728 { | |
729 /* Invalidate cached value of needs_vertical_divider_p in | |
730 every and all windows */ | |
731 map_windows (f, invalidate_vertical_divider_cache_in_window, 0); | |
732 } | |
733 | |
734 /* | |
735 * Frame size may change due to changes in scrollbars, toolbars, | |
736 * default font etc. These changes are applied early in redisplay | |
737 * frame. | |
738 */ | |
739 void | |
740 adjust_frame_size (struct frame *f) | |
741 { | |
1318 | 742 /* This can call Lisp. */ |
428 | 743 int keep_char_size = 0; |
793 | 744 Lisp_Object frame = wrap_frame (f); |
745 | |
428 | 746 if (!f->size_slipped) |
747 return; | |
748 | |
749 /* Don't adjust tty frames. #### May break when TTY have menubars. | |
750 Then, write an Vadjust_frame_function which will return t for TTY | |
751 frames. Another solution is frame_size_fixed_p method for TTYs, | |
752 which always returned yes it's fixed. | |
753 */ | |
754 if (!FRAME_WIN_P (f)) | |
755 { | |
756 CLEAR_FRAME_SIZE_SLIPPED (f); | |
757 return; | |
758 } | |
759 | |
760 /* frame_size_fixed_p tells that frame size cannot currently | |
761 be changed change due to external conditions */ | |
762 if (!FRAMEMETH_OR_GIVEN (f, frame_size_fixed_p, (f), 0)) | |
763 { | |
764 if (NILP (Vadjust_frame_function)) | |
765 keep_char_size = 1; | |
766 else if (EQ (Vadjust_frame_function, Qt)) | |
767 keep_char_size = 0; | |
768 else | |
769 keep_char_size = | |
853 | 770 NILP (call1_trapping_problems ("Error in adjust-frame-function", |
771 Vadjust_frame_function, frame, | |
772 0)); | |
428 | 773 |
774 if (keep_char_size) | |
775 Fset_frame_size (frame, make_int (FRAME_CHARWIDTH(f)), | |
776 make_int (FRAME_CHARHEIGHT(f)), Qnil); | |
777 } | |
778 | |
779 if (!keep_char_size) | |
780 { | |
781 int height, width; | |
782 pixel_to_char_size (f, FRAME_PIXWIDTH(f), FRAME_PIXHEIGHT(f), | |
783 &width, &height); | |
784 change_frame_size (f, height, width, 0); | |
785 CLEAR_FRAME_SIZE_SLIPPED (f); | |
786 } | |
787 } | |
788 | |
789 /* | |
790 * This is a "specifier changed in frame" handler for various specifiers | |
791 * changing which causes frame size adjustment | |
792 */ | |
793 void | |
2286 | 794 frame_size_slipped (Lisp_Object UNUSED (specifier), struct frame *f, |
795 Lisp_Object UNUSED (oldval)) | |
428 | 796 { |
797 MARK_FRAME_SIZE_SLIPPED(f); | |
798 } | |
799 | |
800 DEFUN ("framep", Fframep, 1, 1, 0, /* | |
801 Return non-nil if OBJECT is a frame. | |
802 Also see `frame-live-p'. | |
803 Note that FSF Emacs kludgily returns a value indicating what type of | |
804 frame this is. Use the cleaner function `frame-type' for that. | |
805 */ | |
806 (object)) | |
807 { | |
808 return FRAMEP (object) ? Qt : Qnil; | |
809 } | |
810 | |
811 DEFUN ("frame-live-p", Fframe_live_p, 1, 1, 0, /* | |
812 Return non-nil if OBJECT is a frame which has not been deleted. | |
813 */ | |
814 (object)) | |
815 { | |
816 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil; | |
817 } | |
818 | |
819 | |
820 DEFUN ("focus-frame", Ffocus_frame, 1, 1, 0, /* | |
821 Select FRAME and give it the window system focus. | |
822 This function is not affected by the value of `focus-follows-mouse'. | |
823 */ | |
824 (frame)) | |
825 { | |
826 CHECK_LIVE_FRAME (frame); | |
827 | |
828 MAYBE_DEVMETH (XDEVICE (FRAME_DEVICE (XFRAME (frame))), focus_on_frame, | |
829 (XFRAME (frame))); | |
830 /* FRAME will be selected by the time we receive the next event. | |
831 However, it is better to select it explicitly now, in case the | |
832 Lisp code depends on frame being selected. */ | |
833 Fselect_frame (frame); | |
834 return Qnil; | |
835 } | |
836 | |
837 /* Called from Fselect_window() */ | |
838 void | |
839 select_frame_1 (Lisp_Object frame) | |
840 { | |
841 struct frame *f = XFRAME (frame); | |
842 Lisp_Object old_selected_frame = Fselected_frame (Qnil); | |
843 | |
844 if (EQ (frame, old_selected_frame)) | |
845 return; | |
846 | |
847 /* now select the frame's device */ | |
848 set_device_selected_frame (XDEVICE (FRAME_DEVICE (f)), frame); | |
849 select_device_1 (FRAME_DEVICE (f)); | |
850 | |
851 update_frame_window_mirror (f); | |
852 } | |
853 | |
854 DEFUN ("select-frame", Fselect_frame, 1, 1, 0, /* | |
855 Select the frame FRAME. | |
856 Subsequent editing commands apply to its selected window. | |
857 The selection of FRAME lasts until the next time the user does | |
858 something to select a different frame, or until the next time this | |
859 function is called. | |
860 | |
861 Note that this does not actually cause the window-system focus to be | |
862 set to this frame, or the `select-frame-hook' or `deselect-frame-hook' | |
863 to be run, until the next time that XEmacs is waiting for an event. | |
864 | |
865 Also note that when focus-follows-mouse is non-nil, the frame | |
866 selection is temporary and is reverted when the current command | |
867 terminates, much like the buffer selected by `set-buffer'. In order | |
868 to effect a permanent focus change, use `focus-frame'. | |
869 */ | |
870 (frame)) | |
871 { | |
872 CHECK_LIVE_FRAME (frame); | |
873 | |
874 /* select the frame's selected window. This will call | |
875 selected_frame_1(). */ | |
876 Fselect_window (FRAME_SELECTED_WINDOW (XFRAME (frame)), Qnil); | |
877 | |
878 /* Nothing should be depending on the return value of this function. | |
879 But, of course, there is stuff out there which is. */ | |
880 return frame; | |
881 } | |
882 | |
883 /* use this to retrieve the currently selected frame. You should use | |
884 this in preference to Fselected_frame (Qnil) unless you are prepared | |
885 to handle the possibility of there being no selected frame (this | |
886 happens at some points during startup). */ | |
887 | |
888 struct frame * | |
889 selected_frame (void) | |
890 { | |
891 Lisp_Object device = Fselected_device (Qnil); | |
892 Lisp_Object frame = DEVICE_SELECTED_FRAME (XDEVICE (device)); | |
893 if (NILP (frame)) | |
563 | 894 gui_error ("No frames exist on device", device); |
428 | 895 return XFRAME (frame); |
896 } | |
897 | |
898 /* use this instead of XFRAME (DEVICE_SELECTED_FRAME (d)) to catch | |
899 the possibility of there being no frames on the device (just created). | |
900 There is no point doing this inside of redisplay because errors | |
2500 | 901 cause an ABORT(), indicating a flaw in the logic, and error_check_frame() |
428 | 902 will catch this just as well. */ |
903 | |
904 struct frame * | |
905 device_selected_frame (struct device *d) | |
906 { | |
907 Lisp_Object frame = DEVICE_SELECTED_FRAME (d); | |
908 if (NILP (frame)) | |
909 { | |
793 | 910 Lisp_Object device = wrap_device (d); |
911 | |
563 | 912 gui_error ("No frames exist on device", device); |
428 | 913 } |
914 return XFRAME (frame); | |
915 } | |
916 | |
917 #if 0 /* FSFmacs */ | |
918 | |
826 | 919 DEFUN ("handle-switch-frame", Fhandle_switch_frame, 1, 2, "e", /* |
428 | 920 Handle a switch-frame event EVENT. |
921 Switch-frame events are usually bound to this function. | |
922 A switch-frame event tells Emacs that the window manager has requested | |
923 that the user's events be directed to the frame mentioned in the event. | |
924 This function selects the selected window of the frame of EVENT. | |
925 | |
926 If EVENT is frame object, handle it as if it were a switch-frame event | |
927 to that frame. | |
928 */ | |
929 (frame, no_enter)) | |
930 { | |
931 /* Preserve prefix arg that the command loop just cleared. */ | |
932 XCONSOLE (Vselected_console)->prefix_arg = Vcurrent_prefix_arg; | |
933 #if 0 /* unclean! */ | |
934 run_hook (Qmouse_leave_buffer_hook); | |
935 #endif | |
936 return do_switch_frame (frame, no_enter, 0); | |
937 } | |
938 | |
939 /* A load of garbage. */ | |
826 | 940 DEFUN ("ignore-event", Fignore_event, 0, 0, "", /* |
428 | 941 Do nothing, but preserve any prefix argument already specified. |
942 This is a suitable binding for iconify-frame and make-frame-visible. | |
943 */ | |
944 ()) | |
945 { | |
946 struct console *c = XCONSOLE (Vselected_console); | |
947 | |
948 c->prefix_arg = Vcurrent_prefix_arg; | |
949 return Qnil; | |
950 } | |
951 | |
952 #endif /* 0 */ | |
953 | |
954 DEFUN ("selected-frame", Fselected_frame, 0, 1, 0, /* | |
955 Return the frame that is now selected on device DEVICE. | |
956 If DEVICE is not specified, the selected device will be used. | |
957 If no frames exist on the device, nil is returned. | |
958 */ | |
959 (device)) | |
960 { | |
961 if (NILP (device) && NILP (Fselected_device (Qnil))) | |
962 return Qnil; /* happens early in temacs */ | |
963 return DEVICE_SELECTED_FRAME (decode_device (device)); | |
964 } | |
965 | |
966 Lisp_Object | |
967 frame_first_window (struct frame *f) | |
968 { | |
969 Lisp_Object w = f->root_window; | |
970 | |
971 while (1) | |
972 { | |
973 if (! NILP (XWINDOW (w)->hchild)) | |
974 w = XWINDOW (w)->hchild; | |
975 else if (! NILP (XWINDOW (w)->vchild)) | |
976 w = XWINDOW (w)->vchild; | |
977 else | |
978 break; | |
979 } | |
980 | |
981 return w; | |
982 } | |
983 | |
984 DEFUN ("active-minibuffer-window", Factive_minibuffer_window, 0, 0, 0, /* | |
985 Return the currently active minibuffer window, or nil if none. | |
986 */ | |
987 ()) | |
988 { | |
989 return minibuf_level ? minibuf_window : Qnil; | |
990 } | |
991 | |
992 DEFUN ("last-nonminibuf-frame", Flast_nonminibuf_frame, 0, 1, 0, /* | |
993 Return the most-recently-selected non-minibuffer-only frame on CONSOLE. | |
994 This will always be the same as (selected-frame device) unless the | |
995 selected frame is a minibuffer-only frame. | |
996 CONSOLE defaults to the selected console if omitted. | |
997 */ | |
998 (console)) | |
999 { | |
1000 Lisp_Object result; | |
1001 | |
793 | 1002 console = wrap_console (decode_console (console)); |
428 | 1003 /* Just in case the machinations in delete_frame_internal() resulted |
1004 in the last-nonminibuf-frame getting out of sync, make sure and | |
1005 return the selected frame if it's acceptable. */ | |
1006 result = Fselected_frame (CONSOLE_SELECTED_DEVICE (XCONSOLE (console))); | |
1007 if (!NILP (result) && !FRAME_MINIBUF_ONLY_P (XFRAME (result))) | |
1008 return result; | |
1009 return CONSOLE_LAST_NONMINIBUF_FRAME (XCONSOLE (console)); | |
1010 } | |
1011 | |
1012 DEFUN ("frame-root-window", Fframe_root_window, 0, 1, 0, /* | |
1013 Return the root-window of FRAME. | |
1014 If omitted, FRAME defaults to the currently selected frame. | |
1015 */ | |
1016 (frame)) | |
1017 { | |
1018 struct frame *f = decode_frame (frame); | |
1019 return FRAME_ROOT_WINDOW (f); | |
1020 } | |
1021 | |
1022 DEFUN ("frame-selected-window", Fframe_selected_window, 0, 1, 0, /* | |
1023 Return the selected window of frame object FRAME. | |
1024 If omitted, FRAME defaults to the currently selected frame. | |
1025 */ | |
1026 (frame)) | |
1027 { | |
1028 struct frame *f = decode_frame (frame); | |
1029 return FRAME_SELECTED_WINDOW (f); | |
1030 } | |
1031 | |
1032 void | |
1033 set_frame_selected_window (struct frame *f, Lisp_Object window) | |
1034 { | |
1035 assert (XFRAME (WINDOW_FRAME (XWINDOW (window))) == f); | |
1036 f->selected_window = window; | |
1037 if (!MINI_WINDOW_P (XWINDOW (window)) || FRAME_MINIBUF_ONLY_P (f)) | |
1038 { | |
1039 if (!EQ (f->last_nonminibuf_window, window)) | |
1040 { | |
442 | 1041 #ifdef HAVE_TOOLBARS |
428 | 1042 MARK_TOOLBAR_CHANGED; |
442 | 1043 #endif |
428 | 1044 MARK_GUTTER_CHANGED; |
1045 } | |
1046 f->last_nonminibuf_window = window; | |
1047 } | |
1048 } | |
1049 | |
1050 DEFUN ("set-frame-selected-window", Fset_frame_selected_window, 2, 2, 0, /* | |
460 | 1051 Set the selected window of FRAME to WINDOW. |
428 | 1052 If FRAME is nil, the selected frame is used. |
1053 If FRAME is the selected frame, this makes WINDOW the selected window. | |
1054 */ | |
1055 (frame, window)) | |
1056 { | |
793 | 1057 frame = wrap_frame (decode_frame (frame)); |
428 | 1058 CHECK_LIVE_WINDOW (window); |
1059 | |
1060 if (! EQ (frame, WINDOW_FRAME (XWINDOW (window)))) | |
563 | 1061 invalid_argument ("In `set-frame-selected-window', WINDOW is not on FRAME", Qunbound); |
428 | 1062 |
1063 if (XFRAME (frame) == selected_frame ()) | |
1064 return Fselect_window (window, Qnil); | |
1065 | |
1066 set_frame_selected_window (XFRAME (frame), window); | |
1067 return window; | |
1068 } | |
1069 | |
1070 | |
1071 DEFUN ("frame-device", Fframe_device, 0, 1, 0, /* | |
1072 Return the device that FRAME is on. | |
1073 If omitted, FRAME defaults to the currently selected frame. | |
1074 */ | |
1075 (frame)) | |
1076 { | |
1077 return FRAME_DEVICE (decode_frame (frame)); | |
1078 } | |
1079 | |
1080 int | |
1081 is_surrogate_for_selected_frame (struct frame *f) | |
1082 { | |
1083 struct device *d = XDEVICE (f->device); | |
1084 struct frame *dsf = device_selected_frame (d); | |
1085 | |
1086 /* Can't be a surrogate for ourselves. */ | |
1087 if (f == dsf) | |
1088 return 0; | |
1089 | |
1090 if (!FRAME_HAS_MINIBUF_P (dsf) && | |
1091 f == XFRAME (WINDOW_FRAME (XWINDOW (FRAME_MINIBUF_WINDOW (dsf))))) | |
1092 return 1; | |
1093 else | |
1094 return 0; | |
1095 } | |
1096 | |
1097 static int | |
444 | 1098 frame_matches_frame_spec (Lisp_Object frame, Lisp_Object type) |
428 | 1099 { |
1100 struct frame *f = XFRAME (frame); | |
1101 | |
1102 if (WINDOWP (type)) | |
1103 { | |
1104 CHECK_LIVE_WINDOW (type); | |
1105 | |
1106 if (EQ (FRAME_MINIBUF_WINDOW (f), type) | |
1107 /* Check that F either is, or has forwarded | |
1108 its focus to, TYPE's frame. */ | |
1109 && (EQ (WINDOW_FRAME (XWINDOW (type)), frame) | |
1110 || EQ (WINDOW_FRAME (XWINDOW (type)), | |
1111 FRAME_FOCUS_FRAME (f)))) | |
1112 return 1; | |
1113 else | |
1114 return 0; | |
1115 } | |
1116 | |
1117 #if 0 /* FSFmacs */ | |
1118 if (EQ (type, Qvisible) || EQ (type, Qiconic) || EQ (type, Qvisible_iconic) | |
1119 || EQ (type, Qvisible_nomini) || EQ (type, Qiconic_nomini) | |
1120 || EQ (type, Qvisible_iconic_nomini)) | |
1121 FRAME_SAMPLE_VISIBILITY (f); | |
1122 #endif | |
1123 | |
1124 if (NILP (type)) | |
1125 type = Qnomini; | |
1126 if (ZEROP (type)) | |
1127 type = Qvisible_iconic; | |
1128 | |
1129 if (EQ (type, Qvisible)) | |
1130 return FRAME_VISIBLE_P (f); | |
1131 if (EQ (type, Qiconic)) | |
1132 return FRAME_ICONIFIED_P (f); | |
1133 if (EQ (type, Qinvisible)) | |
1134 return !FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f); | |
1135 if (EQ (type, Qvisible_iconic)) | |
1136 return FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f); | |
1137 if (EQ (type, Qinvisible_iconic)) | |
1138 return !FRAME_VISIBLE_P (f); | |
1139 | |
1140 if (EQ (type, Qnomini)) | |
1141 return !FRAME_MINIBUF_ONLY_P (f); | |
1142 if (EQ (type, Qvisible_nomini)) | |
1143 return FRAME_VISIBLE_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
1144 if (EQ (type, Qiconic_nomini)) | |
1145 return FRAME_ICONIFIED_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
1146 if (EQ (type, Qinvisible_nomini)) | |
1147 return !FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f) && | |
1148 !FRAME_MINIBUF_ONLY_P (f); | |
1149 if (EQ (type, Qvisible_iconic_nomini)) | |
1150 return ((FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)) | |
1151 && !FRAME_MINIBUF_ONLY_P (f)); | |
1152 if (EQ (type, Qinvisible_iconic_nomini)) | |
1153 return !FRAME_VISIBLE_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
1154 | |
1155 return 1; | |
1156 } | |
1157 | |
1158 int | |
444 | 1159 device_matches_device_spec (Lisp_Object device, Lisp_Object device_spec) |
428 | 1160 { |
444 | 1161 if (EQ (device_spec, Qwindow_system)) |
428 | 1162 return DEVICE_WIN_P (XDEVICE (device)); |
444 | 1163 if (DEVICEP (device_spec)) |
1164 return EQ (device, device_spec); | |
1165 if (CONSOLEP (device_spec)) | |
1166 return EQ (DEVICE_CONSOLE (XDEVICE (device)), device_spec); | |
1167 if (valid_console_type_p (device_spec)) | |
1168 return EQ (DEVICE_TYPE (XDEVICE (device)), device_spec); | |
428 | 1169 return 1; |
1170 } | |
1171 | |
1172 /* Return the next frame in the frame list after FRAME. | |
444 | 1173 WHICH-FRAMES and WHICH-DEVICES control which frames and devices |
428 | 1174 are considered; see `next-frame'. */ |
1175 | |
1176 Lisp_Object | |
444 | 1177 next_frame (Lisp_Object frame, Lisp_Object which_frames, Lisp_Object which_devices) |
428 | 1178 { |
442 | 1179 Lisp_Object first = Qnil; |
1180 Lisp_Object devcons, concons; | |
1181 int passed = 0; | |
1182 | |
1183 CHECK_LIVE_FRAME (frame); | |
1184 | |
1185 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
1186 { | |
1187 Lisp_Object device = XCAR (devcons); | |
1188 Lisp_Object frmcons; | |
1189 | |
444 | 1190 if (!device_matches_device_spec (device, which_devices)) |
442 | 1191 { |
1192 if (EQ (device, FRAME_DEVICE (XFRAME (frame)))) | |
1193 passed = 1; | |
1194 continue; | |
1195 } | |
1196 | |
1197 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) | |
1198 { | |
1199 Lisp_Object f = XCAR (frmcons); | |
1200 | |
1201 if (passed) | |
1202 { | |
444 | 1203 if (frame_matches_frame_spec (f, which_frames)) |
442 | 1204 return f; |
1205 } | |
1206 else | |
1207 { | |
1208 if (EQ (frame, f)) | |
1209 { | |
1210 passed = 1; | |
1211 } | |
1212 else | |
1213 { | |
444 | 1214 if (NILP (first) && frame_matches_frame_spec (f, which_frames)) |
442 | 1215 first = f; |
1216 } | |
1217 } | |
1218 } | |
1219 } | |
1220 | |
1221 if (NILP (first)) | |
1222 /* We went through the whole frame list without finding a single | |
1223 acceptable frame. Return the original frame. */ | |
1224 return frame; | |
1225 else | |
1226 /* There were no acceptable frames in the list after FRAME; otherwise, | |
1227 we would have returned directly from the loop. Since FIRST is the last | |
1228 acceptable frame in the list, return it. */ | |
1229 return first; | |
428 | 1230 } |
1231 | |
1232 /* Return the previous frame in the frame list before FRAME. | |
444 | 1233 WHICH-FRAMES and WHICH-DEVICES control which frames and devices |
428 | 1234 are considered; see `next-frame'. */ |
1235 | |
1236 Lisp_Object | |
444 | 1237 previous_frame (Lisp_Object frame, Lisp_Object which_frames, Lisp_Object which_devices) |
428 | 1238 { |
1239 Lisp_Object devcons, concons; | |
442 | 1240 Lisp_Object last = Qnil; |
1241 | |
428 | 1242 CHECK_LIVE_FRAME (frame); |
1243 | |
1244 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
1245 { | |
1246 Lisp_Object device = XCAR (devcons); | |
1247 Lisp_Object frmcons; | |
1248 | |
444 | 1249 if (!device_matches_device_spec (device, which_devices)) |
442 | 1250 { |
1251 if (EQ (device, FRAME_DEVICE (XFRAME (frame))) | |
1252 && !NILP (last)) | |
1253 return last; | |
1254 continue; | |
1255 } | |
428 | 1256 |
1257 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) | |
1258 { | |
1259 Lisp_Object f = XCAR (frmcons); | |
1260 | |
442 | 1261 if (EQ (frame, f)) |
1262 { | |
1263 if (!NILP (last)) | |
1264 return last; | |
1265 } | |
1266 else | |
1267 { | |
444 | 1268 if (frame_matches_frame_spec (f, which_frames)) |
442 | 1269 last = f; |
1270 } | |
428 | 1271 } |
1272 } | |
1273 | |
442 | 1274 if (NILP (last)) |
428 | 1275 /* We went through the whole frame list without finding a single |
1276 acceptable frame. Return the original frame. */ | |
1277 return frame; | |
1278 else | |
1279 /* There were no acceptable frames in the list before FRAME; otherwise, | |
442 | 1280 we would have returned directly from the loop. Since LAST is the last |
428 | 1281 acceptable frame in the list, return it. */ |
442 | 1282 return last; |
428 | 1283 } |
1284 | |
1285 DEFUN ("next-frame", Fnext_frame, 0, 3, 0, /* | |
1286 Return the next frame of the right type in the frame list after FRAME. | |
444 | 1287 WHICH-FRAMES controls which frames are eligible to be returned; all |
428 | 1288 others will be skipped. Note that if there is only one eligible |
1289 frame, then `next-frame' called repeatedly will always return | |
1290 the same frame, and if there is no eligible frame, then FRAME is | |
1291 returned. | |
1292 | |
444 | 1293 Possible values for WHICH-FRAMES are |
428 | 1294 |
3025 | 1295 `visible' Consider only frames that are visible. |
1296 `iconic' Consider only frames that are iconic. | |
1297 `invisible' Consider only frames that are invisible | |
1298 (this is different from iconic). | |
1299 `visible-iconic' Consider frames that are visible or iconic. | |
1300 `invisible-iconic' Consider frames that are invisible or iconic. | |
1301 `nomini' Consider all frames except minibuffer-only ones. | |
1302 `visible-nomini' Like `visible' but omits minibuffer-only frames. | |
1303 `iconic-nomini' Like `iconic' but omits minibuffer-only frames. | |
1304 `invisible-nomini' Like `invisible' but omits minibuffer-only frames. | |
1305 `visible-iconic-nomini' Like `visible-iconic' but omits minibuffer-only | |
1306 frames. | |
1307 `invisible-iconic-nomini' Like `invisible-iconic' but omits minibuffer-only | |
1308 frames. | |
1309 any other value Consider all frames. | |
1310 | |
1311 If WHICH-FRAMES is omitted, `nomini' is used. A value for WHICH-FRAMES | |
1312 of 0 (a number) is treated like `iconic', for backwards compatibility. | |
444 | 1313 |
1314 If WHICH-FRAMES is a window, include only its own frame and any frame | |
1315 now using that window as the minibuffer. | |
1316 | |
1317 The optional third argument WHICH-DEVICES further clarifies on which | |
1318 devices to search for frames as specified by WHICH-FRAMES. | |
1319 If nil or omitted, search all devices on FRAME's console. | |
1320 If a device, only search that device. | |
1321 If a console, search all devices on that console. | |
1322 If a device type, search all devices of that type. | |
1323 If `window-system', search all window-system devices. | |
1324 Any other non-nil value means search all devices. | |
428 | 1325 */ |
444 | 1326 (frame, which_frames, which_devices)) |
428 | 1327 { |
793 | 1328 frame = wrap_frame (decode_frame (frame)); |
428 | 1329 |
444 | 1330 return next_frame (frame, which_frames, which_devices); |
428 | 1331 } |
1332 | |
1333 DEFUN ("previous-frame", Fprevious_frame, 0, 3, 0, /* | |
1334 Return the next frame of the right type in the frame list after FRAME. | |
444 | 1335 WHICH-FRAMES controls which frames are eligible to be returned; all |
428 | 1336 others will be skipped. Note that if there is only one eligible |
1337 frame, then `previous-frame' called repeatedly will always return | |
1338 the same frame, and if there is no eligible frame, then FRAME is | |
1339 returned. | |
1340 | |
444 | 1341 See `next-frame' for an explanation of the WHICH-FRAMES and WHICH-DEVICES |
428 | 1342 arguments. |
1343 */ | |
444 | 1344 (frame, which_frames, which_devices)) |
428 | 1345 { |
793 | 1346 frame = wrap_frame (decode_frame (frame)); |
428 | 1347 |
444 | 1348 return previous_frame (frame, which_frames, which_devices); |
428 | 1349 } |
1350 | |
1351 /* Return any frame for which PREDICATE is non-zero, or return Qnil | |
1352 if there aren't any. */ | |
1353 | |
1354 Lisp_Object | |
1355 find_some_frame (int (*predicate) (Lisp_Object, void *), | |
1356 void *closure) | |
1357 { | |
1358 Lisp_Object framecons, devcons, concons; | |
1359 | |
1360 FRAME_LOOP_NO_BREAK (framecons, devcons, concons) | |
1361 { | |
1362 Lisp_Object frame = XCAR (framecons); | |
1363 | |
1364 if ((predicate) (frame, closure)) | |
1365 return frame; | |
1366 } | |
1367 | |
1368 return Qnil; | |
1369 } | |
1370 | |
1371 | |
1372 | |
1373 /* extern void free_line_insertion_deletion_costs (struct frame *f); */ | |
1374 | |
1375 /* Return 1 if it is ok to delete frame F; | |
1376 0 if all frames aside from F are invisible. | |
1377 (Exception: if F is a stream frame, it's OK to delete if | |
1378 any other frames exist.) */ | |
1379 | |
442 | 1380 int |
1381 other_visible_frames (struct frame *f) | |
428 | 1382 { |
793 | 1383 Lisp_Object frame = wrap_frame (f); |
1384 | |
428 | 1385 if (FRAME_STREAM_P (f)) |
442 | 1386 return !EQ (frame, next_frame (frame, Qt, Qt)); |
1387 return !EQ (frame, next_frame (frame, Qvisible_iconic_nomini, Qt)); | |
428 | 1388 } |
1389 | |
1390 /* Delete frame F. | |
1391 | |
1392 If FORCE is non-zero, allow deletion of the only frame. | |
1393 | |
1394 If CALLED_FROM_DELETE_DEVICE is non-zero, then, if | |
1395 deleting the last frame on a device, just delete it, | |
1396 instead of calling `delete-device'. | |
1397 | |
1398 If FROM_IO_ERROR is non-zero, then the frame is gone due | |
1399 to an I/O error. This affects what happens if we exit | |
1400 (we do an emergency exit instead of `save-buffers-kill-emacs'.) | |
1401 */ | |
1402 | |
1403 void | |
1404 delete_frame_internal (struct frame *f, int force, | |
1405 int called_from_delete_device, | |
1406 int from_io_error) | |
1407 { | |
1408 /* This function can GC */ | |
1409 int minibuffer_selected; | |
1410 struct device *d; | |
1411 struct console *con; | |
1412 Lisp_Object frame; | |
1413 Lisp_Object device; | |
1414 Lisp_Object console; | |
1415 struct gcpro gcpro1; | |
1313 | 1416 int depth; |
428 | 1417 |
1418 /* OK to delete an already deleted frame. */ | |
853 | 1419 if (!FRAME_LIVE_P (f)) |
428 | 1420 return; |
1421 | |
793 | 1422 frame = wrap_frame (f); |
853 | 1423 |
1424 if (!force) | |
1425 check_allowed_operation (OPERATION_DELETE_OBJECT, frame, Qnil); | |
1426 | |
428 | 1427 GCPRO1 (frame); |
1428 | |
1429 device = FRAME_DEVICE (f); | |
1430 d = XDEVICE (device); | |
1431 console = DEVICE_CONSOLE (d); | |
1432 con = XCONSOLE (console); | |
1433 | |
545 | 1434 if (!called_from_delete_device |
1435 && !DEVICE_IMPL_FLAG (d, XDEVIMPF_FRAMELESS_OK)) | |
428 | 1436 { |
1437 /* If we're deleting the only non-minibuffer frame on the | |
1438 device, delete the device. */ | |
1439 if (EQ (frame, next_frame (frame, Qnomini, FRAME_DEVICE (f)))) | |
1440 { | |
1441 delete_device_internal (d, force, 0, from_io_error); | |
1442 UNGCPRO; | |
1443 return; | |
1444 } | |
1445 } | |
1446 | |
1447 /* In FSF, delete-frame will not normally allow you to delete the | |
1448 last visible frame. This was too annoying, so we changed it to the | |
1449 only frame. However, this would let people shoot themselves by | |
1450 deleting all frames which were either visible or iconified and thus | |
1451 losing any way of communicating with the still running XEmacs process. | |
1452 So we put it back. */ | |
1453 if (!force && !allow_deletion_of_last_visible_frame && | |
442 | 1454 !other_visible_frames (f)) |
563 | 1455 invalid_operation ("Attempt to delete the sole visible or iconified frame", Qunbound); |
428 | 1456 |
1457 /* Does this frame have a minibuffer, and is it the surrogate | |
1458 minibuffer for any other frame? */ | |
1459 if (FRAME_HAS_MINIBUF_P (f)) | |
1460 { | |
1461 Lisp_Object frmcons, devcons, concons; | |
1462 | |
1463 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) | |
1464 { | |
2552 | 1465 Lisp_Object this_frame = XCAR (frmcons); |
1466 | |
1467 if (! EQ (this_frame, frame) | |
428 | 1468 && EQ (frame, (WINDOW_FRAME |
1469 (XWINDOW | |
2552 | 1470 (FRAME_MINIBUF_WINDOW (XFRAME (this_frame))))))) |
428 | 1471 { |
1472 /* We've found another frame whose minibuffer is on | |
1473 this frame. */ | |
563 | 1474 gui_error |
428 | 1475 ("Attempt to delete a surrogate minibuffer frame", frame); |
1476 } | |
1477 } | |
1478 } | |
1479 | |
1480 /* Test for popup frames hanging around. */ | |
1481 /* Deletion of a parent frame with popups is deadly. */ | |
1482 { | |
1483 Lisp_Object frmcons, devcons, concons; | |
1484 | |
1485 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) | |
1486 { | |
2552 | 1487 Lisp_Object this_frame = XCAR (frmcons); |
1488 | |
1489 | |
1490 if (! EQ (this_frame, frame)) | |
428 | 1491 { |
1492 struct device *devcons_d = XDEVICE (XCAR (devcons)); | |
1493 if (EQ (frame, DEVMETH_OR_GIVEN (devcons_d, get_frame_parent, | |
2552 | 1494 (XFRAME (this_frame)), |
428 | 1495 Qnil))) |
1496 /* We've found a popup frame whose parent is this frame. */ | |
563 | 1497 gui_error |
428 | 1498 ("Attempt to delete a frame with live popups", frame); |
1499 } | |
1500 } | |
1501 } | |
1502 | |
1503 /* Before here, we haven't made any dangerous changes (just checked for | |
1504 error conditions). Now run the delete-frame-hook. Remember that | |
1505 user code there could do any number of dangerous things, including | |
1506 signalling an error. */ | |
1507 | |
1508 va_run_hook_with_args (Qdelete_frame_hook, 1, frame); | |
1509 | |
1510 if (!FRAME_LIVE_P (f)) /* Make sure the delete-frame-hook didn't */ | |
1511 { /* go ahead and delete anything. */ | |
1512 UNGCPRO; | |
1513 return; | |
1514 } | |
1515 | |
1516 /* Call the delete-device-hook and delete-console-hook now if | |
1517 appropriate, before we do any dangerous things -- they too could | |
1518 signal an error. */ | |
1519 if (XINT (Flength (DEVICE_FRAME_LIST (d))) == 1) | |
1520 { | |
1521 va_run_hook_with_args (Qdelete_device_hook, 1, device); | |
1522 if (!FRAME_LIVE_P (f)) /* Make sure the delete-device-hook didn't */ | |
1523 { /* go ahead and delete anything. */ | |
1524 UNGCPRO; | |
1525 return; | |
1526 } | |
1527 | |
1528 if (XINT (Flength (CONSOLE_DEVICE_LIST (con))) == 1) | |
1529 { | |
1530 va_run_hook_with_args (Qdelete_console_hook, 1, console); | |
1531 if (!FRAME_LIVE_P (f)) /* Make sure the delete-console-hook didn't */ | |
1532 { /* go ahead and delete anything. */ | |
1533 UNGCPRO; | |
1534 return; | |
1535 } | |
1536 } | |
1537 } | |
1538 | |
1539 minibuffer_selected = EQ (minibuf_window, Fselected_window (Qnil)); | |
1540 | |
1541 /* If we were focused on this frame, then we're not any more. | |
1542 Assume that we lost the focus; that way, the call to | |
1543 Fselect_frame() below won't end up making us explicitly | |
1544 focus on another frame, which is generally undesirable in | |
1545 a point-to-type world. If our mouse ends up sitting over | |
1546 another frame, we will receive a FocusIn event and end up | |
1547 making that frame the selected frame. | |
1548 | |
1549 #### This may not be an ideal solution in a click-to-type | |
1550 world (in that case, we might want to explicitly choose | |
1551 another frame to have the focus, rather than relying on | |
1552 the WM, which might focus on a frame in a different app | |
1553 or focus on nothing at all). But there's no easy way | |
1554 to detect which focus model we're running on, and the | |
1555 alternative is more heinous. */ | |
1556 | |
1557 if (EQ (frame, DEVICE_FRAME_WITH_FOCUS_REAL (d))) | |
1558 DEVICE_FRAME_WITH_FOCUS_REAL (d) = Qnil; | |
1559 if (EQ (frame, DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d))) | |
1560 DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d) = Qnil; | |
1561 if (EQ (frame, DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d))) | |
1562 DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d) = Qnil; | |
1563 | |
1564 /* Don't allow the deleted frame to remain selected. | |
1565 Note that in the former scheme of things, this would | |
1566 have caused us to regain the focus. This no longer | |
1567 applies (see above); I think the new behavior is more | |
1568 logical. If someone disagrees, it can always be | |
1569 changed (or a new user variable can be introduced, ugh.) */ | |
1570 if (EQ (frame, DEVICE_SELECTED_FRAME (d))) | |
1571 { | |
1572 Lisp_Object next; | |
1573 | |
1574 /* If this is a popup frame, select its parent if possible. | |
1575 Otherwise, find another visible frame; if none, just take any frame. | |
1576 First try the same device, then the same console. */ | |
1577 | |
1578 next = DEVMETH_OR_GIVEN (d, get_frame_parent, (f), Qnil); | |
1579 if (NILP (next) || EQ (next, frame) || ! FRAME_LIVE_P (XFRAME (next))) | |
442 | 1580 next = next_frame (frame, Qvisible, device); |
428 | 1581 if (NILP (next) || EQ (next, frame)) |
442 | 1582 next = next_frame (frame, Qvisible, console); |
1583 if (NILP (next) || EQ (next, frame)) | |
1584 next = next_frame (frame, Qvisible, Qt); | |
428 | 1585 if (NILP (next) || EQ (next, frame)) |
442 | 1586 next = next_frame (frame, Qt, device); |
428 | 1587 if (NILP (next) || EQ (next, frame)) |
442 | 1588 next = next_frame (frame, Qt, console); |
428 | 1589 if (NILP (next) || EQ (next, frame)) |
442 | 1590 next = next_frame (frame, Qt, Qt); |
428 | 1591 |
1592 /* if we haven't found another frame at this point | |
1593 then there aren't any. */ | |
1594 if (NILP (next) || EQ (next, frame)) | |
1595 ; | |
1596 else | |
1597 { | |
1598 int did_select = 0; | |
1599 /* if this is the global selected frame, select another one. */ | |
1600 if (EQ (frame, Fselected_frame (Qnil))) | |
1601 { | |
1602 Fselect_frame (next); | |
1603 did_select = 1; | |
1604 } | |
1605 /* | |
1606 * If the new frame we just selected is on a different | |
1607 * device then we still need to change DEVICE_SELECTED_FRAME(d) | |
1608 * to a live frame, if there are any left on this device. | |
1609 */ | |
1610 if (!EQ (device, FRAME_DEVICE(XFRAME(next)))) | |
1611 { | |
442 | 1612 Lisp_Object next_f = next_frame (frame, Qt, device); |
428 | 1613 if (NILP (next_f) || EQ (next_f, frame)) |
440 | 1614 set_device_selected_frame (d, Qnil); |
428 | 1615 else |
1616 set_device_selected_frame (d, next_f); | |
1617 } | |
1618 else if (! did_select) | |
1619 set_device_selected_frame (d, next); | |
1620 | |
1621 } | |
1622 } | |
1623 | |
1624 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
1625 if (EQ (f->minibuffer_window, minibuf_window)) | |
1626 { | |
1627 struct frame *sel_frame = selected_frame (); | |
1628 Fset_window_buffer (sel_frame->minibuffer_window, | |
440 | 1629 XWINDOW (minibuf_window)->buffer, Qt); |
428 | 1630 minibuf_window = sel_frame->minibuffer_window; |
1631 | |
1632 /* If the dying minibuffer window was selected, | |
1633 select the new one. */ | |
1634 if (minibuffer_selected) | |
1635 Fselect_window (minibuf_window, Qnil); | |
1636 } | |
1637 | |
1638 /* After this point, no errors must be allowed to occur. */ | |
1639 | |
1313 | 1640 /* Checking for QUIT can run all sorts of weird code and may be deadly |
1641 so don't let it happen. */ | |
1642 depth = begin_dont_check_for_quit (); | |
1643 | |
428 | 1644 #ifdef HAVE_MENUBARS |
1645 free_frame_menubars (f); | |
1646 #endif | |
1647 #ifdef HAVE_SCROLLBARS | |
1648 free_frame_scrollbars (f); | |
1649 #endif | |
1650 #ifdef HAVE_TOOLBARS | |
1651 free_frame_toolbars (f); | |
1652 #endif | |
1653 free_frame_gutters (f); | |
442 | 1654 /* Unfortunately deleting the frame will also delete the parent of |
1655 all of the subwindow instances current on the frame. I think this | |
1656 can lead to bad things when trying to finalize the | |
1657 instances. Thus we loop over all instance caches calling the | |
1658 finalize method for each instance. */ | |
1659 free_frame_subwindow_instances (f); | |
428 | 1660 |
1661 /* This must be done before the window and window_mirror structures | |
1662 are freed. The scrollbar information is attached to them. */ | |
1663 MAYBE_FRAMEMETH (f, delete_frame, (f)); | |
1664 | |
1665 /* Mark all the windows that used to be on FRAME as deleted, and then | |
1666 remove the reference to them. */ | |
1667 delete_all_subwindows (XWINDOW (f->root_window)); | |
1668 f->root_window = Qnil; | |
1669 | |
1670 /* clear out the cached glyph information */ | |
442 | 1671 f->subwindow_instance_cache = Qnil; |
428 | 1672 |
1673 /* Remove the frame now from the list. This way, any events generated | |
1674 on this frame by the maneuvers below will disperse themselves. */ | |
1675 | |
1676 /* This used to be Fdelq(), but that will cause a seg fault if the | |
1677 QUIT checker happens to get invoked, because the frame list is in | |
1678 an inconsistent state. */ | |
1679 d->frame_list = delq_no_quit (frame, d->frame_list); | |
1680 RESET_CHANGED_SET_FLAGS; | |
1681 | |
1682 f->visible = 0; | |
1683 | |
617 | 1684 free_window_mirror (XWINDOW_MIRROR (f->root_mirror)); |
853 | 1685 |
428 | 1686 /* free_line_insertion_deletion_costs (f); */ |
1687 | |
1688 /* If we've deleted the last non-minibuf frame, then try to find | |
1689 another one. */ | |
1690 if (EQ (frame, CONSOLE_LAST_NONMINIBUF_FRAME (con))) | |
1691 { | |
1692 Lisp_Object frmcons, devcons; | |
1693 | |
1694 set_console_last_nonminibuf_frame (con, Qnil); | |
1695 | |
1696 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, con) | |
1697 { | |
1698 Lisp_Object ecran = XCAR (frmcons); | |
1699 if (!FRAME_MINIBUF_ONLY_P (XFRAME (ecran))) | |
1700 { | |
1701 set_console_last_nonminibuf_frame (con, ecran); | |
1702 goto double_break_1; | |
1703 } | |
1704 } | |
1705 } | |
1706 double_break_1: | |
1707 | |
1708 #if 0 | |
1709 /* The following test is degenerate FALSE */ | |
1710 if (called_from_delete_device < 0) | |
1711 /* then we're being called from delete-console, and we shouldn't | |
1712 try to find another default-minibuffer frame for the console. | |
1713 */ | |
1714 con->default_minibuffer_frame = Qnil; | |
1715 #endif | |
1716 | |
1717 /* If we've deleted this console's default_minibuffer_frame, try to | |
1718 find another one. Prefer minibuffer-only frames, but also notice | |
1719 frames with other windows. */ | |
1720 if (EQ (frame, con->default_minibuffer_frame)) | |
1721 { | |
1722 Lisp_Object frmcons, devcons; | |
1723 /* The last frame we saw with a minibuffer, minibuffer-only or not. */ | |
1724 Lisp_Object frame_with_minibuf; | |
1725 /* Some frame we found on the same console, or nil if there are none. */ | |
1726 Lisp_Object frame_on_same_console; | |
1727 | |
1728 frame_on_same_console = Qnil; | |
1729 frame_with_minibuf = Qnil; | |
1730 | |
1731 set_console_last_nonminibuf_frame (con, Qnil); | |
1732 | |
1733 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, con) | |
1734 { | |
2552 | 1735 Lisp_Object this_frame; |
428 | 1736 struct frame *f1; |
1737 | |
2552 | 1738 this_frame = XCAR (frmcons); |
1739 f1 = XFRAME (this_frame); | |
428 | 1740 |
1741 /* Consider only frames on the same console | |
1742 and only those with minibuffers. */ | |
1743 if (FRAME_HAS_MINIBUF_P (f1)) | |
1744 { | |
2552 | 1745 frame_with_minibuf = this_frame; |
428 | 1746 if (FRAME_MINIBUF_ONLY_P (f1)) |
1747 goto double_break_2; | |
1748 } | |
1749 | |
2552 | 1750 frame_on_same_console = this_frame; |
428 | 1751 } |
1752 double_break_2: | |
1753 | |
1754 if (!NILP (frame_on_same_console)) | |
1755 { | |
1756 /* We know that there must be some frame with a minibuffer out | |
1757 there. If this were not true, all of the frames present | |
1758 would have to be minibuffer-less, which implies that at some | |
1759 point their minibuffer frames must have been deleted, but | |
1760 that is prohibited at the top; you can't delete surrogate | |
1761 minibuffer frames. */ | |
1762 if (NILP (frame_with_minibuf)) | |
2500 | 1763 ABORT (); |
428 | 1764 |
1765 con->default_minibuffer_frame = frame_with_minibuf; | |
1766 } | |
1767 else | |
1768 /* No frames left on this console--say no minibuffer either. */ | |
1769 con->default_minibuffer_frame = Qnil; | |
1770 } | |
1771 | |
617 | 1772 /* Nobody should be accessing anything in this object any more, and |
1773 making all Lisp_Objects Qnil allows for better GC'ing in case a | |
1774 pointer to the dead frame continues to hang around. Zero all | |
1775 other structs in case someone tries to access something through | |
1776 them. */ | |
1777 | |
1778 nuke_all_frame_slots (f); | |
428 | 1779 f->framemeths = dead_console_methods; |
1204 | 1780 f->frametype = dead_console; |
617 | 1781 |
853 | 1782 note_object_deleted (frame); |
1783 | |
1313 | 1784 unbind_to (depth); |
1785 | |
428 | 1786 UNGCPRO; |
1787 } | |
1788 | |
1789 void | |
1790 io_error_delete_frame (Lisp_Object frame) | |
1791 { | |
1792 delete_frame_internal (XFRAME (frame), 1, 0, 1); | |
1793 } | |
1794 | |
1795 DEFUN ("delete-frame", Fdelete_frame, 0, 2, "", /* | |
1796 Delete FRAME, permanently eliminating it from use. | |
1797 If omitted, FRAME defaults to the selected frame. | |
1798 A frame may not be deleted if its minibuffer is used by other frames. | |
1799 Normally, you cannot delete the last non-minibuffer-only frame (you must | |
1800 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional | |
1801 second argument FORCE is non-nil, you can delete the last frame. (This | |
1802 will automatically call `save-buffers-kill-emacs'.) | |
1803 */ | |
1804 (frame, force)) | |
1805 { | |
1806 /* This function can GC */ | |
1807 struct frame *f; | |
1808 | |
1809 if (NILP (frame)) | |
1810 { | |
1811 f = selected_frame (); | |
793 | 1812 frame = wrap_frame (f); |
428 | 1813 } |
1814 else | |
1815 { | |
1816 CHECK_FRAME (frame); | |
1817 f = XFRAME (frame); | |
1818 } | |
1819 | |
1820 delete_frame_internal (f, !NILP (force), 0, 0); | |
1821 return Qnil; | |
1822 } | |
1823 | |
1824 | |
1825 /* Return mouse position in character cell units. */ | |
1826 | |
1827 static int | |
1828 mouse_pixel_position_1 (struct device *d, Lisp_Object *frame, | |
1829 int *x, int *y) | |
1830 { | |
1831 switch (DEVMETH_OR_GIVEN (d, get_mouse_position, (d, frame, x, y), -1)) | |
1832 { | |
1833 case 1: | |
1834 return 1; | |
1835 | |
1836 case 0: | |
1837 *frame = Qnil; | |
1838 break; | |
1839 | |
1840 case -1: | |
1841 *frame = DEVICE_SELECTED_FRAME (d); | |
1842 break; | |
1843 | |
1844 default: | |
2500 | 1845 ABORT (); /* method is incorrectly written */ |
428 | 1846 } |
1847 | |
1848 return 0; | |
1849 } | |
1850 | |
1851 DEFUN ("mouse-pixel-position", Fmouse_pixel_position, 0, 1, 0, /* | |
1852 Return a list (WINDOW X . Y) giving the current mouse window and position. | |
442 | 1853 The position is given in pixel units, where (0, 0) is the upper-left corner |
1854 of the window. | |
428 | 1855 |
1856 When the cursor is not over a window, the return value is a list (nil nil). | |
1857 | |
1858 DEVICE specifies the device on which to read the mouse position, and | |
1859 defaults to the selected device. If the device is a mouseless terminal | |
442 | 1860 or XEmacs hasn't been programmed to read its mouse position, it returns |
428 | 1861 the device's selected window for WINDOW and nil for X and Y. |
1862 */ | |
1863 (device)) | |
1864 { | |
1865 struct device *d = decode_device (device); | |
1866 Lisp_Object frame; | |
1867 Lisp_Object window = Qnil; | |
1868 Lisp_Object x = Qnil; | |
1869 Lisp_Object y = Qnil; | |
1870 int intx, inty; | |
1871 | |
1872 if (mouse_pixel_position_1 (d, &frame, &intx, &inty) > 0) | |
1873 { | |
1874 struct window *w = | |
1875 find_window_by_pixel_pos (intx, inty, XFRAME (frame)->root_window); | |
1876 if (w) | |
1877 { | |
793 | 1878 window = wrap_window (w); |
428 | 1879 |
1880 /* Adjust the position to be relative to the window. */ | |
1881 intx -= w->pixel_left; | |
1882 inty -= w->pixel_top; | |
793 | 1883 x = make_int (intx); |
1884 y = make_int (inty); | |
428 | 1885 } |
1886 } | |
1887 else if (FRAMEP (frame)) | |
1888 window = FRAME_SELECTED_WINDOW (XFRAME (frame)); | |
1889 | |
1890 return Fcons (window, Fcons (x, y)); | |
1891 } | |
1892 | |
1893 DEFUN ("mouse-position", Fmouse_position, 0, 1, 0, /* | |
1894 Return a list (WINDOW X . Y) giving the current mouse window and position. | |
1895 The position is of a character under cursor, where (0, 0) is the upper-left | |
1896 corner of the window. | |
1897 | |
1898 When the cursor is not over a character, or not over a window, the return | |
1899 value is a list (nil nil). | |
1900 | |
1901 DEVICE specifies the device on which to read the mouse position, and | |
1902 defaults to the selected device. If the device is a mouseless terminal | |
1903 or Emacs hasn't been programmed to read its mouse position, it returns | |
1904 the device's selected window for WINDOW and nil for X and Y. | |
1905 */ | |
1906 (device)) | |
1907 { | |
1908 struct device *d = decode_device (device); | |
1909 struct window *w; | |
1910 Lisp_Object frame, window = Qnil, lisp_x = Qnil, lisp_y = Qnil; | |
1911 int x, y, obj_x, obj_y; | |
665 | 1912 Charbpos charbpos, closest; |
428 | 1913 Charcount modeline_closest; |
1914 Lisp_Object obj1, obj2; | |
1915 | |
1916 if (mouse_pixel_position_1 (d, &frame, &x, &y) > 0) | |
1917 { | |
1918 int res = pixel_to_glyph_translation (XFRAME (frame), x, y, &x, &y, | |
665 | 1919 &obj_x, &obj_y, &w, &charbpos, |
428 | 1920 &closest, &modeline_closest, |
1921 &obj1, &obj2); | |
1922 if (res == OVER_TEXT) | |
1923 { | |
1924 lisp_x = make_int (x); | |
1925 lisp_y = make_int (y); | |
793 | 1926 window = wrap_window (w); |
428 | 1927 } |
1928 } | |
1929 else if (FRAMEP (frame)) | |
1930 window = FRAME_SELECTED_WINDOW (XFRAME (frame)); | |
1931 | |
1932 return Fcons (window, Fcons (lisp_x, lisp_y)); | |
1933 } | |
1934 | |
1935 DEFUN ("mouse-position-as-motion-event", Fmouse_position_as_motion_event, 0, 1, 0, /* | |
1936 Return the current mouse position as a motion event. | |
1937 This allows you to call the standard event functions such as | |
1938 `event-over-toolbar-p' to determine where the mouse is. | |
1939 | |
1940 DEVICE specifies the device on which to read the mouse position, and | |
1941 defaults to the selected device. If the mouse position can't be determined | |
1942 \(e.g. DEVICE is a TTY device), nil is returned instead of an event. | |
1943 */ | |
1944 (device)) | |
1945 { | |
1946 struct device *d = decode_device (device); | |
1947 Lisp_Object frame; | |
1948 int intx, inty; | |
1949 | |
1950 if (mouse_pixel_position_1 (d, &frame, &intx, &inty)) | |
1951 { | |
1952 Lisp_Object event = Fmake_event (Qnil, Qnil); | |
934 | 1953 XSET_EVENT_TYPE (event, pointer_motion_event); |
1954 XSET_EVENT_CHANNEL (event, frame); | |
1204 | 1955 XSET_EVENT_MOTION_X (event, intx); |
1956 XSET_EVENT_MOTION_Y (event, inty); | |
428 | 1957 return event; |
1958 } | |
1959 else | |
1960 return Qnil; | |
1961 } | |
1962 | |
1963 DEFUN ("set-mouse-position", Fset_mouse_position, 3, 3, 0, /* | |
1964 Move the mouse pointer to the center of character cell (X,Y) in WINDOW. | |
1965 Note, this is a no-op for an X frame that is not visible. | |
1966 If you have just created a frame, you must wait for it to become visible | |
1967 before calling this function on it, like this. | |
1968 (while (not (frame-visible-p frame)) (sleep-for .5)) | |
1969 Note also: Warping the mouse is contrary to the ICCCM, so be very sure | |
1970 that the behavior won't end up being obnoxious! | |
1971 */ | |
1972 (window, x, y)) | |
1973 { | |
1974 struct window *w; | |
1975 int pix_x, pix_y; | |
1976 | |
1977 CHECK_LIVE_WINDOW (window); | |
1978 CHECK_INT (x); | |
1979 CHECK_INT (y); | |
1980 | |
1981 /* Warping the mouse will cause EnterNotify and Focus events under X. */ | |
1982 w = XWINDOW (window); | |
1983 glyph_to_pixel_translation (w, XINT (x), XINT (y), &pix_x, &pix_y); | |
1984 | |
1985 MAYBE_FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, pix_x, pix_y)); | |
1986 | |
1987 return Qnil; | |
1988 } | |
1989 | |
1990 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position, 3, 3, 0, /* | |
1991 Move the mouse pointer to pixel position (X,Y) in WINDOW. | |
1992 Note, this is a no-op for an X frame that is not visible. | |
1993 If you have just created a frame, you must wait for it to become visible | |
1994 before calling this function on it, like this. | |
1995 (while (not (frame-visible-p frame)) (sleep-for .5)) | |
1996 */ | |
1997 (window, x, y)) | |
1998 { | |
1999 struct window *w; | |
2000 | |
2001 CHECK_LIVE_WINDOW (window); | |
2002 CHECK_INT (x); | |
2003 CHECK_INT (y); | |
2004 | |
2005 /* Warping the mouse will cause EnterNotify and Focus events under X. */ | |
2006 w = XWINDOW (window); | |
2007 FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, XINT (x), XINT (y))); | |
2008 | |
2009 return Qnil; | |
2010 } | |
2011 | |
2012 DEFUN ("make-frame-visible", Fmake_frame_visible, 0, 1, 0, /* | |
2013 Make the frame FRAME visible (assuming it is an X-window). | |
2014 If omitted, FRAME defaults to the currently selected frame. | |
2015 Also raises the frame so that nothing obscures it. | |
2016 */ | |
2017 (frame)) | |
2018 { | |
2019 struct frame *f = decode_frame (frame); | |
2020 | |
2021 MAYBE_FRAMEMETH (f, make_frame_visible, (f)); | |
2022 return frame; | |
2023 } | |
2024 | |
2025 DEFUN ("make-frame-invisible", Fmake_frame_invisible, 0, 2, 0, /* | |
2026 Unconditionally removes frame from the display (assuming it is an X-window). | |
2027 If omitted, FRAME defaults to the currently selected frame. | |
2028 If what you want to do is iconify the frame (if the window manager uses | |
2029 icons) then you should call `iconify-frame' instead. | |
2030 Normally you may not make FRAME invisible if all other frames are invisible | |
2031 and uniconified, but if the second optional argument FORCE is non-nil, | |
2032 you may do so. | |
2033 */ | |
2034 (frame, force)) | |
2035 { | |
2036 struct frame *f, *sel_frame; | |
2037 struct device *d; | |
2038 | |
2039 f = decode_frame (frame); | |
2040 d = XDEVICE (FRAME_DEVICE (f)); | |
2041 sel_frame = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
2042 | |
2043 if (NILP (force) && !other_visible_frames (f)) | |
563 | 2044 invalid_operation ("Attempt to make invisible the sole visible or iconified frame", Qunbound); |
428 | 2045 |
2046 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
2047 if (EQ (f->minibuffer_window, minibuf_window)) | |
2048 { | |
2049 Fset_window_buffer (sel_frame->minibuffer_window, | |
440 | 2050 XWINDOW (minibuf_window)->buffer, Qt); |
428 | 2051 minibuf_window = sel_frame->minibuffer_window; |
2052 } | |
2053 | |
2054 MAYBE_FRAMEMETH (f, make_frame_invisible, (f)); | |
2055 | |
2056 return Qnil; | |
2057 } | |
2058 | |
2059 DEFUN ("iconify-frame", Ficonify_frame, 0, 1, "", /* | |
2060 Make the frame FRAME into an icon, if the window manager supports icons. | |
2061 If omitted, FRAME defaults to the currently selected frame. | |
2062 */ | |
2063 (frame)) | |
2064 { | |
2065 struct frame *f, *sel_frame; | |
2066 struct device *d; | |
2067 | |
2068 f = decode_frame (frame); | |
2069 d = XDEVICE (FRAME_DEVICE (f)); | |
2070 sel_frame = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
2071 | |
2072 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
2073 if (EQ (f->minibuffer_window, minibuf_window)) | |
2074 { | |
2075 Fset_window_buffer (sel_frame->minibuffer_window, | |
440 | 2076 XWINDOW (minibuf_window)->buffer, Qt); |
428 | 2077 minibuf_window = sel_frame->minibuffer_window; |
2078 } | |
2079 | |
2080 MAYBE_FRAMEMETH (f, iconify_frame, (f)); | |
2081 | |
2082 return Qnil; | |
2083 } | |
2084 | |
2085 DEFUN ("deiconify-frame", Fdeiconify_frame, 0, 1, 0, /* | |
2086 Open (de-iconify) the iconified frame FRAME. | |
2087 Under X, this is currently the same as `make-frame-visible'. | |
2088 If omitted, FRAME defaults to the currently selected frame. | |
2089 Also raises the frame so that nothing obscures it. | |
2090 */ | |
2091 (frame)) | |
2092 { | |
2093 return Fmake_frame_visible (frame); | |
2094 } | |
2095 | |
3025 | 2096 /* FSF returns `icon' for iconized frames. What a crock! */ |
428 | 2097 |
2098 DEFUN ("frame-visible-p", Fframe_visible_p, 0, 1, 0, /* | |
2099 Return non NIL if FRAME is now "visible" (actually in use for display). | |
2100 A frame that is not visible is not updated, and, if it works through a | |
2101 window system, may not show at all. | |
2102 N.B. Under X "visible" means Mapped. It the window is mapped but not | |
3025 | 2103 actually visible on screen then `frame-visible-p' returns `hidden'. |
428 | 2104 */ |
2105 (frame)) | |
2106 { | |
2107 struct frame *f = decode_frame (frame); | |
2108 int visible = FRAMEMETH_OR_GIVEN (f, frame_visible_p, (f), f->visible); | |
2109 return visible ? ( visible > 0 ? Qt : Qhidden ) : Qnil; | |
2110 } | |
2111 | |
2112 DEFUN ("frame-totally-visible-p", Fframe_totally_visible_p, 0, 1, 0, /* | |
2113 Return t if frame is not obscured by any other window system windows. | |
2114 Always returns t for tty frames. | |
2115 */ | |
2116 (frame)) | |
2117 { | |
2118 struct frame *f = decode_frame (frame); | |
2119 return (FRAMEMETH_OR_GIVEN (f, frame_totally_visible_p, (f), f->visible) | |
2120 ? Qt : Qnil); | |
2121 } | |
2122 | |
2123 DEFUN ("frame-iconified-p", Fframe_iconified_p, 0, 1, 0, /* | |
2124 Return t if FRAME is iconified. | |
2125 Not all window managers use icons; some merely unmap the window, so this | |
2126 function is not the inverse of `frame-visible-p'. It is possible for a | |
2127 frame to not be visible and not be iconified either. However, if the | |
2128 frame is iconified, it will not be visible. | |
2129 */ | |
2130 (frame)) | |
2131 { | |
2132 struct frame *f = decode_frame (frame); | |
2133 if (f->visible) | |
2134 return Qnil; | |
2135 f->iconified = FRAMEMETH_OR_GIVEN (f, frame_iconified_p, (f), 0); | |
2136 return f->iconified ? Qt : Qnil; | |
2137 } | |
2138 | |
2139 DEFUN ("visible-frame-list", Fvisible_frame_list, 0, 1, 0, /* | |
2140 Return a list of all frames now "visible" (being updated). | |
2141 If DEVICE is specified only frames on that device will be returned. | |
460 | 2142 Note that under virtual window managers not all these frames are |
2143 necessarily really updated. | |
428 | 2144 */ |
2145 (device)) | |
2146 { | |
2147 Lisp_Object devcons, concons; | |
2148 struct frame *f; | |
2149 Lisp_Object value; | |
2150 | |
2151 value = Qnil; | |
2152 | |
2153 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
2154 { | |
2155 assert (DEVICEP (XCAR (devcons))); | |
2156 | |
2157 if (NILP (device) || EQ (device, XCAR (devcons))) | |
2158 { | |
2159 Lisp_Object frmcons; | |
2160 | |
2161 DEVICE_FRAME_LOOP (frmcons, XDEVICE (XCAR (devcons))) | |
2162 { | |
2163 Lisp_Object frame = XCAR (frmcons); | |
2164 f = XFRAME (frame); | |
2165 if (FRAME_VISIBLE_P(f)) | |
2166 value = Fcons (frame, value); | |
2167 } | |
2168 } | |
2169 } | |
2170 | |
2171 return value; | |
2172 } | |
2173 | |
2174 | |
2175 DEFUN ("raise-frame", Fraise_frame, 0, 1, "", /* | |
2176 Bring FRAME to the front, so it occludes any frames it overlaps. | |
2177 If omitted, FRAME defaults to the currently selected frame. | |
2178 If FRAME is invisible, make it visible. | |
2179 If Emacs is displaying on an ordinary terminal or some other device which | |
2180 doesn't support multiple overlapping frames, this function does nothing. | |
2181 */ | |
2182 (frame)) | |
2183 { | |
2184 struct frame *f = decode_frame (frame); | |
2185 | |
2186 /* Do like the documentation says. */ | |
2187 Fmake_frame_visible (frame); | |
2188 MAYBE_FRAMEMETH (f, raise_frame, (f)); | |
2189 return Qnil; | |
2190 } | |
2191 | |
2192 DEFUN ("lower-frame", Flower_frame, 0, 1, "", /* | |
2193 Send FRAME to the back, so it is occluded by any frames that overlap it. | |
2194 If omitted, FRAME defaults to the currently selected frame. | |
2195 If Emacs is displaying on an ordinary terminal or some other device which | |
2196 doesn't support multiple overlapping frames, this function does nothing. | |
2197 */ | |
2198 (frame)) | |
2199 { | |
2200 struct frame *f = decode_frame (frame); | |
2201 | |
2202 MAYBE_FRAMEMETH (f, lower_frame, (f)); | |
2203 return Qnil; | |
2204 } | |
2205 | |
442 | 2206 |
2207 DEFUN ("disable-frame", Fdisable_frame, 1, 1, 0, /* | |
2208 Disable frame FRAME, so that it cannot have the focus or receive user input. | |
2209 This is normally used during modal dialog boxes. | |
2210 WARNING: Be very careful not to wedge XEmacs! | |
2211 Use an `unwind-protect' that re-enables the frame to avoid this. | |
2212 */ | |
2213 (frame)) | |
2214 { | |
2215 struct frame *f = decode_frame (frame); | |
2216 | |
2217 f->disabled = 1; | |
2218 MAYBE_FRAMEMETH (f, disable_frame, (f)); | |
2219 return Qnil; | |
2220 } | |
2221 | |
2222 DEFUN ("enable-frame", Fenable_frame, 1, 1, 0, /* | |
2223 Enable frame FRAME, so that it can have the focus and receive user input. | |
2224 Frames are normally enabled, unless explicitly disabled using `disable-frame'. | |
2225 */ | |
2226 (frame)) | |
2227 { | |
2228 struct frame *f = decode_frame (frame); | |
2229 f->disabled = 0; | |
2230 MAYBE_FRAMEMETH (f, enable_frame, (f)); | |
2231 return Qnil; | |
2232 } | |
2233 | |
428 | 2234 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', |
2235 crockish FSFmacs functions. See summary on focus in event-stream.c. */ | |
442 | 2236 |
2237 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /* | |
2238 Return current page number for the print job FRAME. | |
2239 */ | |
2240 (frame)) | |
2241 { | |
2242 CHECK_PRINTER_FRAME (frame); | |
2243 return make_int (FRAME_PAGENUMBER (XFRAME (frame))); | |
2244 } | |
2245 | |
2246 DEFUN ("print-job-eject-page", Fprint_job_eject_page, 1, 1, 0, /* | |
2247 Eject page in the print job FRAME. | |
2248 */ | |
2249 (frame)) | |
2250 { | |
2251 struct frame *f; | |
2252 | |
2253 CHECK_PRINTER_FRAME (frame); | |
2254 f = XFRAME (frame); | |
2255 FRAMEMETH (f, eject_page, (f)); | |
2256 FRAME_SET_PAGENUMBER (f, 1 + FRAME_PAGENUMBER (f)); | |
2257 f->clear = 1; | |
2258 | |
2259 return Qnil; | |
2260 } | |
428 | 2261 |
2262 | |
2263 /***************************************************************************/ | |
2264 /* frame properties */ | |
2265 /***************************************************************************/ | |
2266 | |
2267 static void internal_set_frame_size (struct frame *f, int cols, int rows, | |
2268 int pretend); | |
2269 | |
2270 static void | |
2271 store_minibuf_frame_prop (struct frame *f, Lisp_Object val) | |
2272 { | |
1318 | 2273 /* This can call Lisp. */ |
793 | 2274 Lisp_Object frame = wrap_frame (f); |
2275 | |
428 | 2276 if (WINDOWP (val)) |
2277 { | |
2278 if (! MINI_WINDOW_P (XWINDOW (val))) | |
563 | 2279 gui_error |
428 | 2280 ("Surrogate minibuffer windows must be minibuffer windows", |
2281 val); | |
2282 | |
2283 if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f)) | |
563 | 2284 gui_error |
428 | 2285 ("Can't change the surrogate minibuffer of a frame with its own minibuffer", frame); |
2286 | |
2287 /* Install the chosen minibuffer window, with proper buffer. */ | |
2288 f->minibuffer_window = val; | |
2289 } | |
2290 else if (EQ (val, Qt)) | |
2291 { | |
2292 if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f)) | |
563 | 2293 gui_error |
428 | 2294 ("Frame already has its own minibuffer", frame); |
2295 else | |
2296 { | |
2297 setup_normal_frame (f); | |
2298 f->mirror_dirty = 1; | |
2299 | |
2300 update_frame_window_mirror (f); | |
2301 internal_set_frame_size (f, f->width, f->height, 1); | |
2302 } | |
2303 } | |
2304 } | |
2305 | |
2306 #if 0 | |
2307 | |
2308 /* possible code if you want to have symbols such as `default-background' | |
2309 map to setting the background of `default', etc. */ | |
2310 | |
2311 static int | |
2312 dissect_as_face_setting (Lisp_Object sym, Lisp_Object *face_out, | |
2313 Lisp_Object *face_prop_out) | |
2314 { | |
2315 Lisp_Object list = Vbuilt_in_face_specifiers; | |
793 | 2316 Lisp_Object s; |
428 | 2317 |
2318 if (!SYMBOLP (sym)) | |
2319 return 0; | |
2320 | |
2321 s = symbol_name (XSYMBOL (sym)); | |
2322 | |
2323 while (!NILP (list)) | |
2324 { | |
2325 Lisp_Object prop = Fcar (list); | |
793 | 2326 Lisp_Object prop_name; |
428 | 2327 |
2328 if (!SYMBOLP (prop)) | |
2329 continue; | |
2330 prop_name = symbol_name (XSYMBOL (prop)); | |
793 | 2331 if (XSTRING_LENGTH (s) > XSTRING_LENGTH (prop_name) + 1 |
2332 && !memcmp (XSTRING_DATA (prop_name), | |
2333 XSTRING_DATA (s) + XSTRING_LENGTH (s) | |
2334 - XSTRING_LENGTH (prop_name), | |
2335 XSTRING_LENGTH (prop_name)) | |
2336 && XSTRING_DATA (s)[XSTRING_LENGTH (s) - XSTRING_LENGTH (prop_name) | |
428 | 2337 - 1] == '-') |
2338 { | |
2339 Lisp_Object face = | |
793 | 2340 Ffind_face (make_string (XSTRING_DATA (s), |
2341 XSTRING_LENGTH (s) | |
2342 - XSTRING_LENGTH (prop_name) | |
428 | 2343 - 1)); |
2344 if (!NILP (face)) | |
2345 { | |
2346 *face_out = face; | |
2347 *face_prop_out = prop; | |
2348 return 1; | |
2349 } | |
2350 } | |
2351 | |
2352 list = Fcdr (list); | |
2353 } | |
2354 | |
2355 return 0; | |
2356 } | |
2357 | |
2358 #endif /* 0 */ | |
2359 | |
2360 static Lisp_Object | |
2361 get_property_alias (Lisp_Object prop) | |
2362 { | |
2363 while (1) | |
2364 { | |
2365 Lisp_Object alias = Qnil; | |
2366 | |
2367 if (SYMBOLP (prop)) | |
2368 alias = Fget (prop, Qframe_property_alias, Qnil); | |
2369 if (NILP (alias)) | |
2370 break; | |
2371 prop = alias; | |
2372 QUIT; | |
2373 } | |
2374 | |
2375 return prop; | |
2376 } | |
2377 | |
2378 /* #### Using this to modify the internal border width has no effect | |
2379 because the change isn't propagated to the windows. Are there | |
2380 other properties which this claims to handle, but doesn't? | |
2381 | |
2382 But of course. This stuff needs more work, but it's a lot closer | |
2383 to sanity now than before with the horrible frame-params stuff. */ | |
2384 | |
2385 DEFUN ("set-frame-properties", Fset_frame_properties, 2, 2, 0, /* | |
2386 Change some properties of a frame. | |
2387 PLIST is a property list. | |
2388 You can also change frame properties individually using `set-frame-property', | |
2389 but it may be more efficient to change many properties at once. | |
2390 | |
2391 Frame properties can be retrieved using `frame-property' or `frame-properties'. | |
2392 | |
2393 The following symbols etc. have predefined meanings: | |
2394 | |
2395 name Name of the frame. Used with X resources. | |
2396 Unchangeable after creation. | |
2397 | |
2398 height Height of the frame, in lines. | |
2399 | |
2400 width Width of the frame, in characters. | |
2401 | |
2402 minibuffer Gives the minibuffer behavior for this frame. Either | |
2403 t (frame has its own minibuffer), `only' (frame is | |
442 | 2404 a minibuffer-only frame), `none' (frame has no minibuffer) |
2405 or a window (frame uses that window, which is on another | |
2406 frame, as the minibuffer). | |
428 | 2407 |
2408 unsplittable If non-nil, frame cannot be split by `display-buffer'. | |
2409 | |
2410 current-display-table, menubar-visible-p, left-margin-width, | |
2411 right-margin-width, minimum-line-ascent, minimum-line-descent, | |
2412 use-left-overflow, use-right-overflow, scrollbar-width, scrollbar-height, | |
2413 default-toolbar, top-toolbar, bottom-toolbar, left-toolbar, right-toolbar, | |
2414 default-toolbar-height, default-toolbar-width, top-toolbar-height, | |
2415 bottom-toolbar-height, left-toolbar-width, right-toolbar-width, | |
2416 default-toolbar-visible-p, top-toolbar-visible-p, bottom-toolbar-visible-p, | |
2417 left-toolbar-visible-p, right-toolbar-visible-p, toolbar-buttons-captioned-p, | |
2418 top-toolbar-border-width, bottom-toolbar-border-width, | |
2419 left-toolbar-border-width, right-toolbar-border-width, | |
442 | 2420 modeline-shadow-thickness, has-modeline-p, |
2421 default-gutter, top-gutter, bottom-gutter, left-gutter, right-gutter, | |
2422 default-gutter-height, default-gutter-width, top-gutter-height, | |
2423 bottom-gutter-height, left-gutter-width, right-gutter-width, | |
2424 default-gutter-visible-p, top-gutter-visible-p, bottom-gutter-visible-p, | |
2425 left-gutter-visible-p, right-gutter-visible-p, top-gutter-border-width, | |
2426 bottom-gutter-border-width, left-gutter-border-width, right-gutter-border-width, | |
428 | 2427 [Giving the name of any built-in specifier variable is |
2428 equivalent to calling `set-specifier' on the specifier, | |
2429 with a locale of FRAME. Giving the name to `frame-property' | |
2430 calls `specifier-instance' on the specifier.] | |
2431 | |
2432 text-pointer-glyph, nontext-pointer-glyph, modeline-pointer-glyph, | |
2433 selection-pointer-glyph, busy-pointer-glyph, toolbar-pointer-glyph, | |
2434 menubar-pointer-glyph, scrollbar-pointer-glyph, gc-pointer-glyph, | |
2435 octal-escape-glyph, control-arrow-glyph, invisible-text-glyph, | |
2436 hscroll-glyph, truncation-glyph, continuation-glyph | |
2437 [Giving the name of any glyph variable is equivalent to | |
2438 calling `set-glyph-image' on the glyph, with a locale | |
2439 of FRAME. Giving the name to `frame-property' calls | |
2440 `glyph-image-instance' on the glyph.] | |
2441 | |
2442 [default foreground], [default background], [default font], | |
2443 [modeline foreground], [modeline background], [modeline font], | |
2444 etc. | |
2445 [Giving a vector of a face and a property is equivalent | |
2446 to calling `set-face-property' on the face and property, | |
2447 with a locale of FRAME. Giving the vector to | |
2448 `frame-property' calls `face-property-instance' on the | |
2449 face and property.] | |
2450 | |
2451 Finally, if a frame property symbol has the property `frame-property-alias' | |
2452 on it, then the value will be used in place of that symbol when looking | |
2453 up and setting frame property values. This allows you to alias one | |
2454 frame property name to another. | |
2455 | |
2456 See the variables `default-x-frame-plist', `default-tty-frame-plist' | |
2457 and `default-mswindows-frame-plist' for a description of the properties | |
2458 recognized for particular types of frames. | |
2459 */ | |
2460 (frame, plist)) | |
2461 { | |
1318 | 2462 /* This can call Lisp. */ |
428 | 2463 struct frame *f = decode_frame (frame); |
2464 Lisp_Object tail; | |
2465 Lisp_Object *tailp; | |
2466 struct gcpro gcpro1, gcpro2; | |
2467 | |
793 | 2468 frame = wrap_frame (f); |
428 | 2469 GCPRO2 (frame, plist); |
2470 Fcheck_valid_plist (plist); | |
2471 plist = Fcopy_sequence (plist); | |
2472 Fcanonicalize_lax_plist (plist, Qnil); | |
2473 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail))) | |
2474 { | |
2475 Lisp_Object prop = Fcar (tail); | |
2476 Lisp_Object val = Fcar (Fcdr (tail)); | |
2477 | |
2478 prop = get_property_alias (prop); | |
2479 | |
2480 #if 0 | |
2481 /* mly wants this, but it's not reasonable to change the name of a | |
2482 frame after it has been created, because the old name was used | |
2483 for resource lookup. */ | |
2484 if (EQ (prop, Qname)) | |
2485 { | |
2486 CHECK_STRING (val); | |
2487 f->name = val; | |
2488 } | |
2489 #endif /* 0 */ | |
2490 if (EQ (prop, Qminibuffer)) | |
2491 store_minibuf_frame_prop (f, val); | |
2492 if (EQ (prop, Qunsplittable)) | |
2493 f->no_split = !NILP (val); | |
2494 if (EQ (prop, Qbuffer_predicate)) | |
2495 f->buffer_predicate = val; | |
2496 if (SYMBOLP (prop) && EQ (Fbuilt_in_variable_type (prop), | |
2497 Qconst_specifier)) | |
2498 call3 (Qset_specifier, Fsymbol_value (prop), val, frame); | |
2499 if (SYMBOLP (prop) && !NILP (Fget (prop, Qconst_glyph_variable, Qnil))) | |
2500 call3 (Qset_glyph_image, Fsymbol_value (prop), val, frame); | |
2501 if (VECTORP (prop) && XVECTOR_LENGTH (prop) == 2) | |
2502 { | |
2503 Lisp_Object face_prop = XVECTOR_DATA (prop)[1]; | |
2504 CHECK_SYMBOL (face_prop); | |
2505 call4 (Qset_face_property, | |
2506 Fget_face (XVECTOR_DATA (prop)[0]), | |
2507 face_prop, val, frame); | |
2508 } | |
2509 } | |
2510 | |
2511 MAYBE_FRAMEMETH (f, set_frame_properties, (f, plist)); | |
2512 for (tailp = &plist; !NILP (*tailp);) | |
2513 { | |
2514 Lisp_Object *next_tailp; | |
2515 Lisp_Object next; | |
2516 Lisp_Object prop; | |
2517 | |
2518 next = Fcdr (*tailp); | |
2519 CHECK_CONS (next); | |
2520 next_tailp = &XCDR (next); | |
2521 prop = Fcar (*tailp); | |
2522 | |
2523 prop = get_property_alias (prop); | |
2524 | |
2525 if (EQ (prop, Qminibuffer) | |
2526 || EQ (prop, Qunsplittable) | |
2527 || EQ (prop, Qbuffer_predicate) | |
2528 || EQ (prop, Qheight) | |
2529 || EQ (prop, Qwidth) | |
2530 || (SYMBOLP (prop) && EQ (Fbuilt_in_variable_type (prop), | |
2531 Qconst_specifier)) | |
2532 || (SYMBOLP (prop) && !NILP (Fget (prop, Qconst_glyph_variable, | |
2533 Qnil))) | |
2534 || (VECTORP (prop) && XVECTOR_LENGTH (prop) == 2) | |
2535 || FRAMEMETH_OR_GIVEN (f, internal_frame_property_p, (f, prop), 0)) | |
2536 *tailp = *next_tailp; | |
2537 tailp = next_tailp; | |
2538 } | |
2539 | |
2540 f->plist = nconc2 (plist, f->plist); | |
2541 Fcanonicalize_lax_plist (f->plist, Qnil); | |
2542 UNGCPRO; | |
2543 return Qnil; | |
2544 } | |
2545 | |
2546 DEFUN ("frame-property", Fframe_property, 2, 3, 0, /* | |
2547 Return FRAME's value for property PROPERTY. | |
444 | 2548 Return DEFAULT if there is no such property. |
428 | 2549 See `set-frame-properties' for the built-in property names. |
2550 */ | |
2551 (frame, property, default_)) | |
2552 { | |
2553 struct frame *f = decode_frame (frame); | |
2554 Lisp_Object value; | |
2555 | |
793 | 2556 frame = wrap_frame (f); |
428 | 2557 |
2558 property = get_property_alias (property); | |
2559 | |
2560 if (EQ (Qname, property)) return f->name; | |
2561 | |
2562 if (EQ (Qheight, property) || EQ (Qwidth, property)) | |
2563 { | |
2564 if (window_system_pixelated_geometry (frame)) | |
2565 { | |
2566 int width, height; | |
2567 pixel_to_real_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | |
2568 &width, &height); | |
2569 return make_int (EQ (Qheight, property) ? height: width); | |
2570 } | |
2571 else | |
2572 return make_int (EQ (Qheight, property) ? | |
2573 FRAME_HEIGHT (f) : | |
2574 FRAME_WIDTH (f)); | |
2575 } | |
2576 | |
2577 /* NOTE: FSF returns Qnil instead of Qt for FRAME_HAS_MINIBUF_P. | |
2578 This is over-the-top bogosity, because it's inconsistent with | |
2579 the semantics of `minibuffer' when passed to `make-frame'. | |
2580 Returning Qt makes things consistent. */ | |
2581 if (EQ (Qminibuffer, property)) | |
2582 return (FRAME_MINIBUF_ONLY_P (f) ? Qonly : | |
2583 FRAME_HAS_MINIBUF_P (f) ? Qt : | |
2584 FRAME_MINIBUF_WINDOW (f)); | |
2585 if (EQ (Qunsplittable, property)) | |
2586 return FRAME_NO_SPLIT_P (f) ? Qt : Qnil; | |
2587 if (EQ (Qbuffer_predicate, property)) | |
2588 return f->buffer_predicate; | |
2589 | |
2590 if (SYMBOLP (property)) | |
2591 { | |
2592 if (EQ (Fbuilt_in_variable_type (property), Qconst_specifier)) | |
2593 return Fspecifier_instance (Fsymbol_value (property), | |
2594 frame, default_, Qnil); | |
2595 if (!NILP (Fget (property, Qconst_glyph_variable, Qnil))) | |
2596 { | |
2597 Lisp_Object glyph = Fsymbol_value (property); | |
2598 CHECK_GLYPH (glyph); | |
2599 return Fspecifier_instance (XGLYPH_IMAGE (glyph), | |
2600 frame, default_, Qnil); | |
2601 } | |
2602 } | |
2603 | |
2604 if (VECTORP (property) && XVECTOR_LENGTH (property) == 2) | |
2605 { | |
2606 Lisp_Object face_prop = XVECTOR_DATA (property)[1]; | |
2607 CHECK_SYMBOL (face_prop); | |
2608 return call3 (Qface_property_instance, | |
2609 Fget_face (XVECTOR_DATA (property)[0]), | |
2610 face_prop, frame); | |
2611 } | |
2612 | |
2613 if (HAS_FRAMEMETH_P (f, frame_property)) | |
2614 if (!UNBOUNDP (value = FRAMEMETH (f, frame_property, (f, property)))) | |
2615 return value; | |
2616 | |
2617 if (!UNBOUNDP (value = external_plist_get (&f->plist, property, 1, ERROR_ME))) | |
2618 return value; | |
2619 | |
2620 return default_; | |
2621 } | |
2622 | |
2623 DEFUN ("frame-properties", Fframe_properties, 0, 1, 0, /* | |
2624 Return a property list of the properties of FRAME. | |
2625 Do not modify this list; use `set-frame-property' instead. | |
2626 */ | |
2627 (frame)) | |
2628 { | |
2629 struct frame *f = decode_frame (frame); | |
2630 Lisp_Object result = Qnil; | |
2631 struct gcpro gcpro1; | |
2632 | |
2633 GCPRO1 (result); | |
2634 | |
793 | 2635 frame = wrap_frame (f); |
428 | 2636 |
2637 /* #### for the moment (since old code uses `frame-parameters'), | |
2638 we call `copy-sequence' on f->plist. That allows frame-parameters | |
2639 to destructively convert the plist into an alist, which is more | |
2640 efficient than doing it non-destructively. At some point we | |
2641 should remove the call to copy-sequence. */ | |
2642 result = Fcopy_sequence (f->plist); | |
2643 | |
2644 /* #### should we be adding all the specifiers and glyphs? | |
2645 That would entail having a list of them all. */ | |
2646 if (HAS_FRAMEMETH_P (f, frame_properties)) | |
2647 result = nconc2 (FRAMEMETH (f, frame_properties, (f)), result); | |
2648 | |
2649 if (!NILP (f->buffer_predicate)) | |
2650 result = cons3 (Qbuffer_predicate, f->buffer_predicate, result); | |
2651 | |
2652 if (FRAME_NO_SPLIT_P (f)) | |
2653 result = cons3 (Qunsplittable, Qt, result); | |
2654 | |
2655 /* NOTE: FSF returns Qnil instead of Qt for FRAME_HAS_MINIBUF_P. | |
2656 This is over-the-top bogosity, because it's inconsistent with | |
2657 the semantics of `minibuffer' when passed to `make-frame'. | |
2658 Returning Qt makes things consistent. */ | |
2659 result = cons3 (Qminibuffer, | |
2660 (FRAME_MINIBUF_ONLY_P (f) ? Qonly : | |
2661 FRAME_HAS_MINIBUF_P (f) ? Qt : | |
2662 FRAME_MINIBUF_WINDOW (f)), | |
2663 result); | |
2664 { | |
2665 int width, height; | |
2666 | |
2667 if (window_system_pixelated_geometry (frame)) | |
2668 { | |
2669 pixel_to_real_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | |
2670 &width, &height); | |
2671 } | |
2672 else | |
2673 { | |
2674 height = FRAME_HEIGHT (f); | |
2675 width = FRAME_WIDTH (f); | |
2676 } | |
2677 result = cons3 (Qwidth , make_int (width), result); | |
2678 result = cons3 (Qheight, make_int (height), result); | |
2679 } | |
2680 | |
2681 result = cons3 (Qname, f->name, result); | |
2682 | |
2683 UNGCPRO; | |
2684 return result; | |
2685 } | |
2686 | |
2687 | |
2688 DEFUN ("frame-pixel-height", Fframe_pixel_height, 0, 1, 0, /* | |
1125 | 2689 Return the total height in pixels of FRAME. |
428 | 2690 */ |
2691 (frame)) | |
2692 { | |
2693 return make_int (decode_frame (frame)->pixheight); | |
2694 } | |
2695 | |
1125 | 2696 DEFUN ("frame-displayable-pixel-height", Fframe_displayable_pixel_height, 0, 1, 0, /* |
2697 Return the height of the displayable area in pixels of FRAME. | |
2698 */ | |
2699 (frame)) | |
2700 { | |
2701 struct frame *f = decode_frame (frame); | |
2702 int height, pheight; | |
2703 frame = wrap_frame (f); | |
2704 | |
2705 if (!window_system_pixelated_geometry (frame)) | |
2706 { | |
2707 height = FRAME_HEIGHT (f); | |
2708 | |
2709 frame_conversion_internal (f, CHAR_TO_DISPLAYABLE_PIXEL, | |
2710 0, &pheight, 0, &height, 0); | |
2711 } | |
2712 else | |
2713 pheight = FRAME_PIXHEIGHT (f); | |
2714 | |
2715 return make_int (pheight); | |
2716 } | |
2717 | |
428 | 2718 DEFUN ("frame-pixel-width", Fframe_pixel_width, 0, 1, 0, /* |
1125 | 2719 Return the total width in pixels of FRAME. |
428 | 2720 */ |
2721 (frame)) | |
2722 { | |
2723 return make_int (decode_frame (frame)->pixwidth); | |
2724 } | |
2725 | |
1125 | 2726 DEFUN ("frame-displayable-pixel-width", Fframe_displayable_pixel_width, 0, 1, 0, /* |
2727 Return the width of the displayable area in pixels of FRAME. | |
2728 */ | |
2729 (frame)) | |
2730 { | |
2731 struct frame *f = decode_frame (frame); | |
2732 int width, pwidth; | |
2733 frame = wrap_frame (f); | |
2734 | |
2735 if (!window_system_pixelated_geometry (frame)) | |
2736 { | |
2737 width = FRAME_WIDTH (f); | |
2738 | |
2739 frame_conversion_internal (f, CHAR_TO_DISPLAYABLE_PIXEL, | |
2740 &pwidth, 0, &width, 0, 0); | |
2741 } | |
2742 else | |
2743 pwidth = FRAME_PIXWIDTH (f); | |
2744 | |
2745 return make_int (pwidth); | |
2746 } | |
2747 | |
428 | 2748 DEFUN ("frame-name", Fframe_name, 0, 1, 0, /* |
2749 Return the name of FRAME (defaulting to the selected frame). | |
2750 This is not the same as the `title' of the frame. | |
2751 */ | |
2752 (frame)) | |
2753 { | |
2754 return decode_frame (frame)->name; | |
2755 } | |
2756 | |
2757 DEFUN ("frame-modified-tick", Fframe_modified_tick, 0, 1, 0, /* | |
2758 Return FRAME's tick counter, incremented for each change to the frame. | |
2759 Each frame has a tick counter which is incremented each time the frame | |
2760 is resized, a window is resized, added, or deleted, a face is changed, | |
2761 `set-window-buffer' or `select-window' is called on a window in the | |
2762 frame, the window-start of a window in the frame has changed, or | |
2763 anything else interesting has happened. It wraps around occasionally. | |
2764 No argument or nil as argument means use selected frame as FRAME. | |
2765 */ | |
2766 (frame)) | |
2767 { | |
2768 return make_int (decode_frame (frame)->modiff); | |
2769 } | |
2770 | |
2771 static void | |
2772 internal_set_frame_size (struct frame *f, int cols, int rows, int pretend) | |
2773 { | |
1318 | 2774 /* This can call Lisp. See mswindows_set_frame_size(). */ |
428 | 2775 /* An explicit size change cancels any pending frame size adjustment */ |
1318 | 2776 CLEAR_FRAME_SIZE_SLIPPED (f); |
428 | 2777 |
2778 if (pretend || !HAS_FRAMEMETH_P (f, set_frame_size)) | |
2779 change_frame_size (f, rows, cols, 0); | |
2780 else | |
2781 FRAMEMETH (f, set_frame_size, (f, cols, rows)); | |
2782 } | |
2783 | |
2784 DEFUN ("set-frame-height", Fset_frame_height, 2, 3, 0, /* | |
2785 Specify that the frame FRAME has LINES lines. | |
2786 Optional third arg non-nil means that redisplay should use LINES lines | |
2787 but that the idea of the actual height of the frame should not be changed. | |
2788 */ | |
444 | 2789 (frame, lines, pretend)) |
428 | 2790 { |
1318 | 2791 /* This can call Lisp. */ |
428 | 2792 struct frame *f = decode_frame (frame); |
2793 int height, width; | |
793 | 2794 frame = wrap_frame (f); |
444 | 2795 CHECK_INT (lines); |
428 | 2796 |
2797 if (window_system_pixelated_geometry (frame)) | |
2798 { | |
444 | 2799 char_to_real_pixel_size (f, 0, XINT (lines), 0, &height); |
428 | 2800 width = FRAME_PIXWIDTH (f); |
2801 } | |
2802 else | |
2803 { | |
444 | 2804 height = XINT (lines); |
428 | 2805 width = FRAME_WIDTH (f); |
2806 } | |
2807 | |
2808 internal_set_frame_size (f, width, height, !NILP (pretend)); | |
2809 return frame; | |
2810 } | |
2811 | |
863 | 2812 DEFUN ("set-frame-pixel-height", Fset_frame_pixel_height, 2, 3, 0, /* |
1125 | 2813 Specify that the frame FRAME is a total of HEIGHT pixels tall. |
863 | 2814 Optional third arg non-nil means that redisplay should be HEIGHT pixels tall |
2815 but that the idea of the actual height of the frame should not be changed. | |
2816 */ | |
2817 (frame, height, pretend)) | |
2818 { | |
1318 | 2819 /* This can call Lisp. */ |
863 | 2820 struct frame *f = decode_frame (frame); |
2821 int pheight, width; | |
2822 frame = wrap_frame (f); | |
2823 CHECK_INT (height); | |
2824 | |
2825 if (!window_system_pixelated_geometry (frame)) | |
2826 { | |
2827 int h = XINT (height); | |
2828 width = FRAME_WIDTH (f); | |
1125 | 2829 |
2830 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, 0, &h, 0, &pheight, 0); | |
863 | 2831 } |
2832 else | |
2833 { | |
2834 width = FRAME_PIXWIDTH (f); | |
2835 pheight = XINT (height); | |
2836 } | |
2837 | |
2838 internal_set_frame_size (f, width, pheight, !NILP (pretend)); | |
2839 return frame; | |
2840 } | |
2841 | |
1125 | 2842 DEFUN ("set-frame-displayable-pixel-height", Fset_frame_displayable_pixel_height, 2, 3, 0, /* |
2843 Specify that the displayable area of frame FRAME is HEIGHT pixels tall. | |
2844 Optional third arg non-nil means that redisplay should be HEIGHT pixels tall | |
2845 but that the idea of the actual height of the frame should not be changed. | |
2846 */ | |
2847 (frame, height, pretend)) | |
2848 { | |
1318 | 2849 /* This can call Lisp. */ |
1125 | 2850 struct frame *f = decode_frame (frame); |
2851 int pheight, width; | |
2852 frame = wrap_frame (f); | |
2853 CHECK_INT (height); | |
2854 | |
2855 if (!window_system_pixelated_geometry (frame)) | |
2856 { | |
2857 int h = XINT (height); | |
2858 width = FRAME_WIDTH (f); | |
2859 frame_conversion_internal (f, DISPLAYABLE_PIXEL_TO_CHAR, 0, &h, 0, &pheight, 0); | |
2860 } | |
2861 else | |
2862 { | |
2863 width = FRAME_PIXWIDTH (f); | |
2864 pheight = XINT (height); | |
2865 } | |
2866 | |
2867 internal_set_frame_size (f, width, pheight, !NILP (pretend)); | |
2868 return frame; | |
2869 } | |
2870 | |
2871 | |
428 | 2872 DEFUN ("set-frame-width", Fset_frame_width, 2, 3, 0, /* |
2873 Specify that the frame FRAME has COLS columns. | |
2874 Optional third arg non-nil means that redisplay should use COLS columns | |
2875 but that the idea of the actual width of the frame should not be changed. | |
2876 */ | |
2877 (frame, cols, pretend)) | |
2878 { | |
1318 | 2879 /* This can call Lisp. */ |
428 | 2880 struct frame *f = decode_frame (frame); |
2881 int width, height; | |
793 | 2882 frame = wrap_frame (f); |
428 | 2883 CHECK_INT (cols); |
2884 | |
2885 if (window_system_pixelated_geometry (frame)) | |
2886 { | |
2887 char_to_real_pixel_size (f, XINT (cols), 0, &width, 0); | |
2888 height = FRAME_PIXHEIGHT (f); | |
2889 } | |
2890 else | |
2891 { | |
2892 width = XINT (cols); | |
2893 height = FRAME_HEIGHT (f); | |
2894 } | |
2895 | |
2896 internal_set_frame_size (f, width, height, !NILP (pretend)); | |
2897 return frame; | |
2898 } | |
2899 | |
863 | 2900 DEFUN ("set-frame-pixel-width", Fset_frame_pixel_width, 2, 3, 0, /* |
1125 | 2901 Specify that the frame FRAME is a total of WIDTH pixels wide. |
863 | 2902 Optional third arg non-nil means that redisplay should be WIDTH wide |
2903 but that the idea of the actual height of the frame should not be changed. | |
2904 */ | |
2905 (frame, width, pretend)) | |
2906 { | |
1318 | 2907 /* This can call Lisp. */ |
863 | 2908 struct frame *f = decode_frame (frame); |
2909 int height, pwidth; | |
2910 frame = wrap_frame (f); | |
2911 CHECK_INT (width); | |
2912 | |
2913 if (!window_system_pixelated_geometry (frame)) | |
2914 { | |
2915 int w = XINT (width); | |
2916 height = FRAME_HEIGHT (f); | |
1125 | 2917 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, &w, 0, &pwidth, 0, 0); |
2918 } | |
2919 else | |
2920 { | |
2921 height = FRAME_PIXHEIGHT (f); | |
2922 pwidth = XINT (width); | |
2923 } | |
2924 | |
2925 internal_set_frame_size (f, pwidth, height, !NILP (pretend)); | |
2926 return frame; | |
2927 } | |
2928 | |
2929 DEFUN ("set-frame-displayable-pixel-width", Fset_frame_displayable_pixel_width, 2, 3, 0, /* | |
2930 Specify that the displayable area of frame FRAME is WIDTH pixels wide. | |
2931 Optional third arg non-nil means that redisplay should be WIDTH wide | |
2932 but that the idea of the actual height of the frame should not be changed. | |
2933 */ | |
2934 (frame, width, pretend)) | |
2935 { | |
1318 | 2936 /* This can call Lisp. */ |
1125 | 2937 struct frame *f = decode_frame (frame); |
2938 int height, pwidth; | |
2939 frame = wrap_frame (f); | |
2940 CHECK_INT (width); | |
2941 | |
2942 if (!window_system_pixelated_geometry (frame)) | |
2943 { | |
2944 int w = XINT (width); | |
2945 height = FRAME_HEIGHT (f); | |
2946 frame_conversion_internal (f, DISPLAYABLE_PIXEL_TO_CHAR, &w, 0, &pwidth, 0, 0); | |
863 | 2947 } |
2948 else | |
2949 { | |
2950 height = FRAME_PIXHEIGHT (f); | |
2951 pwidth = XINT (width); | |
2952 } | |
2953 | |
2954 internal_set_frame_size (f, pwidth, height, !NILP (pretend)); | |
2955 return frame; | |
2956 } | |
2957 | |
428 | 2958 DEFUN ("set-frame-size", Fset_frame_size, 3, 4, 0, /* |
444 | 2959 Set the size of FRAME to COLS by ROWS, measured in characters. |
428 | 2960 Optional fourth arg non-nil means that redisplay should use COLS by ROWS |
2961 but that the idea of the actual size of the frame should not be changed. | |
2962 */ | |
2963 (frame, cols, rows, pretend)) | |
2964 { | |
1318 | 2965 /* This can call Lisp. */ |
428 | 2966 struct frame *f = decode_frame (frame); |
2967 int height, width; | |
793 | 2968 frame = wrap_frame (f); |
428 | 2969 CHECK_INT (cols); |
2970 CHECK_INT (rows); | |
2971 | |
2972 if (window_system_pixelated_geometry (frame)) | |
2973 char_to_real_pixel_size (f, XINT (cols), XINT (rows), &width, &height); | |
2974 else | |
2975 { | |
2976 height = XINT (rows); | |
2977 width = XINT (cols); | |
2978 } | |
2979 | |
2980 internal_set_frame_size (f, width, height, !NILP (pretend)); | |
2981 return frame; | |
2982 } | |
2983 | |
863 | 2984 DEFUN ("set-frame-pixel-size", Fset_frame_pixel_size, 3, 4, 0, /* |
1125 | 2985 Set the total size of FRAME to WIDTH by HEIGHT, measured in pixels. |
863 | 2986 Optional fourth arg non-nil means that redisplay should use WIDTH by HEIGHT |
2987 but that the idea of the actual size of the frame should not be changed. | |
2988 */ | |
2989 (frame, width, height, pretend)) | |
2990 { | |
1318 | 2991 /* This can call Lisp. */ |
863 | 2992 struct frame *f = decode_frame (frame); |
2993 int pheight, pwidth; | |
2994 frame = wrap_frame (f); | |
2995 CHECK_INT (width); | |
2996 CHECK_INT (height); | |
2997 | |
2998 if (!window_system_pixelated_geometry (frame)) | |
2999 { | |
3000 int w = XINT (width); | |
3001 int h = XINT (height); | |
1125 | 3002 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, &w, &h, &pwidth, &pheight, 0); |
3003 } | |
3004 else | |
3005 { | |
3006 pheight = XINT (height); | |
3007 pwidth = XINT (width); | |
3008 } | |
3009 | |
3010 internal_set_frame_size (f, pwidth, pheight, !NILP (pretend)); | |
3011 return frame; | |
3012 } | |
3013 | |
3014 DEFUN ("set-frame-displayable-pixel-size", Fset_frame_displayable_pixel_size, 3, 4, 0, /* | |
3015 Set the displayable size of FRAME to WIDTH by HEIGHT, measured in pixels. | |
3016 Optional fourth arg non-nil means that redisplay should use WIDTH by HEIGHT | |
3017 but that the idea of the actual size of the frame should not be changed. | |
3018 */ | |
3019 (frame, width, height, pretend)) | |
3020 { | |
1318 | 3021 /* This can call Lisp. */ |
1125 | 3022 struct frame *f = decode_frame (frame); |
3023 int pheight, pwidth; | |
3024 frame = wrap_frame (f); | |
3025 CHECK_INT (width); | |
3026 CHECK_INT (height); | |
3027 | |
3028 if (!window_system_pixelated_geometry (frame)) | |
3029 { | |
3030 int w = XINT (width); | |
3031 int h = XINT (height); | |
3032 frame_conversion_internal (f, DISPLAYABLE_PIXEL_TO_CHAR, &w, &h, &pwidth, &pheight, 0); | |
863 | 3033 } |
3034 else | |
3035 { | |
3036 pheight = XINT (height); | |
3037 pwidth = XINT (width); | |
3038 } | |
3039 | |
3040 internal_set_frame_size (f, pwidth, pheight, !NILP (pretend)); | |
3041 return frame; | |
3042 } | |
3043 | |
428 | 3044 DEFUN ("set-frame-position", Fset_frame_position, 3, 3, 0, /* |
3045 Set position of FRAME in pixels to XOFFSET by YOFFSET. | |
3046 This is actually the position of the upper left corner of the frame. | |
3047 Negative values for XOFFSET or YOFFSET are interpreted relative to | |
3048 the rightmost or bottommost possible position (that stays within the screen). | |
3049 */ | |
3050 (frame, xoffset, yoffset)) | |
3051 { | |
3052 struct frame *f = decode_frame (frame); | |
3053 CHECK_INT (xoffset); | |
3054 CHECK_INT (yoffset); | |
3055 | |
3056 MAYBE_FRAMEMETH (f, set_frame_position, (f, XINT (xoffset), XINT (yoffset))); | |
3057 | |
3058 return Qt; | |
3059 } | |
3060 | |
3061 | |
3062 | |
3063 /* Frame size conversion functions moved here from EmacsFrame.c | |
3064 because they're generic and really don't belong in that file. | |
3065 Function get_default_char_pixel_size() removed because it's | |
3066 exactly the same as default_face_height_and_width(). */ | |
3067 static void | |
1125 | 3068 frame_conversion_internal (struct frame *f, |
3069 pixel_to_char_mode_t pixel_to_char, | |
428 | 3070 int *pixel_width, int *pixel_height, |
3071 int *char_width, int *char_height, | |
3072 int real_face) | |
3073 { | |
3074 int cpw; | |
3075 int cph; | |
3076 int egw; | |
3077 int obw, obh, bdr; | |
3078 Lisp_Object frame, window; | |
3079 | |
793 | 3080 frame = wrap_frame (f); |
428 | 3081 if (real_face) |
3082 default_face_height_and_width (frame, &cph, &cpw); | |
3083 else | |
3084 default_face_height_and_width_1 (frame, &cph, &cpw); | |
3085 | |
3086 window = FRAME_SELECTED_WINDOW (f); | |
3087 | |
438 | 3088 egw = max (glyph_width (Vcontinuation_glyph, window), |
3089 glyph_width (Vtruncation_glyph, window)); | |
428 | 3090 egw = max (egw, cpw); |
3091 bdr = 2 * f->internal_border_width; | |
3092 obw = FRAME_SCROLLBAR_WIDTH (f) + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) + | |
3093 FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) + | |
3094 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) + | |
3095 2 * FRAME_THEORETICAL_RIGHT_TOOLBAR_BORDER_WIDTH (f); | |
3096 obh = FRAME_SCROLLBAR_HEIGHT (f) + FRAME_THEORETICAL_TOP_TOOLBAR_HEIGHT (f) + | |
3097 FRAME_THEORETICAL_BOTTOM_TOOLBAR_HEIGHT (f) + | |
3098 2 * FRAME_THEORETICAL_TOP_TOOLBAR_BORDER_WIDTH (f) + | |
3099 2 * FRAME_THEORETICAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f); | |
3100 | |
863 | 3101 /* Convert to chars so that the displayable area is pixel_width x |
3102 pixel_height. | |
3103 | |
3104 #### Consider rounding up to 0.5 characters to avoid adding too | |
3105 much space. */ | |
1125 | 3106 switch (pixel_to_char) |
863 | 3107 { |
1125 | 3108 case DISPLAYABLE_PIXEL_TO_CHAR: |
863 | 3109 if (char_width) |
3110 *char_width = ROUND_UP (*pixel_width, cpw) / cpw; | |
3111 if (char_height) | |
3112 *char_height = ROUND_UP (*pixel_height, cph) / cph; | |
1125 | 3113 break; |
3114 case TOTAL_PIXEL_TO_CHAR: | |
3115 /* Convert to chars so that the total frame size is pixel_width x | |
3116 pixel_height. */ | |
428 | 3117 if (char_width) |
3118 *char_width = 1 + ((*pixel_width - egw) - bdr - obw) / cpw; | |
3119 if (char_height) | |
3120 *char_height = (*pixel_height - bdr - obh) / cph; | |
1125 | 3121 break; |
3122 case CHAR_TO_TOTAL_PIXEL: | |
428 | 3123 if (pixel_width) |
3124 *pixel_width = (*char_width - 1) * cpw + egw + bdr + obw; | |
3125 if (pixel_height) | |
3126 *pixel_height = *char_height * cph + bdr + obh; | |
1125 | 3127 break; |
3128 case CHAR_TO_DISPLAYABLE_PIXEL: | |
3129 if (pixel_width) | |
3130 *pixel_width = *char_width * cpw; | |
3131 if (pixel_height) | |
3132 *pixel_height = *char_height * cph; | |
3133 break; | |
428 | 3134 } |
3135 } | |
3136 | |
3137 /* This takes the size in pixels of the text area, and returns the number | |
3138 of characters that will fit there, taking into account the internal | |
3139 border width, and the pixel width of the line terminator glyphs (which | |
3140 always count as one "character" wide, even if they are not the same size | |
3141 as the default character size of the default font). The frame scrollbar | |
3142 width and left and right toolbar widths are also subtracted out of the | |
3143 available width. The frame scrollbar height and top and bottom toolbar | |
3144 heights are subtracted out of the available height. | |
3145 | |
3146 Therefore the result is not necessarily a multiple of anything in | |
3147 particular. */ | |
3148 void | |
3149 pixel_to_char_size (struct frame *f, int pixel_width, int pixel_height, | |
3150 int *char_width, int *char_height) | |
3151 { | |
1125 | 3152 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, |
3153 &pixel_width, &pixel_height, char_width, | |
428 | 3154 char_height, 0); |
3155 } | |
3156 | |
3157 /* Given a character size, this returns the minimum number of pixels | |
3158 necessary to display that many characters, taking into account the | |
3159 internal border width, scrollbar height and width, toolbar heights and | |
3160 widths and the size of the line terminator glyphs (assuming the line | |
3161 terminators take up exactly one character position). | |
3162 | |
3163 Therefore the result is not necessarily a multiple of anything in | |
3164 particular. */ | |
3165 void | |
3166 char_to_pixel_size (struct frame *f, int char_width, int char_height, | |
3167 int *pixel_width, int *pixel_height) | |
3168 { | |
1125 | 3169 frame_conversion_internal (f, CHAR_TO_TOTAL_PIXEL, |
3170 pixel_width, pixel_height, &char_width, | |
428 | 3171 &char_height, 0); |
3172 } | |
3173 | |
3174 /* Given a pixel size, rounds DOWN to the smallest size in pixels necessary | |
3175 to display the same number of characters as are displayable now. | |
3176 */ | |
3177 void | |
3178 round_size_to_char (struct frame *f, int in_width, int in_height, | |
3179 int *out_width, int *out_height) | |
3180 { | |
3181 int char_width; | |
3182 int char_height; | |
3183 pixel_to_char_size (f, in_width, in_height, &char_width, &char_height); | |
3184 char_to_pixel_size (f, char_width, char_height, out_width, out_height); | |
3185 } | |
3186 | |
3187 /* Versions of the above which always account for real font metrics. | |
3188 */ | |
3189 void | |
3190 pixel_to_real_char_size (struct frame *f, int pixel_width, int pixel_height, | |
3191 int *char_width, int *char_height) | |
3192 { | |
1125 | 3193 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, |
3194 &pixel_width, &pixel_height, char_width, | |
428 | 3195 char_height, 1); |
3196 } | |
3197 | |
3198 void | |
3199 char_to_real_pixel_size (struct frame *f, int char_width, int char_height, | |
3200 int *pixel_width, int *pixel_height) | |
3201 { | |
1125 | 3202 frame_conversion_internal (f, CHAR_TO_TOTAL_PIXEL, |
3203 pixel_width, pixel_height, &char_width, | |
428 | 3204 &char_height, 1); |
3205 } | |
3206 | |
3207 void | |
3208 round_size_to_real_char (struct frame *f, int in_width, int in_height, | |
3209 int *out_width, int *out_height) | |
3210 { | |
3211 int char_width; | |
3212 int char_height; | |
3213 pixel_to_real_char_size (f, in_width, in_height, &char_width, &char_height); | |
3214 char_to_real_pixel_size (f, char_width, char_height, out_width, out_height); | |
3215 } | |
3216 | |
3217 /* Change the frame height and/or width. Values may be given as zero to | |
3218 indicate no change is to take place. */ | |
3219 static void | |
3220 change_frame_size_1 (struct frame *f, int newheight, int newwidth) | |
3221 { | |
3222 Lisp_Object frame; | |
3223 int new_pixheight, new_pixwidth; | |
3224 int font_height, real_font_height, font_width; | |
3225 | |
3226 /* #### Chuck -- shouldn't we be checking to see if the frame | |
3227 is being "changed" to its existing size, and do nothing if so? */ | |
3228 /* No, because it would hose toolbar updates. The toolbar | |
3229 update code relies on this function to cause window `top' and | |
3230 `left' coordinates to be recomputed even though no frame size | |
3231 change occurs. --kyle */ | |
1318 | 3232 if (in_display || hold_frame_size_changes) |
2500 | 3233 ABORT (); |
428 | 3234 |
793 | 3235 frame = wrap_frame (f); |
428 | 3236 |
3237 default_face_height_and_width (frame, &real_font_height, 0); | |
3238 default_face_height_and_width_1 (frame, &font_height, &font_width); | |
3239 | |
3240 /* This size-change overrides any pending one for this frame. */ | |
3241 FRAME_NEW_HEIGHT (f) = 0; | |
3242 FRAME_NEW_WIDTH (f) = 0; | |
3243 | |
3244 new_pixheight = newheight * font_height; | |
3245 new_pixwidth = (newwidth - 1) * font_width; | |
3246 | |
3247 /* #### dependency on FRAME_WIN_P should be removed. */ | |
3248 if (FRAME_WIN_P (f)) | |
3249 { | |
3250 new_pixheight += FRAME_SCROLLBAR_HEIGHT (f); | |
3251 new_pixwidth += FRAME_SCROLLBAR_WIDTH (f); | |
3252 } | |
3253 | |
3254 /* when frame_conversion_internal() calculated the number of rows/cols | |
3255 in the frame, the theoretical toolbar sizes were subtracted out. | |
3256 The calculations below adjust for real toolbar height/width in | |
3257 frame, which may be different from frame spec, taking the above | |
3258 fact into account */ | |
3259 new_pixheight += | |
3260 + FRAME_THEORETICAL_TOP_TOOLBAR_HEIGHT (f) | |
3261 + 2 * FRAME_THEORETICAL_TOP_TOOLBAR_BORDER_WIDTH (f) | |
3262 - FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) | |
3263 - 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f); | |
3264 | |
3265 new_pixheight += | |
3266 + FRAME_THEORETICAL_BOTTOM_TOOLBAR_HEIGHT (f) | |
3267 + 2 * FRAME_THEORETICAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f) | |
3268 - FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) | |
3269 - 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f); | |
3270 | |
3271 new_pixwidth += | |
3272 + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) | |
3273 + 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) | |
3274 - FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) | |
3275 - 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f); | |
3276 | |
3277 new_pixwidth += | |
3278 + FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) | |
3279 + 2 * FRAME_THEORETICAL_RIGHT_TOOLBAR_BORDER_WIDTH (f) | |
3280 - FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) | |
3281 - 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f); | |
3282 | |
3283 /* Adjust the width for the end glyph which may be a different width | |
3284 than the default character width. */ | |
3285 { | |
3286 int adjustment, trunc_width, cont_width; | |
3287 | |
440 | 3288 trunc_width = glyph_width (Vtruncation_glyph, |
428 | 3289 FRAME_SELECTED_WINDOW (f)); |
440 | 3290 cont_width = glyph_width (Vcontinuation_glyph, |
428 | 3291 FRAME_SELECTED_WINDOW (f)); |
3292 adjustment = max (trunc_width, cont_width); | |
3293 adjustment = max (adjustment, font_width); | |
3294 | |
3295 new_pixwidth += adjustment; | |
3296 } | |
3297 | |
3298 /* If we don't have valid values, exit. */ | |
3299 if (!new_pixheight && !new_pixwidth) | |
3300 return; | |
3301 | |
3302 if (new_pixheight) | |
3303 { | |
442 | 3304 /* Adjust for gutters here so that we always get set |
3305 properly. */ | |
3306 new_pixheight -= | |
3307 (FRAME_TOP_GUTTER_BOUNDS (f) | |
3308 + FRAME_BOTTOM_GUTTER_BOUNDS (f)); | |
3309 | |
3310 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top | |
3311 = FRAME_TOP_BORDER_END (f) + FRAME_TOP_GUTTER_BOUNDS (f); | |
428 | 3312 |
3313 if (FRAME_HAS_MINIBUF_P (f) | |
3314 && ! FRAME_MINIBUF_ONLY_P (f)) | |
3315 /* Frame has both root and minibuffer. */ | |
3316 { | |
3317 /* | |
3318 * Leave the minibuffer height the same if the frame has | |
3319 * been initialized, and the minibuffer height is tall | |
3320 * enough to display at least one line of text in the default | |
3321 * font, and the old minibuffer height is a multiple of the | |
3322 * default font height. This should cause the minibuffer | |
3323 * height to be recomputed on font changes but not for | |
3324 * other frame size changes, which seems reasonable. | |
3325 */ | |
3326 int old_minibuf_height = | |
3327 XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_height; | |
3328 int minibuf_height = | |
3329 f->init_finished && (old_minibuf_height % real_font_height) == 0 ? | |
3330 max(old_minibuf_height, real_font_height) : | |
3331 real_font_height; | |
3332 set_window_pixheight (FRAME_ROOT_WINDOW (f), | |
3333 /* - font_height for minibuffer */ | |
3334 new_pixheight - minibuf_height, 0); | |
3335 | |
3336 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top = | |
442 | 3337 FRAME_TOP_BORDER_END (f) + |
3338 FRAME_TOP_GUTTER_BOUNDS (f) + | |
3339 FRAME_BOTTOM_GUTTER_BOUNDS (f) + | |
3340 new_pixheight - minibuf_height; | |
428 | 3341 |
3342 set_window_pixheight (FRAME_MINIBUF_WINDOW (f), minibuf_height, 0); | |
3343 } | |
3344 else | |
3345 /* Frame has just one top-level window. */ | |
3346 set_window_pixheight (FRAME_ROOT_WINDOW (f), new_pixheight, 0); | |
3347 | |
3348 FRAME_HEIGHT (f) = newheight; | |
3349 if (FRAME_TTY_P (f)) | |
3350 f->pixheight = newheight; | |
3351 } | |
3352 | |
3353 if (new_pixwidth) | |
3354 { | |
442 | 3355 /* Adjust for gutters here so that we always get set |
3356 properly. */ | |
3357 new_pixwidth -= | |
3358 (FRAME_LEFT_GUTTER_BOUNDS (f) | |
3359 + FRAME_RIGHT_GUTTER_BOUNDS (f)); | |
3360 | |
3361 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left = | |
3362 FRAME_LEFT_BORDER_END (f) + FRAME_LEFT_GUTTER_BOUNDS (f); | |
428 | 3363 set_window_pixwidth (FRAME_ROOT_WINDOW (f), new_pixwidth, 0); |
3364 | |
3365 if (FRAME_HAS_MINIBUF_P (f)) | |
3366 { | |
3367 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_left = | |
442 | 3368 FRAME_LEFT_BORDER_END (f) + FRAME_LEFT_GUTTER_BOUNDS (f); |
428 | 3369 set_window_pixwidth (FRAME_MINIBUF_WINDOW (f), new_pixwidth, 0); |
3370 } | |
3371 | |
3372 FRAME_WIDTH (f) = newwidth; | |
3373 if (FRAME_TTY_P (f)) | |
3374 f->pixwidth = newwidth; | |
3375 } | |
3376 | |
3377 if (window_system_pixelated_geometry (frame)) | |
3378 pixel_to_real_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | |
3379 &FRAME_CHARWIDTH (f), &FRAME_CHARHEIGHT (f)); | |
3380 else | |
3381 { | |
3382 FRAME_CHARWIDTH (f) = FRAME_WIDTH (f); | |
3383 FRAME_CHARHEIGHT (f) = FRAME_HEIGHT (f); | |
3384 } | |
3385 | |
3386 MARK_FRAME_TOOLBARS_CHANGED (f); | |
442 | 3387 MARK_FRAME_GUTTERS_CHANGED (f); |
428 | 3388 MARK_FRAME_CHANGED (f); |
3389 f->echo_area_garbaged = 1; | |
3390 } | |
3391 | |
3392 void | |
3393 change_frame_size (struct frame *f, int newheight, int newwidth, int delay) | |
3394 { | |
3395 /* sometimes we get passed a size that's too small (esp. when a | |
3396 client widget gets resized, since we have no control over this). | |
3397 So deal. */ | |
3398 check_frame_size (f, &newheight, &newwidth); | |
3399 | |
450 | 3400 /* Unconditionally mark that the frame has changed size. This is |
3401 because many things need to know after the | |
3402 fact. f->size_change_pending will get reset below. The most that | |
3403 can happen is that we will cycle through redisplay once more | |
3404 --andy. */ | |
3405 MARK_FRAME_SIZE_CHANGED (f); | |
3406 | |
1318 | 3407 if (delay || hold_frame_size_changes || gc_in_progress) |
428 | 3408 { |
3409 f->new_width = newwidth; | |
3410 f->new_height = newheight; | |
3411 return; | |
3412 } | |
3413 | |
3414 f->size_change_pending = 0; | |
3415 /* For TTY frames, it's like one, like all ... | |
3416 Can't have two TTY frames of different sizes on the same device. */ | |
3417 if (FRAME_TTY_P (f)) | |
3418 { | |
3419 Lisp_Object frmcons; | |
3420 | |
3421 DEVICE_FRAME_LOOP (frmcons, XDEVICE (FRAME_DEVICE (f))) | |
3422 change_frame_size_1 (XFRAME (XCAR (frmcons)), newheight, newwidth); | |
3423 } | |
3424 else | |
3425 change_frame_size_1 (f, newheight, newwidth); | |
3426 } | |
3427 | |
3428 | |
438 | 3429 /* The caller is responsible for freeing the returned string. */ |
867 | 3430 static Ibyte * |
438 | 3431 generate_title_string (struct window *w, Lisp_Object format_str, |
3432 face_index findex, int type) | |
3433 { | |
3434 struct display_line *dl; | |
3435 struct display_block *db; | |
3436 int elt = 0; | |
3437 | |
3438 dl = &title_string_display_line; | |
3439 db = get_display_block_from_line (dl, TEXT); | |
3440 Dynarr_reset (db->runes); | |
3441 | |
3442 generate_formatted_string_db (format_str, Qnil, w, dl, db, findex, 0, | |
3443 -1, type); | |
3444 | |
867 | 3445 Dynarr_reset (title_string_ichar_dynarr); |
438 | 3446 while (elt < Dynarr_length (db->runes)) |
3447 { | |
3448 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) | |
867 | 3449 Dynarr_add (title_string_ichar_dynarr, |
438 | 3450 Dynarr_atp (db->runes, elt)->object.chr.ch); |
3451 elt++; | |
3452 } | |
3453 | |
3454 return | |
867 | 3455 convert_ichar_string_into_malloced_string |
3456 (Dynarr_atp (title_string_ichar_dynarr, 0), | |
3457 Dynarr_length (title_string_ichar_dynarr), 0); | |
438 | 3458 } |
3459 | |
428 | 3460 void |
3461 update_frame_title (struct frame *f) | |
3462 { | |
3463 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); | |
3464 Lisp_Object title_format; | |
3465 Lisp_Object icon_format; | |
867 | 3466 Ibyte *title; |
428 | 3467 |
3468 /* We don't change the title for the minibuffer unless the frame | |
3469 only has a minibuffer. */ | |
3470 if (MINI_WINDOW_P (w) && !FRAME_MINIBUF_ONLY_P (f)) | |
3471 return; | |
3472 | |
3473 /* And we don't want dead buffers to blow up on us. */ | |
3474 if (!BUFFER_LIVE_P (XBUFFER (w->buffer))) | |
3475 return; | |
3476 | |
3477 title = NULL; | |
3478 title_format = symbol_value_in_buffer (Qframe_title_format, w->buffer); | |
3479 icon_format = symbol_value_in_buffer (Qframe_icon_title_format, w->buffer); | |
3480 | |
867 | 3481 if (HAS_FRAMEMETH_P (f, set_title_from_ibyte)) |
428 | 3482 { |
438 | 3483 title = generate_title_string (w, title_format, |
3484 DEFAULT_INDEX, CURRENT_DISP); | |
867 | 3485 FRAMEMETH (f, set_title_from_ibyte, (f, title)); |
428 | 3486 } |
3487 | |
867 | 3488 if (HAS_FRAMEMETH_P (f, set_icon_name_from_ibyte)) |
428 | 3489 { |
3490 if (!EQ (icon_format, title_format) || !title) | |
3491 { | |
3492 if (title) | |
1726 | 3493 xfree (title, Ibyte *); |
428 | 3494 |
438 | 3495 title = generate_title_string (w, icon_format, |
3496 DEFAULT_INDEX, CURRENT_DISP); | |
428 | 3497 } |
867 | 3498 FRAMEMETH (f, set_icon_name_from_ibyte, (f, title)); |
428 | 3499 } |
3500 | |
3501 if (title) | |
1726 | 3502 xfree (title, Ibyte *); |
428 | 3503 } |
3504 | |
3505 | |
3506 DEFUN ("set-frame-pointer", Fset_frame_pointer, 2, 2, 0, /* | |
3507 Set the mouse pointer of FRAME to the given pointer image instance. | |
3508 You should not call this function directly. Instead, set one of | |
3509 the variables `text-pointer-glyph', `nontext-pointer-glyph', | |
3510 `modeline-pointer-glyph', `selection-pointer-glyph', | |
3511 `busy-pointer-glyph', or `toolbar-pointer-glyph'. | |
3512 */ | |
3513 (frame, image_instance)) | |
3514 { | |
3515 struct frame *f = decode_frame (frame); | |
3516 CHECK_POINTER_IMAGE_INSTANCE (image_instance); | |
3517 if (!EQ (f->pointer, image_instance)) | |
3518 { | |
3519 f->pointer = image_instance; | |
3520 MAYBE_FRAMEMETH (f, set_frame_pointer, (f)); | |
3521 } | |
3522 return Qnil; | |
3523 } | |
3524 | |
3525 | |
3526 void | |
3527 update_frame_icon (struct frame *f) | |
3528 { | |
3529 if (f->icon_changed || f->windows_changed) | |
3530 { | |
3531 Lisp_Object frame; | |
3532 Lisp_Object new_icon; | |
3533 | |
793 | 3534 frame = wrap_frame (f); |
428 | 3535 new_icon = glyph_image_instance (Vframe_icon_glyph, frame, |
3536 ERROR_ME_WARN, 0); | |
3537 if (!EQ (new_icon, f->icon)) | |
3538 { | |
3539 f->icon = new_icon; | |
3540 MAYBE_FRAMEMETH (f, set_frame_icon, (f)); | |
3541 } | |
3542 } | |
3543 | |
3544 f->icon_changed = 0; | |
3545 } | |
3546 | |
3547 static void | |
2286 | 3548 icon_glyph_changed (Lisp_Object UNUSED (glyph), Lisp_Object UNUSED (property), |
3549 Lisp_Object UNUSED (locale)) | |
428 | 3550 { |
3551 MARK_ICON_CHANGED; | |
3552 } | |
3553 | |
3554 | |
438 | 3555 /***************************************************************************/ |
3556 /* */ | |
3557 /* initialization */ | |
3558 /* */ | |
3559 /***************************************************************************/ | |
3560 | |
3561 void | |
3562 init_frame (void) | |
3563 { | |
3564 #ifndef PDUMP | |
3565 if (!initialized) | |
3566 #endif | |
3567 { | |
867 | 3568 title_string_ichar_dynarr = Dynarr_new (Ichar); |
438 | 3569 xzero (title_string_display_line); |
3570 } | |
3571 } | |
3572 | |
428 | 3573 void |
3574 syms_of_frame (void) | |
3575 { | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
3576 INIT_LISP_OBJECT (frame); |
442 | 3577 |
563 | 3578 DEFSYMBOL (Qdelete_frame_hook); |
3579 DEFSYMBOL (Qselect_frame_hook); | |
3580 DEFSYMBOL (Qdeselect_frame_hook); | |
3581 DEFSYMBOL (Qcreate_frame_hook); | |
3582 DEFSYMBOL (Qcustom_initialize_frame); | |
3583 DEFSYMBOL (Qmouse_enter_frame_hook); | |
3584 DEFSYMBOL (Qmouse_leave_frame_hook); | |
3585 DEFSYMBOL (Qmap_frame_hook); | |
3586 DEFSYMBOL (Qunmap_frame_hook); | |
3587 | |
3588 DEFSYMBOL (Qframep); | |
3589 DEFSYMBOL (Qframe_live_p); | |
3590 DEFSYMBOL (Qdelete_frame); | |
3591 DEFSYMBOL (Qsynchronize_minibuffers); | |
3592 DEFSYMBOL (Qbuffer_predicate); | |
3593 DEFSYMBOL (Qframe_being_created); | |
3594 DEFSYMBOL (Qmake_initial_minibuffer_frame); | |
3595 | |
3596 DEFSYMBOL (Qframe_title_format); | |
3597 DEFSYMBOL (Qframe_icon_title_format); | |
3598 | |
3599 DEFSYMBOL (Qhidden); | |
3600 DEFSYMBOL (Qvisible); | |
3601 DEFSYMBOL (Qiconic); | |
3602 DEFSYMBOL (Qinvisible); | |
3603 DEFSYMBOL (Qvisible_iconic); | |
3604 DEFSYMBOL (Qinvisible_iconic); | |
3605 DEFSYMBOL (Qnomini); | |
3606 DEFSYMBOL (Qvisible_nomini); | |
3607 DEFSYMBOL (Qiconic_nomini); | |
3608 DEFSYMBOL (Qinvisible_nomini); | |
3609 DEFSYMBOL (Qvisible_iconic_nomini); | |
3610 DEFSYMBOL (Qinvisible_iconic_nomini); | |
3611 | |
3612 DEFSYMBOL (Qminibuffer); | |
3613 DEFSYMBOL (Qunsplittable); | |
3614 DEFSYMBOL (Qinternal_border_width); | |
3615 DEFSYMBOL (Qtop_toolbar_shadow_color); | |
3616 DEFSYMBOL (Qbottom_toolbar_shadow_color); | |
3617 DEFSYMBOL (Qbackground_toolbar_color); | |
3618 DEFSYMBOL (Qtop_toolbar_shadow_pixmap); | |
3619 DEFSYMBOL (Qbottom_toolbar_shadow_pixmap); | |
3620 DEFSYMBOL (Qtoolbar_shadow_thickness); | |
3621 DEFSYMBOL (Qscrollbar_placement); | |
3622 DEFSYMBOL (Qinter_line_space); | |
428 | 3623 /* Qiconic already in this function. */ |
563 | 3624 DEFSYMBOL (Qvisual_bell); |
3625 DEFSYMBOL (Qbell_volume); | |
3626 DEFSYMBOL (Qpointer_background); | |
3627 DEFSYMBOL (Qpointer_color); | |
3628 DEFSYMBOL (Qtext_pointer); | |
3629 DEFSYMBOL (Qspace_pointer); | |
3630 DEFSYMBOL (Qmodeline_pointer); | |
3631 DEFSYMBOL (Qgc_pointer); | |
3632 DEFSYMBOL (Qinitially_unmapped); | |
3633 DEFSYMBOL (Quse_backing_store); | |
3634 DEFSYMBOL (Qborder_color); | |
3635 DEFSYMBOL (Qborder_width); | |
428 | 3636 /* Qwidth, Qheight, Qleft, Qtop in general.c */ |
563 | 3637 DEFSYMBOL (Qset_specifier); |
3638 DEFSYMBOL (Qset_face_property); | |
3639 DEFSYMBOL (Qface_property_instance); | |
3640 DEFSYMBOL (Qframe_property_alias); | |
428 | 3641 |
3642 DEFSUBR (Fmake_frame); | |
3643 DEFSUBR (Fframep); | |
3644 DEFSUBR (Fframe_live_p); | |
3645 #if 0 /* FSFmacs */ | |
3646 DEFSUBR (Fignore_event); | |
3647 #endif | |
3648 DEFSUBR (Ffocus_frame); | |
3649 DEFSUBR (Fselect_frame); | |
3650 DEFSUBR (Fselected_frame); | |
3651 DEFSUBR (Factive_minibuffer_window); | |
3652 DEFSUBR (Flast_nonminibuf_frame); | |
3653 DEFSUBR (Fframe_root_window); | |
3654 DEFSUBR (Fframe_selected_window); | |
3655 DEFSUBR (Fset_frame_selected_window); | |
3656 DEFSUBR (Fframe_device); | |
3657 DEFSUBR (Fnext_frame); | |
3658 DEFSUBR (Fprevious_frame); | |
3659 DEFSUBR (Fdelete_frame); | |
3660 DEFSUBR (Fmouse_position); | |
3661 DEFSUBR (Fmouse_pixel_position); | |
3662 DEFSUBR (Fmouse_position_as_motion_event); | |
3663 DEFSUBR (Fset_mouse_position); | |
3664 DEFSUBR (Fset_mouse_pixel_position); | |
3665 DEFSUBR (Fmake_frame_visible); | |
3666 DEFSUBR (Fmake_frame_invisible); | |
3667 DEFSUBR (Ficonify_frame); | |
3668 DEFSUBR (Fdeiconify_frame); | |
3669 DEFSUBR (Fframe_visible_p); | |
3670 DEFSUBR (Fframe_totally_visible_p); | |
3671 DEFSUBR (Fframe_iconified_p); | |
3672 DEFSUBR (Fvisible_frame_list); | |
3673 DEFSUBR (Fraise_frame); | |
3674 DEFSUBR (Flower_frame); | |
442 | 3675 DEFSUBR (Fdisable_frame); |
3676 DEFSUBR (Fenable_frame); | |
428 | 3677 DEFSUBR (Fframe_property); |
3678 DEFSUBR (Fframe_properties); | |
3679 DEFSUBR (Fset_frame_properties); | |
3680 DEFSUBR (Fframe_pixel_height); | |
1125 | 3681 DEFSUBR (Fframe_displayable_pixel_height); |
428 | 3682 DEFSUBR (Fframe_pixel_width); |
1125 | 3683 DEFSUBR (Fframe_displayable_pixel_width); |
428 | 3684 DEFSUBR (Fframe_name); |
3685 DEFSUBR (Fframe_modified_tick); | |
3686 DEFSUBR (Fset_frame_height); | |
3687 DEFSUBR (Fset_frame_width); | |
3688 DEFSUBR (Fset_frame_size); | |
863 | 3689 DEFSUBR (Fset_frame_pixel_height); |
1125 | 3690 DEFSUBR (Fset_frame_displayable_pixel_height); |
863 | 3691 DEFSUBR (Fset_frame_pixel_width); |
1125 | 3692 DEFSUBR (Fset_frame_displayable_pixel_width); |
863 | 3693 DEFSUBR (Fset_frame_pixel_size); |
1125 | 3694 DEFSUBR (Fset_frame_displayable_pixel_size); |
428 | 3695 DEFSUBR (Fset_frame_position); |
3696 DEFSUBR (Fset_frame_pointer); | |
442 | 3697 DEFSUBR (Fprint_job_page_number); |
3698 DEFSUBR (Fprint_job_eject_page); | |
428 | 3699 } |
3700 | |
3701 void | |
3702 vars_of_frame (void) | |
3703 { | |
3704 /* */ | |
3705 Vframe_being_created = Qnil; | |
3706 staticpro (&Vframe_being_created); | |
3707 | |
3708 #ifdef HAVE_CDE | |
3709 Fprovide (intern ("cde")); | |
3710 #endif | |
3711 | |
3712 #ifdef HAVE_OFFIX_DND | |
3713 Fprovide (intern ("offix")); | |
3714 #endif | |
3715 | |
3716 #if 0 /* FSFmacs stupidity */ | |
3717 xxDEFVAR_LISP ("emacs-iconified", &Vemacs_iconified /* | |
3718 Non-nil if all of emacs is iconified and frame updates are not needed. | |
3719 */ ); | |
3720 Vemacs_iconified = Qnil; | |
3721 #endif | |
3722 | |
3723 DEFVAR_LISP ("select-frame-hook", &Vselect_frame_hook /* | |
3724 Function or functions to run just after a new frame is given the focus. | |
3725 Note that calling `select-frame' does not necessarily set the focus: | |
3726 The actual window-system focus will not be changed until the next time | |
3727 that XEmacs is waiting for an event, and even then, the window manager | |
3728 may refuse the focus-change request. | |
3729 */ ); | |
3730 Vselect_frame_hook = Qnil; | |
3731 | |
3732 DEFVAR_LISP ("deselect-frame-hook", &Vdeselect_frame_hook /* | |
3733 Function or functions to run just before a frame loses the focus. | |
3734 See `select-frame-hook'. | |
3735 */ ); | |
3736 Vdeselect_frame_hook = Qnil; | |
3737 | |
3738 DEFVAR_LISP ("delete-frame-hook", &Vdelete_frame_hook /* | |
3739 Function or functions to call when a frame is deleted. | |
3740 One argument, the about-to-be-deleted frame. | |
3741 */ ); | |
3742 Vdelete_frame_hook = Qnil; | |
3743 | |
3744 DEFVAR_LISP ("create-frame-hook", &Vcreate_frame_hook /* | |
3745 Function or functions to call when a frame is created. | |
3746 One argument, the newly-created frame. | |
3747 */ ); | |
3748 Vcreate_frame_hook = Qnil; | |
3749 | |
3750 DEFVAR_LISP ("mouse-enter-frame-hook", &Vmouse_enter_frame_hook /* | |
3751 Function or functions to call when the mouse enters a frame. | |
3752 One argument, the frame. | |
3753 Be careful not to make assumptions about the window manager's focus model. | |
3754 In most cases, the `deselect-frame-hook' is more appropriate. | |
3755 */ ); | |
3756 Vmouse_enter_frame_hook = Qnil; | |
3757 | |
3758 DEFVAR_LISP ("mouse-leave-frame-hook", &Vmouse_leave_frame_hook /* | |
3759 Function or functions to call when the mouse leaves a frame. | |
3760 One argument, the frame. | |
3761 Be careful not to make assumptions about the window manager's focus model. | |
3762 In most cases, the `select-frame-hook' is more appropriate. | |
3763 */ ); | |
3764 Vmouse_leave_frame_hook = Qnil; | |
3765 | |
3766 DEFVAR_LISP ("map-frame-hook", &Vmap_frame_hook /* | |
3767 Function or functions to call when a frame is mapped. | |
3768 One argument, the frame. | |
3769 */ ); | |
3770 Vmap_frame_hook = Qnil; | |
3771 | |
3772 DEFVAR_LISP ("unmap-frame-hook", &Vunmap_frame_hook /* | |
3773 Function or functions to call when a frame is unmapped. | |
3774 One argument, the frame. | |
3775 */ ); | |
3776 Vunmap_frame_hook = Qnil; | |
3777 | |
3778 DEFVAR_BOOL ("allow-deletion-of-last-visible-frame", | |
3779 &allow_deletion_of_last_visible_frame /* | |
3780 *Non-nil means to assume the force option to delete-frame. | |
3781 */ ); | |
3782 allow_deletion_of_last_visible_frame = 0; | |
3783 | |
3784 DEFVAR_LISP ("adjust-frame-function", &Vadjust_frame_function /* | |
3785 Function or constant controlling adjustment of frame. | |
3786 When scrollbars, toolbars, default font etc. change in frame, the frame | |
3787 needs to be adjusted. The adjustment is controlled by this variable. | |
3788 Legal values are: | |
3789 nil to keep character frame size unchanged when possible (resize) | |
3790 t to keep pixel size unchanged (never resize) | |
3791 function symbol or lambda form. This function must return boolean | |
3792 value which is treated as above. Function is passed one parameter, | |
3793 the frame being adjusted. It function should not modify or delete | |
3794 the frame. | |
3795 */ ); | |
3796 Vadjust_frame_function = Qnil; | |
3797 | |
3798 DEFVAR_LISP ("mouse-motion-handler", &Vmouse_motion_handler /* | |
3799 Handler for motion events. One arg, the event. | |
3800 For most applications, you should use `mode-motion-hook' instead of this. | |
3801 */ ); | |
3802 Vmouse_motion_handler = Qnil; | |
3803 | |
3804 DEFVAR_LISP ("synchronize-minibuffers",&Vsynchronize_minibuffers /* | |
3805 Set to t if all minibuffer windows are to be synchronized. | |
3806 This will cause echo area messages to appear in the minibuffers of all | |
3807 visible frames. | |
3808 */ ); | |
3809 Vsynchronize_minibuffers = Qnil; | |
3810 | |
3811 DEFVAR_LISP ("frame-title-format", &Vframe_title_format /* | |
442 | 3812 Controls the title of the window-system window of the selected frame. |
428 | 3813 This is the same format as `modeline-format' with the exception that |
3814 %- is ignored. | |
3815 */ ); | |
442 | 3816 /* #### I would change this unilaterally but for the wrath of the Kyles |
3817 of the world. */ | |
3818 #ifdef WIN32_NATIVE | |
3819 Vframe_title_format = build_string ("%b - XEmacs"); | |
3820 #else | |
428 | 3821 Vframe_title_format = build_string ("%S: %b"); |
442 | 3822 #endif |
428 | 3823 |
3824 DEFVAR_LISP ("frame-icon-title-format", &Vframe_icon_title_format /* | |
3825 Controls the title of the icon corresponding to the selected frame. | |
3826 See also the variable `frame-title-format'. | |
3827 */ ); | |
3828 Vframe_icon_title_format = build_string ("%b"); | |
3829 | |
3830 DEFVAR_LISP ("default-frame-name", &Vdefault_frame_name /* | |
3831 The default name to assign to newly-created frames. | |
442 | 3832 This can be overridden by arguments to `make-frame'. This must be a string. |
3833 This is used primarily for picking up X resources, and is *not* the title | |
3834 of the frame. (See `frame-title-format'.) | |
2681 | 3835 |
3836 Previous to 21.5.21, this defaulted to `emacs'; since that release, it has | |
3837 defaulted to `XEmacs'. In the short term you can restore the old default by | |
3838 setting the environment variable USE_EMACS_AS_DEFAULT_APPLICATION_CLASS | |
3839 (which does affect the frame name, despite what it's called) to some value | |
3840 before starting XEmacs, but this is deprecated. | |
428 | 3841 */ ); |
2681 | 3842 Vdefault_frame_name = Qnil; |
428 | 3843 |
3844 DEFVAR_LISP ("default-frame-plist", &Vdefault_frame_plist /* | |
3845 Plist of default values for frame creation, other than the first one. | |
3846 These may be set in your init file, like this: | |
3847 | |
3848 \(setq default-frame-plist '(width 80 height 55)) | |
3849 | |
2747 | 3850 Predefined properties are described in `set-frame-properties'. |
3851 | |
428 | 3852 The properties may be in alist format for backward compatibility |
3853 but you should not rely on this behavior. | |
3854 | |
3855 These override values given in window system configuration data, | |
2747 | 3856 including X Windows' defaults database. |
3857 | |
3858 Values for the first Emacs frame are taken from `initial-frame-plist'. | |
3859 Since the first X frame is created before loading your .emacs file, you | |
3860 may wish use the X resource database to avoid flashing. | |
3861 | |
428 | 3862 For values specific to the separate minibuffer frame, see |
2747 | 3863 `minibuffer-frame-plist'. See also the variables `default-x-frame-plist' |
3864 and `default-tty-frame-plist', which are like `default-frame-plist' | |
3865 except that they apply only to X or tty frames, respectively \(whereas | |
3866 `default-frame-plist' applies to all types of frames). | |
428 | 3867 */ ); |
3868 Vdefault_frame_plist = Qnil; | |
3869 | |
3870 DEFVAR_LISP ("frame-icon-glyph", &Vframe_icon_glyph /* | |
3871 Icon glyph used to iconify a frame. | |
3872 */ ); | |
3873 } | |
3874 | |
3875 void | |
3876 complex_vars_of_frame (void) | |
3877 { | |
3878 Vframe_icon_glyph = allocate_glyph (GLYPH_ICON, icon_glyph_changed); | |
3879 } |