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