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