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