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