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