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