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