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