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