Commit | Line | Data |
---|---|---|
ff11dfa1 | 1 | /* Define frame-object for GNU Emacs. |
1f922834 | 2 | Copyright (C) 1993, 1994, 1999, 2000, 2001 Free Software Foundation, Inc. |
efa4ce8b JB |
3 | |
4 | This file is part of GNU Emacs. | |
5 | ||
6 | GNU Emacs is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
e5d77022 | 8 | the Free Software Foundation; either version 2, or (at your option) |
efa4ce8b JB |
9 | any later version. |
10 | ||
11 | GNU Emacs is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Emacs; see the file COPYING. If not, write to | |
3b7ad313 EN |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
efa4ce8b | 20 | |
843c9999 GM |
21 | /* Don't multiply include: dispextern.h includes macterm.h which |
22 | includes frame.h some emacs source includes both dispextern.h and | |
23 | frame.h */ | |
24 | ||
84e01749 GM |
25 | #ifndef EMACS_FRAME_H |
26 | #define EMACS_FRAME_H | |
1f922834 | 27 | |
20a6c8d7 JB |
28 | \f |
29 | /* Miscellanea. */ | |
30 | ||
9628b887 | 31 | /* Nonzero means there is at least one garbaged frame. */ |
20a6c8d7 JB |
32 | extern int frame_garbaged; |
33 | ||
34 | /* Nonzero means FRAME_MESSAGE_BUF (selected_frame) is being used by | |
35 | print. */ | |
3b83d631 | 36 | |
20a6c8d7 | 37 | extern int message_buf_print; |
efa4ce8b | 38 | |
20a6c8d7 | 39 | \f |
e3678b64 | 40 | /* The structure representing a frame. */ |
efa4ce8b JB |
41 | |
42 | enum output_method | |
3b83d631 GM |
43 | { |
44 | output_termcap, | |
45 | output_x_window, | |
46 | output_msdos_raw, | |
0e015153 RS |
47 | output_w32, |
48 | output_mac | |
3b83d631 | 49 | }; |
efa4ce8b | 50 | |
a3211441 | 51 | enum vertical_scroll_bar_type |
3b83d631 GM |
52 | { |
53 | vertical_scroll_bar_none, | |
54 | vertical_scroll_bar_left, | |
55 | vertical_scroll_bar_right | |
56 | }; | |
a3211441 | 57 | |
4d418fcc KS |
58 | enum text_cursor_kinds |
59 | { | |
60 | DEFAULT_CURSOR = -2, | |
61 | NO_CURSOR = -1, | |
62 | FILLED_BOX_CURSOR, | |
63 | HOLLOW_BOX_CURSOR, | |
64 | BAR_CURSOR, | |
65 | HBAR_CURSOR | |
66 | }; | |
67 | ||
28d7d09f KL |
68 | #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel) |
69 | #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel) | |
2d764c78 | 70 | |
28d7d09f | 71 | struct device; |
2d764c78 | 72 | |
ff11dfa1 | 73 | struct frame |
efa4ce8b | 74 | { |
0c38c2f9 | 75 | EMACS_INT size; |
efa4ce8b JB |
76 | struct Lisp_Vector *next; |
77 | ||
21015f9c RS |
78 | /* All Lisp_Object components must come first. |
79 | Only EMACS_INT values can be intermixed with them. | |
80 | That ensures they are all aligned normally. */ | |
efa4ce8b | 81 | |
fa5d1baa RS |
82 | /* Name of this frame: a Lisp string. It is used for looking up resources, |
83 | as well as for the title in some cases. */ | |
efa4ce8b JB |
84 | Lisp_Object name; |
85 | ||
e7f79a67 RS |
86 | /* The name to use for the icon, the last time |
87 | it was refreshed. nil means not explicitly specified. */ | |
88 | Lisp_Object icon_name; | |
89 | ||
fa5d1baa RS |
90 | /* This is the frame title specified explicitly, if any. |
91 | Usually it is nil. */ | |
92 | Lisp_Object title; | |
93 | ||
eb8c3be9 | 94 | /* The frame which should receive keystrokes that occur in this |
46a5c487 JB |
95 | frame, or nil if they should go to the frame itself. This is |
96 | usually nil, but if the frame is minibufferless, we can use this | |
97 | to redirect keystrokes to a surrogate minibuffer frame when | |
98 | needed. | |
99 | ||
100 | Note that a value of nil is different than having the field point | |
101 | to the frame itself. Whenever the Fselect_frame function is used | |
102 | to shift from one frame to the other, any redirections to the | |
103 | original frame are shifted to the newly selected frame; if | |
104 | focus_frame is nil, Fselect_frame will leave it alone. */ | |
ff11dfa1 | 105 | Lisp_Object focus_frame; |
0f79a4ae | 106 | |
ff11dfa1 JB |
107 | /* This frame's root window. Every frame has one. |
108 | If the frame has only a minibuffer window, this is it. | |
109 | Otherwise, if the frame has a minibuffer window, this is its sibling. */ | |
efa4ce8b JB |
110 | Lisp_Object root_window; |
111 | ||
ff11dfa1 JB |
112 | /* This frame's selected window. |
113 | Each frame has its own window hierarchy | |
114 | and one of the windows in it is selected within the frame. | |
115 | The selected window of the selected frame is Emacs's selected window. */ | |
efa4ce8b JB |
116 | Lisp_Object selected_window; |
117 | ||
ff11dfa1 JB |
118 | /* This frame's minibuffer window. |
119 | Most frames have their own minibuffer windows, | |
120 | but only the selected frame's minibuffer window | |
efa4ce8b JB |
121 | can actually appear to exist. */ |
122 | Lisp_Object minibuffer_window; | |
123 | ||
ff11dfa1 JB |
124 | /* Parameter alist of this frame. |
125 | These are the parameters specified when creating the frame | |
126 | or modified with modify-frame-parameters. */ | |
efa4ce8b JB |
127 | Lisp_Object param_alist; |
128 | ||
177c0ea7 | 129 | /* List of scroll bars on this frame. |
20a6c8d7 | 130 | Actually, we don't specify exactly what is stored here at all; the |
a3c87d4e | 131 | scroll bar implementation code can use it to store anything it likes. |
20a6c8d7 JB |
132 | This field is marked by the garbage collector. It is here |
133 | instead of in the `display' structure so that the garbage | |
134 | collector doesn't need to look inside the window-system-dependent | |
135 | structure. */ | |
a3c87d4e JB |
136 | Lisp_Object scroll_bars; |
137 | Lisp_Object condemned_scroll_bars; | |
20a6c8d7 | 138 | |
ad6cd733 RS |
139 | /* Vector describing the items to display in the menu bar. |
140 | Each item has four elements in this vector. | |
141 | They are KEY, STRING, SUBMAP, and HPOS. | |
142 | (HPOS is not used in when the X toolkit is in use.) | |
143 | There are four additional elements of nil at the end, to terminate. */ | |
6d05db81 RS |
144 | Lisp_Object menu_bar_items; |
145 | ||
fb63ba7d RS |
146 | /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA). */ |
147 | Lisp_Object face_alist; | |
148 | ||
21015f9c RS |
149 | /* A vector that records the entire structure of this frame's menu bar. |
150 | For the format of the data, see extensive comments in xmenu.c. | |
151 | Only the X toolkit version uses this. */ | |
152 | Lisp_Object menu_bar_vector; | |
153 | /* Number of elements in the vector that have meaningful data. */ | |
154 | EMACS_INT menu_bar_items_used; | |
155 | ||
156 | /* Predicate for selecting buffers for other-buffer. */ | |
157 | Lisp_Object buffer_predicate; | |
158 | ||
375ff4f1 RS |
159 | /* List of buffers viewed in this frame, for other-buffer. */ |
160 | Lisp_Object buffer_list; | |
161 | ||
3b83d631 GM |
162 | /* A dummy window used to display menu bars under X when no X |
163 | toolkit support is available. */ | |
164 | Lisp_Object menu_bar_window; | |
165 | ||
9ea173e8 GM |
166 | /* A window used to display the tool-bar of a frame. */ |
167 | Lisp_Object tool_bar_window; | |
3b83d631 | 168 | |
9ea173e8 | 169 | /* Desired and current tool-bar items. */ |
e3303a23 | 170 | Lisp_Object tool_bar_items; |
3b83d631 | 171 | |
9ea173e8 GM |
172 | /* Desired and current contents displayed in tool_bar_window. */ |
173 | Lisp_Object desired_tool_bar_string, current_tool_bar_string; | |
3b83d631 | 174 | |
375ff4f1 | 175 | /* beyond here, there should be no more Lisp_Object components. */ |
21015f9c | 176 | |
3b83d631 GM |
177 | /* Cache of realized faces. */ |
178 | struct face_cache *face_cache; | |
21015f9c | 179 | |
3b83d631 GM |
180 | /* A buffer to hold the frame's name. We can't use the Lisp |
181 | string's pointer (`name', above) because it might get relocated. */ | |
bd601e2a KH |
182 | char *namebuf; |
183 | ||
3b83d631 GM |
184 | /* Glyph pool and matrix. */ |
185 | struct glyph_pool *current_pool; | |
186 | struct glyph_pool *desired_pool; | |
187 | struct glyph_matrix *desired_matrix; | |
188 | struct glyph_matrix *current_matrix; | |
189 | ||
190 | /* 1 means that glyphs on this frame have been initialized so it can | |
191 | be used for output. */ | |
192 | unsigned glyphs_initialized_p : 1; | |
21015f9c | 193 | |
488dd4c4 JD |
194 | #if defined (USE_GTK) |
195 | /* Nonzero means using a tool bar that comes from the toolkit. */ | |
196 | int external_tool_bar; | |
197 | #endif | |
198 | ||
9ea173e8 GM |
199 | /* Margin at the top of the frame. Used to display the tool-bar. */ |
200 | int tool_bar_lines; | |
3b83d631 | 201 | |
e3303a23 | 202 | int n_tool_bar_items; |
177c0ea7 | 203 | |
3b83d631 GM |
204 | /* A buffer for decode_mode_line. */ |
205 | char *decode_mode_spec_buffer; | |
21015f9c RS |
206 | |
207 | /* See do_line_insertion_deletion_costs for info on these arrays. */ | |
208 | /* Cost of inserting 1 line on this frame */ | |
209 | int *insert_line_cost; | |
210 | /* Cost of deleting 1 line on this frame */ | |
211 | int *delete_line_cost; | |
212 | /* Cost of inserting n lines on this frame */ | |
213 | int *insert_n_lines_cost; | |
214 | /* Cost of deleting n lines on this frame */ | |
215 | int *delete_n_lines_cost; | |
216 | ||
b45afe99 KS |
217 | /* Size of this frame, excluding fringes, scroll bars etc., |
218 | in units of canonical characters. */ | |
219 | EMACS_INT text_lines, text_cols; | |
220 | ||
221 | /* Total size of this frame (i.e. its native window), in units of | |
222 | canonical characters. */ | |
223 | EMACS_INT total_lines, total_cols; | |
224 | ||
225 | /* New text height and width for pending size change. | |
226 | 0 if no change pending. */ | |
227 | int new_text_lines, new_text_cols; | |
228 | ||
229 | /* Pixel position of the frame window (x and y offsets in root window). */ | |
230 | int left_pos, top_pos; | |
231 | ||
232 | /* Size of the frame window in pixels. */ | |
233 | int pixel_height, pixel_width; | |
234 | ||
235 | /* These many pixels are the difference between the outer window (i.e. the | |
236 | left and top of the window manager decoration) and FRAME_X_WINDOW. */ | |
237 | int x_pixels_diff, y_pixels_diff; | |
238 | ||
239 | /* This is the gravity value for the specified window position. */ | |
240 | int win_gravity; | |
241 | ||
242 | /* The geometry flags for this window. */ | |
243 | int size_hint_flags; | |
21015f9c | 244 | |
b45afe99 KS |
245 | /* Border width of the frame window as known by the (X) window system. */ |
246 | int border_width; | |
247 | ||
248 | /* Width of the internal border. This is a line of background color | |
249 | just inside the window's border. When the frame is selected, | |
250 | a highlighting is displayed inside the internal border. */ | |
251 | int internal_border_width; | |
252 | ||
253 | /* Canonical X unit. Width of default font, in pixels. */ | |
254 | int column_width; | |
255 | ||
256 | /* Canonical Y unit. Height of a line, in pixels. */ | |
257 | int line_height; | |
21015f9c | 258 | |
28d7d09f KL |
259 | /* The display hooks to use with this frame. */ |
260 | struct display *display; | |
261 | ||
ff11dfa1 | 262 | /* The output method says how the contents of this frame |
efa4ce8b JB |
263 | are displayed. It could be using termcap, or using an X window. */ |
264 | enum output_method output_method; | |
265 | ||
266 | /* A structure of auxiliary data used for displaying the contents. | |
28d7d09f | 267 | struct tty_output is used for termcap frames; |
28d440ab | 268 | it is defined in term.h. |
785ee691 | 269 | struct x_output is used for X window frames; |
177c0ea7 | 270 | it is defined in xterm.h. |
fbd6baed | 271 | struct w32_output is used for W32 window frames; |
efa7f0f9 | 272 | it is defined in w32term.h. */ |
3b83d631 GM |
273 | union output_data |
274 | { | |
28d440ab | 275 | struct tty_output *tty; |
3b83d631 GM |
276 | struct x_output *x; |
277 | struct w32_output *w32; | |
0e015153 | 278 | struct mac_output *mac; |
cf0fb540 | 279 | EMACS_INT nothing; |
3b83d631 GM |
280 | } |
281 | output_data; | |
efa4ce8b | 282 | |
b45afe99 KS |
283 | /* Total width of fringes reserved for drawing truncation bitmaps, |
284 | continuation bitmaps and alike. The width is in canonical char | |
285 | units of the frame. This must currently be the case because window | |
286 | sizes aren't pixel values. If it weren't the case, we wouldn't be | |
287 | able to split windows horizontally nicely. */ | |
288 | int fringe_cols; | |
289 | ||
290 | /* The extra width (in pixels) currently allotted for fringes. */ | |
291 | int left_fringe_width, right_fringe_width; | |
292 | ||
37ea66e1 KH |
293 | #ifdef MULTI_KBOARD |
294 | /* A pointer to the kboard structure associated with this frame. | |
295 | For termcap frames, this points to initial_kboard. For X frames, | |
296 | it will be the same as display.x->display_info->kboard. */ | |
fadab1e3 | 297 | struct kboard *kboard; |
37ea66e1 KH |
298 | #endif |
299 | ||
b45afe99 KS |
300 | /* See FULLSCREEN_ enum below */ |
301 | int want_fullscreen; | |
302 | ||
6d05db81 RS |
303 | /* Number of lines of menu bar. */ |
304 | int menu_bar_lines; | |
305 | ||
488dd4c4 JD |
306 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \ |
307 | || defined (USE_GTK) | |
9c95189b RS |
308 | /* Nonzero means using a menu bar that comes from the X toolkit. */ |
309 | int external_menu_bar; | |
310 | #endif | |
311 | ||
ff11dfa1 | 312 | /* Nonzero if last attempt at redisplay on this frame was preempted. */ |
efa4ce8b JB |
313 | char display_preempted; |
314 | ||
a4659527 JB |
315 | /* visible is nonzero if the frame is currently displayed; we check |
316 | it to see if we should bother updating the frame's contents. | |
46a5c487 | 317 | DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE. |
efa4ce8b | 318 | |
20a6c8d7 JB |
319 | Note that, since invisible frames aren't updated, whenever a |
320 | frame becomes visible again, it must be marked as garbaged. The | |
321 | FRAME_SAMPLE_VISIBILITY macro takes care of this. | |
322 | ||
6548cf00 KL |
323 | On ttys and on Windows NT/9X, to avoid wasting effort updating |
324 | visible frames that are actually completely obscured by other | |
325 | windows on the display, we bend the meaning of visible slightly: | |
326 | if greater than 1, then the frame is obscured - we still consider | |
327 | it to be "visible" as seen from lisp, but we don't bother | |
328 | updating it. We must take care to garbage the frame when it | |
329 | ceaces to be obscured though. | |
0969b893 | 330 | |
a4659527 JB |
331 | iconified is nonzero if the frame is currently iconified. |
332 | ||
333 | Asynchronous input handlers should NOT change these directly; | |
334 | instead, they should change async_visible or async_iconified, and | |
335 | let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified | |
336 | at the next redisplay. | |
337 | ||
338 | These should probably be considered read-only by everyone except | |
339 | FRAME_SAMPLE_VISIBILITY. | |
340 | ||
74cc2959 | 341 | These two are mutually exclusive. They might both be zero, if the |
a4659527 JB |
342 | frame has been made invisible without an icon. */ |
343 | char visible, iconified; | |
344 | ||
345 | /* Asynchronous input handlers change these, and | |
346 | FRAME_SAMPLE_VISIBILITY copies them into visible and iconified. | |
347 | See FRAME_SAMPLE_VISIBILITY, below. */ | |
b975254e | 348 | volatile char async_visible, async_iconified; |
efa4ce8b | 349 | |
ff11dfa1 | 350 | /* Nonzero if this frame should be redrawn. */ |
b975254e | 351 | volatile char garbaged; |
efa4ce8b | 352 | |
ff11dfa1 JB |
353 | /* True if frame actually has a minibuffer window on it. |
354 | 0 if using a minibuffer window that isn't on this frame. */ | |
efa4ce8b | 355 | char has_minibuffer; |
177c0ea7 | 356 | |
ff11dfa1 | 357 | /* 0 means, if this frame has just one window, |
efa4ce8b JB |
358 | show no modeline for that window. */ |
359 | char wants_modeline; | |
360 | ||
46a5c487 | 361 | /* Non-zero if the hardware device this frame is displaying on can |
a3c87d4e JB |
362 | support scroll bars. */ |
363 | char can_have_scroll_bars; | |
46a5c487 | 364 | |
a3c87d4e | 365 | /* If can_have_scroll_bars is non-zero, this is non-zero if we should |
46a5c487 | 366 | actually display them on this frame. */ |
a3211441 | 367 | enum vertical_scroll_bar_type vertical_scroll_bar_type; |
46a5c487 | 368 | |
4d418fcc KS |
369 | /* What kind of text cursor should we draw in the future? |
370 | This should always be filled_box_cursor or bar_cursor. */ | |
371 | enum text_cursor_kinds desired_cursor; | |
372 | ||
373 | /* Width of bar cursor (if we are using that). */ | |
374 | int cursor_width; | |
375 | ||
376 | /* What kind of text cursor should we draw when the cursor blinks off? | |
377 | This can be filled_box_cursor or bar_cursor or no_cursor. */ | |
378 | enum text_cursor_kinds blink_off_cursor; | |
379 | ||
380 | /* Width of bar cursor (if we are using that) for blink-off state. */ | |
381 | int blink_off_cursor_width; | |
382 | ||
ff11dfa1 | 383 | /* Non-0 means raise this frame to the top of the heap when selected. */ |
efa4ce8b JB |
384 | char auto_raise; |
385 | ||
ff11dfa1 | 386 | /* Non-0 means lower this frame to the bottom of the stack when left. */ |
efa4ce8b JB |
387 | char auto_lower; |
388 | ||
ff11dfa1 | 389 | /* True if frame's root window can't be split. */ |
efa4ce8b JB |
390 | char no_split; |
391 | ||
fbfed6f0 JB |
392 | /* If this is set, then Emacs won't change the frame name to indicate |
393 | the current buffer, etcetera. If the user explicitly sets the frame | |
394 | name, this gets set. If the user sets the name to Qnil, this is | |
395 | cleared. */ | |
396 | char explicit_name; | |
397 | ||
adc12f0f RS |
398 | /* Nonzero if size of some window on this frame has changed. */ |
399 | char window_sizes_changed; | |
400 | ||
ff11dfa1 | 401 | /* Storage for messages to this frame. */ |
efa4ce8b JB |
402 | char *message_buf; |
403 | ||
404 | /* Nonnegative if current redisplay should not do scroll computation | |
405 | for lines beyond a certain vpos. This is the vpos. */ | |
406 | int scroll_bottom_vpos; | |
8d6de7ce | 407 | |
b45afe99 KS |
408 | /* Configured width of the scroll bar, in pixels and in characters. |
409 | config_scroll_bar_cols tracks config_scroll_bar_width if the | |
410 | latter is positive; a zero value in config_scroll_bar_width means | |
411 | to compute the actual width on the fly, using config_scroll_bar_cols | |
412 | and the current font width. */ | |
413 | int config_scroll_bar_width; | |
414 | int config_scroll_bar_cols; | |
415 | ||
416 | /* The size of the extra width currently allotted for vertical | |
417 | scroll bars in this frame, in pixels. */ | |
418 | int scroll_bar_actual_width; | |
95b999aa RS |
419 | |
420 | /* The baud rate that was used to calculate costs for this frame. */ | |
421 | int cost_calculation_baud_rate; | |
6462918c KH |
422 | |
423 | /* Nonzero if the mouse has moved on this display | |
424 | since the last time we checked. */ | |
425 | char mouse_moved; | |
b61cbba3 GM |
426 | |
427 | /* Exponent for gamma correction of colors. 1/(VIEWING_GAMMA * | |
428 | SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a | |
429 | frame parameter. 0 means don't do gamma correction. */ | |
430 | double gamma; | |
d1738c45 GM |
431 | |
432 | /* Additional space to put between text lines on this frame. */ | |
433 | int extra_line_spacing; | |
f1c69c61 GM |
434 | |
435 | /* Set to non-zero in change_frame_size when size of frame changed | |
436 | Clear the frame in clear_garbaged_frames if set. */ | |
437 | unsigned resized_p : 1; | |
a5f696ac | 438 | |
28d7d09f KL |
439 | /* All display backends seem to need these two pixel values. */ |
440 | unsigned long background_pixel; | |
441 | unsigned long foreground_pixel; | |
442 | ||
a5f696ac JD |
443 | /* Set to non-zero if the default face for the frame has been |
444 | realized. Reset to zero whenever the default face changes. | |
445 | Used to see the difference between a font change and face change. */ | |
446 | unsigned default_face_done_p : 1; | |
efa4ce8b JB |
447 | }; |
448 | ||
e3678b64 | 449 | #ifdef MULTI_KBOARD |
37ea66e1 KH |
450 | #define FRAME_KBOARD(f) ((f)->kboard) |
451 | #else | |
452 | #define FRAME_KBOARD(f) (&the_only_kboard) | |
453 | #endif | |
454 | ||
ff11dfa1 JB |
455 | typedef struct frame *FRAME_PTR; |
456 | ||
8801a864 | 457 | #define XFRAME(p) (eassert (GC_FRAMEP(p)),(struct frame *) XPNTR (p)) |
aac03cca | 458 | #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME)) |
ff11dfa1 | 459 | |
cea6021b | 460 | /* Given a window, return its frame as a Lisp_Object. */ |
ff11dfa1 JB |
461 | #define WINDOW_FRAME(w) (w)->frame |
462 | ||
cea6021b RS |
463 | /* Test a frame for particular kinds of display methods. */ |
464 | #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap) | |
efa7f0f9 | 465 | #define FRAME_X_P(f) ((f)->output_method == output_x_window) |
fbd6baed | 466 | #define FRAME_W32_P(f) ((f)->output_method == output_w32) |
6f181713 | 467 | #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw) |
0e015153 | 468 | #define FRAME_MAC_P(f) ((f)->output_method == output_mac) |
efa7f0f9 GV |
469 | |
470 | /* FRAME_WINDOW_P tests whether the frame is a window, and is | |
471 | defined to be the predicate for the window system being used. */ | |
3b83d631 | 472 | |
efa7f0f9 GV |
473 | #ifdef HAVE_X_WINDOWS |
474 | #define FRAME_WINDOW_P(f) FRAME_X_P (f) | |
475 | #endif | |
476 | #ifdef HAVE_NTGUI | |
fbd6baed | 477 | #define FRAME_WINDOW_P(f) FRAME_W32_P (f) |
efa7f0f9 | 478 | #endif |
e0f712ba | 479 | #ifdef MAC_OS |
0e015153 RS |
480 | #define FRAME_WINDOW_P(f) FRAME_MAC_P (f) |
481 | #endif | |
7651b07e RS |
482 | #ifndef FRAME_WINDOW_P |
483 | #define FRAME_WINDOW_P(f) (0) | |
484 | #endif | |
efa7f0f9 | 485 | |
cea6021b | 486 | /* Nonzero if frame F is still alive (not deleted). */ |
785ee691 | 487 | #define FRAME_LIVE_P(f) ((f)->output_data.nothing != 0) |
cea6021b RS |
488 | |
489 | /* Nonzero if frame F is a minibuffer-only frame. */ | |
ff11dfa1 JB |
490 | #define FRAME_MINIBUF_ONLY_P(f) \ |
491 | EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f)) | |
cea6021b RS |
492 | |
493 | /* Nonzero if frame F contains a minibuffer window. | |
494 | (If this is 0, F must use some other minibuffer window.) */ | |
10a4cc63 | 495 | #define FRAME_HAS_MINIBUF_P(f) ((f)->has_minibuffer) |
cea6021b | 496 | |
b45afe99 KS |
497 | /* Pixel height of frame F, including non-toolkit menu bar and |
498 | non-toolkit tool bar lines. */ | |
499 | #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height) | |
500 | ||
501 | /* Pixel width of frame F. */ | |
502 | #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width) | |
503 | ||
504 | /* Height of frame F, measured in canonical lines, including | |
505 | non-toolkit menu bar and non-toolkit tool bar lines. */ | |
506 | #define FRAME_LINES(f) (f)->text_lines | |
507 | ||
508 | /* Width of frame F, measured in canonical character columns, | |
cea6021b | 509 | not including scroll bars if any. */ |
b45afe99 | 510 | #define FRAME_COLS(f) (f)->text_cols |
cea6021b RS |
511 | |
512 | /* Number of lines of frame F used for menu bar. | |
513 | This is relevant on terminal frames and on | |
514 | X Windows when not using the X toolkit. | |
b45afe99 | 515 | These lines are counted in FRAME_LINES. */ |
6d05db81 | 516 | #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines |
cea6021b | 517 | |
488dd4c4 JD |
518 | /* Nonzero if this frame should display a tool bar |
519 | in a way that does not use any text lines. */ | |
520 | #if defined (USE_GTK) | |
521 | #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar | |
522 | #else | |
523 | #define FRAME_EXTERNAL_TOOL_BAR(f) 0 | |
524 | #endif | |
525 | ||
9ea173e8 | 526 | /* Number of lines of frame F used for the tool-bar. */ |
3b83d631 | 527 | |
9ea173e8 | 528 | #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines |
3b83d631 | 529 | |
488dd4c4 | 530 | |
3b83d631 GM |
531 | /* Lines above the top-most window in frame F. */ |
532 | ||
533 | #define FRAME_TOP_MARGIN(F) \ | |
9ea173e8 | 534 | (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F)) |
3b83d631 | 535 | |
cea6021b RS |
536 | /* Nonzero if this frame should display a menu bar |
537 | in a way that does not use any text lines. */ | |
488dd4c4 JD |
538 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined (MAC_OS) \ |
539 | || defined (USE_GTK) | |
9c95189b | 540 | #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar |
4c8888a0 RS |
541 | #else |
542 | #define FRAME_EXTERNAL_MENU_BAR(f) 0 | |
543 | #endif | |
46a5c487 | 544 | #define FRAME_VISIBLE_P(f) ((f)->visible != 0) |
cea6021b RS |
545 | |
546 | /* Nonzero if frame F is currently visible but hidden. */ | |
0969b893 | 547 | #define FRAME_OBSCURED_P(f) ((f)->visible > 1) |
cea6021b RS |
548 | |
549 | /* Nonzero if frame F is currently iconified. */ | |
550 | #define FRAME_ICONIFIED_P(f) (f)->iconified | |
551 | ||
46a5c487 JB |
552 | #define FRAME_SET_VISIBLE(f,p) \ |
553 | ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f)) | |
ff11dfa1 JB |
554 | #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1) |
555 | #define FRAME_GARBAGED_P(f) (f)->garbaged | |
cea6021b RS |
556 | |
557 | /* Nonzero means do not allow splitting this frame's window. */ | |
ff11dfa1 | 558 | #define FRAME_NO_SPLIT_P(f) (f)->no_split |
cea6021b RS |
559 | |
560 | /* Not really implemented. */ | |
ff11dfa1 | 561 | #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline |
cea6021b RS |
562 | |
563 | /* Nonzero if a size change has been requested for frame F | |
564 | but not yet really put into effect. This can be true temporarily | |
565 | when an X event comes in at a bad time. */ | |
adc12f0f | 566 | #define FRAME_WINDOW_SIZES_CHANGED(f) (f)->window_sizes_changed |
cea6021b RS |
567 | |
568 | /* The minibuffer window of frame F, if it has one; otherwise nil. */ | |
ff11dfa1 | 569 | #define FRAME_MINIBUF_WINDOW(f) (f)->minibuffer_window |
cea6021b RS |
570 | |
571 | /* The root window of the window tree of frame F. */ | |
ff11dfa1 | 572 | #define FRAME_ROOT_WINDOW(f) (f)->root_window |
cea6021b RS |
573 | |
574 | /* The currently selected window of the window tree of frame F. */ | |
ff11dfa1 | 575 | #define FRAME_SELECTED_WINDOW(f) (f)->selected_window |
cea6021b | 576 | |
177c0ea7 JB |
577 | #define FRAME_INSERT_COST(f) (f)->insert_line_cost |
578 | #define FRAME_DELETE_COST(f) (f)->delete_line_cost | |
ff11dfa1 JB |
579 | #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost |
580 | #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost | |
581 | #define FRAME_MESSAGE_BUF(f) (f)->message_buf | |
582 | #define FRAME_SCROLL_BOTTOM_VPOS(f) (f)->scroll_bottom_vpos | |
583 | #define FRAME_FOCUS_FRAME(f) (f)->focus_frame | |
cea6021b RS |
584 | |
585 | /* Nonzero if frame F supports scroll bars. | |
586 | If this is zero, then it is impossible to enable scroll bars | |
587 | on frame F. */ | |
a3c87d4e | 588 | #define FRAME_CAN_HAVE_SCROLL_BARS(f) ((f)->can_have_scroll_bars) |
cea6021b RS |
589 | |
590 | /* This frame slot says whether scroll bars are currently enabled for frame F, | |
591 | and which side they are on. */ | |
a3211441 RS |
592 | #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type) |
593 | #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \ | |
594 | ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none) | |
595 | #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \ | |
596 | ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left) | |
597 | #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \ | |
598 | ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right) | |
cea6021b RS |
599 | |
600 | /* Width that a scroll bar in frame F should have, if there is one. | |
601 | Measured in pixels. | |
602 | If scroll bars are turned off, this is still nonzero. */ | |
b45afe99 | 603 | #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width) |
cea6021b RS |
604 | |
605 | /* Width that a scroll bar in frame F should have, if there is one. | |
606 | Measured in columns (characters). | |
607 | If scroll bars are turned off, this is still nonzero. */ | |
b45afe99 | 608 | #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols) |
cea6021b RS |
609 | |
610 | /* Width of a scroll bar in frame F, measured in columns (characters), | |
7d81cf83 GM |
611 | but only if scroll bars are on the left. If scroll bars are on |
612 | the right in this frame, or there are no scroll bars, value is 0. */ | |
613 | ||
b45afe99 | 614 | #define FRAME_LEFT_SCROLL_BAR_COLS(f) \ |
7d81cf83 | 615 | (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \ |
b45afe99 | 616 | ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \ |
7d81cf83 GM |
617 | : 0) |
618 | ||
b45afe99 KS |
619 | /* Width of a left scroll bar in frame F, measured in pixels */ |
620 | ||
621 | #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f) \ | |
622 | (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f) \ | |
623 | ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \ | |
624 | : 0) | |
625 | ||
7d81cf83 GM |
626 | /* Width of a scroll bar in frame F, measured in columns (characters), |
627 | but only if scroll bars are on the right. If scroll bars are on | |
628 | the left in this frame, or there are no scroll bars, value is 0. */ | |
629 | ||
b45afe99 | 630 | #define FRAME_RIGHT_SCROLL_BAR_COLS(f) \ |
7d81cf83 | 631 | (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \ |
b45afe99 | 632 | ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \ |
a3211441 | 633 | : 0) |
cea6021b | 634 | |
b45afe99 KS |
635 | /* Width of a right scroll bar area in frame F, measured in pixels */ |
636 | ||
637 | #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f) \ | |
638 | (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f) \ | |
639 | ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \ | |
640 | : 0) | |
641 | ||
642 | /* Actual width of a scroll bar in frame F, measured in columns. */ | |
643 | ||
644 | #define FRAME_SCROLL_BAR_COLS(f) \ | |
645 | (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \ | |
646 | ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \ | |
a3211441 | 647 | : 0) |
cea6021b | 648 | |
b45afe99 KS |
649 | /* Actual width of a scroll bar area in frame F, measured in pixels. */ |
650 | ||
651 | #define FRAME_SCROLL_BAR_AREA_WIDTH(f) \ | |
652 | (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \ | |
653 | ? (FRAME_CONFIG_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f)) \ | |
654 | : 0) | |
655 | ||
cea6021b RS |
656 | /* Total width of frame F, in columns (characters), |
657 | including the width used by scroll bars if any. */ | |
b45afe99 KS |
658 | |
659 | #define FRAME_TOTAL_COLS(f) ((f)->total_cols) | |
cea6021b RS |
660 | |
661 | /* Set the width of frame F to VAL. | |
662 | VAL is the width of a full-frame window, | |
b45afe99 KS |
663 | not including scroll bars and fringes. */ |
664 | ||
665 | #define SET_FRAME_COLS(f, val) \ | |
666 | (FRAME_COLS (f) = (val), \ | |
667 | (f)->total_cols = FRAME_TOTAL_COLS_ARG (f, FRAME_COLS (f))) | |
cea6021b RS |
668 | |
669 | /* Given a value WIDTH for frame F's nominal width, | |
b45afe99 KS |
670 | return the value that FRAME_TOTAL_COLS should have. */ |
671 | ||
672 | #define FRAME_TOTAL_COLS_ARG(f, width) \ | |
3b83d631 | 673 | ((width) \ |
b45afe99 | 674 | + FRAME_SCROLL_BAR_COLS (f) \ |
986f10ad | 675 | + FRAME_FRINGE_COLS (f)) |
cea6021b | 676 | |
4ff34795 | 677 | /* Maximum + 1 legitimate value for FRAME_CURSOR_X. */ |
b45afe99 | 678 | |
4ff34795 | 679 | #define FRAME_CURSOR_X_LIMIT(f) \ |
b45afe99 | 680 | (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f)) |
cea6021b RS |
681 | |
682 | /* Nonzero if frame F has scroll bars. */ | |
b45afe99 | 683 | |
a3c87d4e | 684 | #define FRAME_SCROLL_BARS(f) ((f)->scroll_bars) |
cea6021b | 685 | |
a3c87d4e | 686 | #define FRAME_CONDEMNED_SCROLL_BARS(f) ((f)->condemned_scroll_bars) |
6d05db81 | 687 | #define FRAME_MENU_BAR_ITEMS(f) ((f)->menu_bar_items) |
95b999aa | 688 | #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate) |
81d00831 | 689 | |
4d418fcc KS |
690 | #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor) |
691 | #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor) | |
692 | #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width) | |
693 | #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width) | |
694 | ||
3b83d631 GM |
695 | /* Return a pointer to the face cache of frame F. */ |
696 | ||
697 | #define FRAME_FACE_CACHE(F) (F)->face_cache | |
698 | ||
81d00831 KH |
699 | /* Return the size of message_buf of the frame F. We multiply the |
700 | width of the frame by 4 because multi-byte form may require at most | |
701 | 4-byte for a character. */ | |
177c0ea7 | 702 | |
b45afe99 | 703 | #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4) |
ff11dfa1 | 704 | |
a4659527 JB |
705 | /* Emacs's redisplay code could become confused if a frame's |
706 | visibility changes at arbitrary times. For example, if a frame is | |
707 | visible while the desired glyphs are being built, but becomes | |
708 | invisible before they are updated, then some rows of the | |
709 | desired_glyphs will be left marked as enabled after redisplay is | |
710 | complete, which should never happen. The next time the frame | |
711 | becomes visible, redisplay will probably barf. | |
712 | ||
713 | Currently, there are no similar situations involving iconified, but | |
714 | the principle is the same. | |
715 | ||
716 | So instead of having asynchronous input handlers directly set and | |
717 | clear the frame's visibility and iconification flags, they just set | |
718 | the async_visible and async_iconified flags; the redisplay code | |
719 | calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay, | |
720 | which sets visible and iconified from their asynchronous | |
46a5c487 JB |
721 | counterparts. |
722 | ||
20a6c8d7 JB |
723 | Synchronous code must use the FRAME_SET_VISIBLE macro. |
724 | ||
725 | Also, if a frame used to be invisible, but has just become visible, | |
726 | it must be marked as garbaged, since redisplay hasn't been keeping | |
9628b887 KL |
727 | up its contents. |
728 | ||
729 | Note that a tty frame is visible if and only if it is the topmost | |
730 | frame. */ | |
177c0ea7 | 731 | |
a4659527 | 732 | #define FRAME_SAMPLE_VISIBILITY(f) \ |
0969b893 GV |
733 | (((f)->async_visible && (f)->visible != (f)->async_visible) ? \ |
734 | SET_FRAME_GARBAGED (f) : 0, \ | |
20a6c8d7 | 735 | (f)->visible = (f)->async_visible, \ |
a4659527 JB |
736 | (f)->iconified = (f)->async_iconified) |
737 | ||
00a2cef7 | 738 | #define CHECK_FRAME(x) \ |
c3df1ad9 GM |
739 | do { \ |
740 | if (! FRAMEP (x)) \ | |
741 | x = wrong_type_argument (Qframep, (x)); \ | |
742 | } while (0) | |
265a9e55 | 743 | |
00a2cef7 | 744 | #define CHECK_LIVE_FRAME(x) \ |
c3df1ad9 GM |
745 | do { \ |
746 | if (! FRAMEP (x) \ | |
747 | || ! FRAME_LIVE_P (XFRAME (x))) \ | |
748 | x = wrong_type_argument (Qframe_live_p, (x)); \ | |
749 | } while (0) | |
265a9e55 | 750 | |
ff11dfa1 JB |
751 | /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a |
752 | `for' loop which iterates over the elements of Vframe_list. The | |
35f56f96 | 753 | loop will set FRAME_VAR, a Lisp_Object, to each frame in |
ff11dfa1 | 754 | Vframe_list in succession and execute the statement. LIST_VAR |
35f56f96 | 755 | should be a Lisp_Object too; it is used to iterate through the |
177c0ea7 | 756 | Vframe_list. |
e5d77022 | 757 | |
e3678b64 KH |
758 | This macro is a holdover from a time when multiple frames weren't always |
759 | supported. An alternate definition of the macro would expand to | |
760 | something which executes the statement once. */ | |
3b83d631 | 761 | |
ff11dfa1 JB |
762 | #define FOR_EACH_FRAME(list_var, frame_var) \ |
763 | for ((list_var) = Vframe_list; \ | |
e5d77022 | 764 | (CONSP (list_var) \ |
ee88f64d KR |
765 | && (frame_var = XCAR (list_var), 1)); \ |
766 | list_var = XCDR (list_var)) | |
e5d77022 JB |
767 | |
768 | ||
5e02ce11 | 769 | extern Lisp_Object Qframep, Qframe_live_p; |
efa4ce8b | 770 | |
ff11dfa1 | 771 | extern struct frame *last_nonminibuf_frame; |
efa4ce8b | 772 | |
28d440ab | 773 | extern struct frame *make_terminal_frame P_ ((char *tty, char *tty_type)); |
fd6a330f | 774 | extern struct frame *make_frame P_ ((int)); |
c9e5d3d1 | 775 | #ifdef HAVE_WINDOW_SYSTEM |
fd6a330f AS |
776 | extern struct frame *make_minibuffer_frame P_ ((void)); |
777 | extern struct frame *make_frame_without_minibuffer P_ ((Lisp_Object, | |
778 | struct kboard *, | |
779 | Lisp_Object)); | |
c9e5d3d1 | 780 | #endif /* HAVE_WINDOW_SYSTEM */ |
fd6a330f | 781 | extern int other_visible_frames P_ ((struct frame *)); |
efa4ce8b | 782 | |
ff11dfa1 JB |
783 | extern Lisp_Object Vframe_list; |
784 | extern Lisp_Object Vdefault_frame_alist; | |
efa4ce8b | 785 | |
0349c9af | 786 | extern Lisp_Object Vmouse_highlight; |
efa4ce8b | 787 | \f |
650afd94 GM |
788 | /* The currently selected frame. */ |
789 | ||
790 | extern Lisp_Object selected_frame; | |
791 | ||
792 | /* Value is a pointer to the selected frame. If the selected frame | |
b975254e | 793 | isn't live, abort. */ |
650afd94 GM |
794 | |
795 | #define SELECTED_FRAME() \ | |
796 | ((FRAMEP (selected_frame) \ | |
797 | && FRAME_LIVE_P (XFRAME (selected_frame))) \ | |
798 | ? XFRAME (selected_frame) \ | |
e1ef1fb2 | 799 | : (abort (), (struct frame *) 0)) |
3b83d631 GM |
800 | |
801 | \f | |
802 | /*********************************************************************** | |
803 | Display-related Macros | |
804 | ***********************************************************************/ | |
805 | ||
b45afe99 KS |
806 | /* Canonical y-unit on frame F. |
807 | This value currently equals the line height of the frame (which is | |
808 | the height of the default font of F). */ | |
809 | ||
810 | #define FRAME_LINE_HEIGHT(F) ((F)->line_height) | |
3b83d631 | 811 | |
b45afe99 KS |
812 | /* Canonical x-unit on frame F. |
813 | This value currently equals the width of the default font of F. */ | |
3b83d631 | 814 | |
b45afe99 | 815 | #define FRAME_COLUMN_WIDTH(F) ((F)->column_width) |
3b83d631 | 816 | |
3b83d631 GM |
817 | |
818 | /* Pixel width of areas used to display truncation marks, continuation | |
5cb26370 | 819 | marks, overlay arrows. This is 0 for terminal frames. */ |
3b83d631 GM |
820 | |
821 | #ifdef HAVE_WINDOW_SYSTEM | |
aa5b8e15 | 822 | |
b45afe99 KS |
823 | /* Total width of fringes reserved for drawing truncation bitmaps, |
824 | continuation bitmaps and alike. The width is in canonical char | |
825 | units of the frame. This must currently be the case because window | |
826 | sizes aren't pixel values. If it weren't the case, we wouldn't be | |
827 | able to split windows horizontally nicely. */ | |
828 | ||
829 | #define FRAME_FRINGE_COLS(F) ((F)->fringe_cols) | |
830 | ||
831 | /* Pixel-width of the left and right fringe. */ | |
832 | ||
833 | #define FRAME_LEFT_FRINGE_WIDTH(F) ((F)->left_fringe_width) | |
834 | #define FRAME_RIGHT_FRINGE_WIDTH(F) ((F)->right_fringe_width) | |
835 | ||
836 | /* Total width of fringes in pixels. */ | |
837 | ||
838 | #define FRAME_TOTAL_FRINGE_WIDTH(F) \ | |
839 | (FRAME_LEFT_FRINGE_WIDTH (F) + FRAME_RIGHT_FRINGE_WIDTH (F)) | |
840 | ||
841 | ||
842 | /* Pixel-width of internal border lines */ | |
843 | ||
844 | #define FRAME_INTERNAL_BORDER_WIDTH(F) ((F)->internal_border_width) | |
177c0ea7 | 845 | |
aa5b8e15 GM |
846 | #else /* not HAVE_WINDOW_SYSTEM */ |
847 | ||
986f10ad | 848 | #define FRAME_FRINGE_COLS(F) 0 |
b45afe99 | 849 | #define FRAME_TOTAL_FRINGE_WIDTH(F) 0 |
986f10ad | 850 | #define FRAME_LEFT_FRINGE_WIDTH(F) 0 |
8432bb78 | 851 | #define FRAME_RIGHT_FRINGE_WIDTH(F) 0 |
b45afe99 | 852 | #define FRAME_INTERNAL_BORDER_WIDTH(F) 0 |
aa5b8e15 GM |
853 | |
854 | #endif /* not HAVE_WINDOW_SYSTEM */ | |
177c0ea7 | 855 | |
3b83d631 GM |
856 | |
857 | ||
858 | \f | |
859 | /*********************************************************************** | |
860 | Conversion between canonical units and pixels | |
861 | ***********************************************************************/ | |
862 | ||
b45afe99 KS |
863 | /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical |
864 | y-unit are fractions of FRAME_LINE_HEIGHT of a frame. Both are | |
865 | represented as Lisp numbers, i.e. integers or floats. */ | |
3b83d631 GM |
866 | |
867 | /* Convert canonical value X to pixels. F is the frame whose | |
868 | canonical char width is to be used. X must be a Lisp integer or | |
869 | float. Value is a C integer. */ | |
177c0ea7 | 870 | |
b45afe99 | 871 | #define FRAME_PIXEL_X_FROM_CANON_X(F, X) \ |
3b83d631 | 872 | (INTEGERP (X) \ |
b45afe99 KS |
873 | ? XINT (X) * FRAME_COLUMN_WIDTH (F) \ |
874 | : (int) (XFLOAT_DATA (X) * FRAME_COLUMN_WIDTH (F))) | |
177c0ea7 | 875 | |
3b83d631 GM |
876 | /* Convert canonical value Y to pixels. F is the frame whose |
877 | canonical character height is to be used. X must be a Lisp integer | |
878 | or float. Value is a C integer. */ | |
177c0ea7 | 879 | |
b45afe99 | 880 | #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y) \ |
3b83d631 | 881 | (INTEGERP (Y) \ |
b45afe99 KS |
882 | ? XINT (Y) * FRAME_LINE_HEIGHT (F) \ |
883 | : (int) (XFLOAT_DATA (Y) * FRAME_LINE_HEIGHT (F))) | |
3b83d631 GM |
884 | |
885 | /* Convert pixel-value X to canonical units. F is the frame whose | |
886 | canonical character width is to be used. X is a C integer. Result | |
887 | is a Lisp float if X is not a multiple of the canon width, | |
888 | otherwise it's a Lisp integer. */ | |
889 | ||
b45afe99 KS |
890 | #define FRAME_CANON_X_FROM_PIXEL_X(F, X) \ |
891 | ((X) % FRAME_COLUMN_WIDTH (F) != 0 \ | |
892 | ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F)) \ | |
893 | : make_number ((X) / FRAME_COLUMN_WIDTH (F))) | |
3b83d631 GM |
894 | |
895 | /* Convert pixel-value Y to canonical units. F is the frame whose | |
896 | canonical character height is to be used. Y is a C integer. | |
897 | Result is a Lisp float if Y is not a multiple of the canon width, | |
898 | otherwise it's a Lisp integer. */ | |
899 | ||
b45afe99 KS |
900 | #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y) \ |
901 | ((Y) % FRAME_LINE_HEIGHT (F) \ | |
902 | ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F)) \ | |
903 | : make_number ((Y) / FRAME_LINE_HEIGHT (F))) | |
904 | ||
905 | ||
906 | \f | |
907 | /* Manipulating pixel sizes and character sizes. | |
908 | Knowledge of which factors affect the overall size of the window should | |
909 | be hidden in these macros, if that's possible. | |
910 | ||
911 | Return the upper/left pixel position of the character cell on frame F | |
912 | at ROW/COL. */ | |
913 | ||
914 | #define FRAME_LINE_TO_PIXEL_Y(f, row) \ | |
915 | (FRAME_INTERNAL_BORDER_WIDTH (f) \ | |
916 | + (row) * FRAME_LINE_HEIGHT (f)) | |
917 | ||
918 | #define FRAME_COL_TO_PIXEL_X(f, col) \ | |
919 | (FRAME_INTERNAL_BORDER_WIDTH (f) \ | |
920 | + (col) * FRAME_COLUMN_WIDTH (f)) | |
921 | ||
922 | /* Return the pixel width/height of frame F if it has | |
923 | COLS columns/LINES rows. */ | |
924 | ||
925 | #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \ | |
926 | (FRAME_COL_TO_PIXEL_X (f, cols) \ | |
927 | + (f)->scroll_bar_actual_width \ | |
928 | + FRAME_TOTAL_FRINGE_WIDTH (f) \ | |
929 | + FRAME_INTERNAL_BORDER_WIDTH (f)) | |
930 | ||
931 | #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \ | |
932 | (FRAME_LINE_TO_PIXEL_Y (f, lines) \ | |
933 | + FRAME_INTERNAL_BORDER_WIDTH (f)) | |
934 | ||
935 | ||
936 | /* Return the row/column (zero-based) of the character cell containing | |
937 | the pixel on FRAME at Y/X. */ | |
938 | ||
939 | #define FRAME_PIXEL_Y_TO_LINE(f, y) \ | |
940 | (((y) - FRAME_INTERNAL_BORDER_WIDTH (f)) \ | |
941 | / FRAME_LINE_HEIGHT (f)) | |
942 | ||
943 | #define FRAME_PIXEL_X_TO_COL(f, x) \ | |
944 | (((x) - FRAME_INTERNAL_BORDER_WIDTH (f)) \ | |
945 | / FRAME_COLUMN_WIDTH (f)) | |
946 | ||
947 | /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on | |
948 | frame F? */ | |
949 | ||
950 | #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width) \ | |
951 | (FRAME_PIXEL_X_TO_COL (f, ((width) \ | |
952 | - FRAME_INTERNAL_BORDER_WIDTH (f) \ | |
953 | - FRAME_TOTAL_FRINGE_WIDTH (f) \ | |
954 | - (f)->scroll_bar_actual_width))) | |
955 | ||
956 | #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height) \ | |
957 | (FRAME_PIXEL_Y_TO_LINE (f, ((height) \ | |
958 | - FRAME_INTERNAL_BORDER_WIDTH (f)))) | |
177c0ea7 | 959 | |
5e02ce11 KS |
960 | |
961 | /*********************************************************************** | |
962 | Frame Parameters | |
963 | ***********************************************************************/ | |
964 | ||
965 | extern Lisp_Object Qauto_raise, Qauto_lower; | |
966 | extern Lisp_Object Qborder_color, Qborder_width; | |
967 | extern Lisp_Object Qbuffer_predicate, Qbuffer_list; | |
968 | extern Lisp_Object Qcursor_color, Qcursor_type; | |
969 | extern Lisp_Object Qfont; | |
970 | extern Lisp_Object Qbackground_color, Qforeground_color; | |
971 | extern Lisp_Object Qicon, Qicon_name, Qicon_type, Qicon_left, Qicon_top; | |
972 | extern Lisp_Object Qinternal_border_width; | |
973 | extern Lisp_Object Qmenu_bar_lines, Qtool_bar_lines; | |
974 | extern Lisp_Object Qmouse_color; | |
975 | extern Lisp_Object Qname, Qtitle; | |
976 | extern Lisp_Object Qparent_id; | |
977 | extern Lisp_Object Qunsplittable, Qvisibility; | |
978 | extern Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars; | |
979 | extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; | |
980 | extern Lisp_Object Qscreen_gamma; | |
981 | extern Lisp_Object Qline_spacing; | |
982 | extern Lisp_Object Qwait_for_wm; | |
983 | extern Lisp_Object Qfullscreen; | |
984 | ||
985 | extern Lisp_Object Qleft_fringe, Qright_fringe; | |
986 | extern Lisp_Object Qheight, Qwidth; | |
987 | extern Lisp_Object Qminibuffer, Qmodeline; | |
988 | extern Lisp_Object Qonly; | |
989 | extern Lisp_Object Qx, Qw32, Qmac, Qpc; | |
990 | extern Lisp_Object Qvisible; | |
991 | extern Lisp_Object Qdisplay_type; | |
992 | extern Lisp_Object Qbackground_mode; | |
993 | ||
994 | extern Lisp_Object Qx_resource_name; | |
995 | ||
996 | extern Lisp_Object Qleft, Qright, Qtop, Qbox; | |
997 | extern Lisp_Object Qdisplay; | |
998 | ||
999 | #ifdef HAVE_WINDOW_SYSTEM | |
1000 | ||
1001 | /* The class of this X application. */ | |
1002 | #define EMACS_CLASS "Emacs" | |
1003 | ||
1004 | enum | |
1005 | { | |
1006 | /* Values used as a bit mask, BOTH == WIDTH | HEIGHT. */ | |
1007 | FULLSCREEN_NONE = 0, | |
1008 | FULLSCREEN_WIDTH = 1, | |
1009 | FULLSCREEN_HEIGHT = 2, | |
1010 | FULLSCREEN_BOTH = 3, | |
1011 | FULLSCREEN_WAIT = 4, | |
5e02ce11 KS |
1012 | }; |
1013 | ||
1014 | ||
1015 | /* These are in xterm.c, w32term.c, etc. */ | |
1016 | ||
1017 | extern void x_set_scroll_bar_default_width P_ ((struct frame *)); | |
1018 | extern void x_set_offset P_ ((struct frame *, int, int, int)); | |
1019 | extern void x_wm_set_icon_position P_ ((struct frame *, int, int)); | |
1020 | ||
1021 | extern Lisp_Object x_new_font P_ ((struct frame *, char *)); | |
1022 | extern Lisp_Object x_new_fontset P_ ((struct frame *, char *)); | |
1023 | ||
1024 | ||
1025 | /* These are in frame.c */ | |
1026 | ||
1027 | extern Lisp_Object Vx_resource_name; | |
1028 | extern Lisp_Object Vx_resource_class; | |
1029 | ||
1030 | ||
1031 | extern Lisp_Object Qface_set_after_frame_default; | |
1032 | ||
1033 | extern void x_fullscreen_adjust P_ ((struct frame *f, int *, int *, | |
1034 | int *, int *)); | |
1035 | ||
1036 | extern void x_set_frame_parameters P_ ((struct frame *, Lisp_Object)); | |
1037 | extern void x_report_frame_params P_ ((struct frame *, Lisp_Object *)); | |
1038 | ||
1039 | extern void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1040 | extern void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1041 | extern void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1042 | extern void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1043 | extern void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1044 | extern void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1045 | extern void x_set_internal_border_width P_ ((struct frame *, Lisp_Object, | |
1046 | Lisp_Object)); | |
1047 | extern void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1048 | extern void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1049 | extern void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1050 | extern void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object)); | |
1051 | extern void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object, | |
1052 | Lisp_Object)); | |
1053 | extern void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object, | |
1054 | Lisp_Object)); | |
1055 | ||
1056 | extern Lisp_Object x_icon_type P_ ((struct frame *)); | |
1057 | ||
1058 | extern int x_figure_window_size P_ ((struct frame *, Lisp_Object, int)); | |
1059 | ||
1060 | ||
1061 | extern void validate_x_resource_name P_ ((void)); | |
1062 | ||
1063 | #endif /* HAVE_WINDOW_SYSTEM */ | |
1064 | ||
84e01749 | 1065 | #endif /* not EMACS_FRAME_H */ |
ab5796a9 MB |
1066 | |
1067 | /* arch-tag: 0df048ee-e6bf-4f48-bd56-e3cd055dd8c4 | |
1068 | (do not change this comment) */ |