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