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