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