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