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