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