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