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