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