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