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