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