frame.h 56.1 KB
Newer Older
Jim Blandy's avatar
Jim Blandy committed
1
/* Define frame-object for GNU Emacs.
Paul Eggert's avatar
Paul Eggert committed
2
   Copyright (C) 1993-1994, 1999-2019 Free Software Foundation, Inc.
Jim Blandy's avatar
Jim Blandy committed
3 4 5

This file is part of GNU Emacs.

6
GNU Emacs is free software: you can redistribute it and/or modify
Jim Blandy's avatar
Jim Blandy committed
7
it under the terms of the GNU General Public License as published by
8 9
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
Jim Blandy's avatar
Jim Blandy committed
10 11 12 13 14 15 16

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
17
along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
Jim Blandy's avatar
Jim Blandy committed
18

19 20
#ifndef EMACS_FRAME_H
#define EMACS_FRAME_H
Gerd Moellmann's avatar
Gerd Moellmann committed
21

22
#include "termhooks.h"
23
#include "window.h"
24

25 26
INLINE_HEADER_BEGIN

27
enum vertical_scroll_bar_type
Gerd Moellmann's avatar
Gerd Moellmann committed
28 29 30 31 32
{
  vertical_scroll_bar_none,
  vertical_scroll_bar_left,
  vertical_scroll_bar_right
};
33

34 35
#ifdef HAVE_WINDOW_SYSTEM

36 37
enum fullscreen_type
{
38
  FULLSCREEN_NONE,
39 40 41 42
  FULLSCREEN_WIDTH     = 0x1,
  FULLSCREEN_HEIGHT    = 0x2,
  FULLSCREEN_BOTH      = 0x3, /* Not a typo but means "width and height".  */
  FULLSCREEN_MAXIMIZED = 0x4,
43
#ifdef HAVE_NTGUI
44
  FULLSCREEN_WAIT      = 0x8
45
#endif
46 47
};

48 49 50 51 52 53 54
enum z_group
{
  z_group_none,
  z_group_above,
  z_group_below,
  z_group_above_suspended,
};
55 56 57 58 59 60 61 62 63 64 65 66 67

enum internal_border_part
  {
   INTERNAL_BORDER_NONE,
   INTERNAL_BORDER_LEFT_EDGE,
   INTERNAL_BORDER_TOP_LEFT_CORNER,
   INTERNAL_BORDER_TOP_EDGE,
   INTERNAL_BORDER_TOP_RIGHT_CORNER,
   INTERNAL_BORDER_RIGHT_EDGE,
   INTERNAL_BORDER_BOTTOM_RIGHT_CORNER,
   INTERNAL_BORDER_BOTTOM_EDGE,
   INTERNAL_BORDER_BOTTOM_LEFT_CORNER,
  };
68 69 70 71 72 73 74 75

#ifdef NS_IMPL_COCOA
enum ns_appearance_type
  {
   ns_appearance_aqua,
   ns_appearance_vibrant_dark
  };
#endif
76 77
#endif /* HAVE_WINDOW_SYSTEM */

78
/* The structure representing a frame.  */
79

Jim Blandy's avatar
Jim Blandy committed
80
struct frame
Jim Blandy's avatar
Jim Blandy committed
81
{
82
  union vectorlike_header header;
Jim Blandy's avatar
Jim Blandy committed
83

84 85
  /* All Lisp_Object components must come first.
     That ensures they are all aligned normally.  */
Jim Blandy's avatar
Jim Blandy committed
86

87 88
  /* Name of this frame: a Lisp string.  It is used for looking up resources,
     as well as for the title in some cases.  */
89
  Lisp_Object name;
Jim Blandy's avatar
Jim Blandy committed
90

91 92
  /* The name to use for the icon, the last time
     it was refreshed.  nil means not explicitly specified.  */
93
  Lisp_Object icon_name;
94

95 96
  /* This is the frame title specified explicitly, if any.
     Usually it is nil.  */
97
  Lisp_Object title;
98

99
#if defined (HAVE_WINDOW_SYSTEM)
100 101
  /* This frame's parent frame, if it has one.  */
  Lisp_Object parent_frame;
102
#endif /* HAVE_WINDOW_SYSTEM */
103

104
  /* The frame which should receive keystrokes that occur in this
105 106 107 108 109 110 111 112 113 114
     frame, or nil if they should go to the frame itself.  This is
     usually nil, but if the frame is minibufferless, we can use this
     to redirect keystrokes to a surrogate minibuffer frame when
     needed.

     Note that a value of nil is different than having the field point
     to the frame itself.  Whenever the Fselect_frame function is used
     to shift from one frame to the other, any redirections to the
     original frame are shifted to the newly selected frame; if
     focus_frame is nil, Fselect_frame will leave it alone.  */
115
  Lisp_Object focus_frame;
Jim Blandy's avatar
Jim Blandy committed
116

Jim Blandy's avatar
Jim Blandy committed
117 118 119
  /* This frame's root window.  Every frame has one.
     If the frame has only a minibuffer window, this is it.
     Otherwise, if the frame has a minibuffer window, this is its sibling.  */
120
  Lisp_Object root_window;
Jim Blandy's avatar
Jim Blandy committed
121

Jim Blandy's avatar
Jim Blandy committed
122 123 124 125
  /* This frame's selected window.
     Each frame has its own window hierarchy
     and one of the windows in it is selected within the frame.
     The selected window of the selected frame is Emacs's selected window.  */
126
  Lisp_Object selected_window;
Jim Blandy's avatar
Jim Blandy committed
127

128 129 130 131
  /* This frame's selected window when run_window_change_functions was
     called the last time on this frame.  */
  Lisp_Object old_selected_window;

Jim Blandy's avatar
Jim Blandy committed
132 133 134
  /* This frame's minibuffer window.
     Most frames have their own minibuffer windows,
     but only the selected frame's minibuffer window
Jim Blandy's avatar
Jim Blandy committed
135
     can actually appear to exist.  */
136
  Lisp_Object minibuffer_window;
Jim Blandy's avatar
Jim Blandy committed
137

Jim Blandy's avatar
Jim Blandy committed
138 139 140
  /* Parameter alist of this frame.
     These are the parameters specified when creating the frame
     or modified with modify-frame-parameters.  */
141
  Lisp_Object param_alist;
Jim Blandy's avatar
Jim Blandy committed
142

143
  /* List of scroll bars on this frame.
144
     Actually, we don't specify exactly what is stored here at all; the
145
     scroll bar implementation code can use it to store anything it likes.
146
     This field is marked by the garbage collector.  It is here
147
     instead of in the `device' structure so that the garbage
148 149
     collector doesn't need to look inside the window-system-dependent
     structure.  */
150 151
  Lisp_Object scroll_bars;
  Lisp_Object condemned_scroll_bars;
152

Richard M. Stallman's avatar
Richard M. Stallman committed
153 154 155 156 157
  /* Vector describing the items to display in the menu bar.
     Each item has four elements in this vector.
     They are KEY, STRING, SUBMAP, and HPOS.
     (HPOS is not used in when the X toolkit is in use.)
     There are four additional elements of nil at the end, to terminate.  */
158
  Lisp_Object menu_bar_items;
159

160
  /* Alist of elements (FACE-NAME . FACE-VECTOR-DATA).  */
161
  Lisp_Object face_alist;
162

163 164 165
  /* A vector that records the entire structure of this frame's menu bar.
     For the format of the data, see extensive comments in xmenu.c.
     Only the X toolkit version uses this.  */
166
  Lisp_Object menu_bar_vector;
167 168

  /* Predicate for selecting buffers for other-buffer.  */
169
  Lisp_Object buffer_predicate;
170

171
  /* List of buffers viewed in this frame, for other-buffer.  */
172
  Lisp_Object buffer_list;
173

174 175
  /* List of buffers that were viewed, then buried in this frame.  The
     most recently buried buffer is first.  For last-buffer.  */
176
  Lisp_Object buried_buffer_list;
Juanma Barranquero's avatar
Juanma Barranquero committed
177

178
#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
Gerd Moellmann's avatar
Gerd Moellmann committed
179 180
  /* A dummy window used to display menu bars under X when no X
     toolkit support is available.  */
181
  Lisp_Object menu_bar_window;
182
#endif
Gerd Moellmann's avatar
Gerd Moellmann committed
183

184
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
185
  /* A window used to display the tool-bar of a frame.  */
186
  Lisp_Object tool_bar_window;
Gerd Moellmann's avatar
Gerd Moellmann committed
187

188 189 190 191 192
  /* Desired and current contents displayed in that window.  */
  Lisp_Object desired_tool_bar_string;
  Lisp_Object current_tool_bar_string;
#endif

193
#ifdef USE_GTK
194 195
  /* Where tool bar is, can be left, right, top or bottom.
     Except with GTK, the only supported position is `top'.  */
196
  Lisp_Object tool_bar_position;
197
#endif
198

199 200 201 202 203
#if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
  /* List of data specific to font-driver and frame, but common to faces.  */
  Lisp_Object font_data;
#endif

204 205 206
  /* Desired and current tool-bar items.  */
  Lisp_Object tool_bar_items;
  /* tool_bar_items should be the last Lisp_Object member.  */
207

Gerd Moellmann's avatar
Gerd Moellmann committed
208 209
  /* Cache of realized faces.  */
  struct face_cache *face_cache;
210

211
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
212 213 214 215
  /* Tool-bar item index of the item on which a mouse button was pressed.  */
  int last_tool_bar_item;
#endif

216
  /* Number of elements in `menu_bar_vector' that have meaningful data.  */
217
  int menu_bar_items_used;
218

219
#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
220 221 222
  /* A buffer to hold the frame's name.  Since this is used by the
     window system toolkit, we can't use the Lisp string's pointer
     (`name', above) because it might get relocated.  */
223
  char *namebuf;
224
#endif
225

226 227 228 229 230
#ifdef USE_X_TOOLKIT
  /* Used to pass geometry parameters to toolkit functions.  */
  char *shell_position;
#endif

231
  /* Glyph pool and matrix.  */
Gerd Moellmann's avatar
Gerd Moellmann committed
232 233 234 235 236
  struct glyph_pool *current_pool;
  struct glyph_pool *desired_pool;
  struct glyph_matrix *desired_matrix;
  struct glyph_matrix *current_matrix;

237 238
  /* Bitfield area begins here.  Keep them together to avoid extra padding.  */

239
  /* True means that glyphs on this frame have been initialized so it can
Gerd Moellmann's avatar
Gerd Moellmann committed
240
     be used for output.  */
241
  bool_bf glyphs_initialized_p : 1;
242

243
  /* Set to true in change_frame_size when size of frame changed
244
     Clear the frame in clear_garbaged_frames if set.  */
245
  bool_bf resized_p : 1;
246

247
  /* Set to true if the default face for the frame has been
248 249
     realized.  Reset to zero whenever the default face changes.
     Used to see the difference between a font change and face change.  */
250
  bool_bf default_face_done_p : 1;
251

252
  /* Set to true if this frame has already been hscrolled during
253
     current redisplay.  */
254
  bool_bf already_hscrolled_p : 1;
255

256 257
  /* Set to true when current redisplay has updated frame.  */
  bool_bf updated_p : 1;
258

259
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
260
  /* Set to true to minimize tool-bar height even when
261
     auto-resize-tool-bar is set to grow-only.  */
262
  bool_bf minimize_tool_bar_window_p : 1;
263
#endif
264

265
#ifdef HAVE_EXT_TOOL_BAR
266 267
  /* True means using a tool bar that comes from the toolkit.  */
  bool_bf external_tool_bar : 1;
Jan Djärv's avatar
Jan Djärv committed
268 269
#endif

270
  /* True means that fonts have been loaded since the last glyph
271
     matrix adjustments.  */
272
  bool_bf fonts_changed : 1;
273

274 275
  /* True means that cursor type has been changed.  */
  bool_bf cursor_type_changed : 1;
276 277

  /* True if it needs to be redisplayed.  */
278
  bool_bf redisplay : 1;
279

280 281
#ifdef HAVE_EXT_MENU_BAR
  /* True means using a menu bar that comes from the toolkit.  */
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
  bool_bf external_menu_bar : 1;
#endif

  /* Next two bitfields are mutually exclusive.  They might both be
     zero if the frame has been made invisible without an icon.  */

  /* Nonzero if the frame is currently displayed; we check
     it to see if we should bother updating the frame's contents.

     On ttys and on Windows NT/9X, to avoid wasting effort updating
     visible frames that are actually completely obscured by other
     windows on the display, we bend the meaning of visible slightly:
     if equal to 2, then the frame is obscured - we still consider
     it to be "visible" as seen from lisp, but we don't bother
     updating it.  */
  unsigned visible : 2;

  /* True if the frame is currently iconified.  Do not
     set this directly, use SET_FRAME_ICONIFIED instead.  */
  bool_bf iconified : 1;

  /* True if this frame should be fully redisplayed.  Disables all
     optimizations while rebuilding matrices and redrawing.  */
  bool_bf garbaged : 1;

  /* False means, if this frame has just one window,
     show no modeline for that window.  */
  bool_bf wants_modeline : 1;

  /* True means raise this frame to the top of the heap when selected.  */
  bool_bf auto_raise : 1;

  /* True means lower this frame to the bottom of the stack when left.  */
  bool_bf auto_lower : 1;

  /* True if frame's root window can't be split.  */
  bool_bf no_split : 1;

  /* If this is set, then Emacs won't change the frame name to indicate
     the current buffer, etcetera.  If the user explicitly sets the frame
     name, this gets set.  If the user sets the name to Qnil, this is
     cleared.  */
  bool_bf explicit_name : 1;

326 327 328 329 330 331 332 333
  /* True if at least one window on this frame changed since the last
     call of run_window_change_functions.  Changes are either "state
     changes" (a window has been created, deleted or got assigned
     another buffer) or "size changes" (the total or body size of a
     window changed).  run_window_change_functions exits early unless
     either this flag is true or a window selection happened on this
     frame.  */
  bool_bf window_change : 1;
334

335 336 337 338
  /* True if running window state change functions has been explicitly
     requested for this frame since last redisplay.  */
  bool_bf window_state_change : 1;

339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
  /* True if the mouse has moved on this display device
     since the last time we checked.  */
  bool_bf mouse_moved : 1;

  /* True means that the pointer is invisible.  */
  bool_bf pointer_invisible : 1;

  /* True means that all windows except mini-window and
     selected window on this frame have frozen window starts.  */
  bool_bf frozen_window_starts : 1;

  /* The output method says how the contents of this frame are
     displayed.  It could be using termcap, or using an X window.
     This must be the same as the terminal->type. */
  ENUM_BF (output_method) output_method : 3;

#ifdef HAVE_WINDOW_SYSTEM
356 357 358
  /* True if this frame is a tooltip frame.  */
  bool_bf tooltip : 1;

359 360 361 362 363 364 365
  /* See FULLSCREEN_ enum on top.  */
  ENUM_BF (fullscreen_type) want_fullscreen : 4;

  /* If not vertical_scroll_bar_none, we should actually
     display the scroll bars of this type on this frame.  */
  ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;

366 367
  /* Nonzero if we should actually display horizontal scroll bars on this frame.  */
  bool_bf horizontal_scroll_bars : 1;
368

369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
  /* True if this is an undecorated frame.  */
  bool_bf undecorated : 1;

#ifndef HAVE_NTGUI
  /* True if this is an override_redirect frame.  */
  bool_bf override_redirect : 1;
#endif

  /* Nonzero if this frame's icon should not appear on its display's taskbar.  */
  bool_bf skip_taskbar : 1;

  /* Nonzero if this frame's window F's X window does not want to
     receive input focus when it is mapped.  */
  bool_bf no_focus_on_map : 1;

  /* Nonzero if this frame's window does not want to receive input focus
     via mouse clicks or by moving the mouse into it.  */
  bool_bf no_accept_focus : 1;

  /* The z-group this frame's window belongs to. */
  ENUM_BF (z_group) z_group : 2;
390 391 392 393 394

  /* Non-zero if display of truncation and continuation glyphs outside
     the fringes is suppressed.  */
  bool_bf no_special_glyphs : 1;
#endif /* HAVE_WINDOW_SYSTEM */
395

396 397 398 399
  /* Whether new_height and new_width shall be interpreted
     in pixels.  */
  bool_bf new_pixelwise : 1;

400 401 402 403
  /* True means x_set_window_size requests can be processed for this
     frame.  */
  bool_bf can_x_set_window_size : 1;

404 405
  /* Set to true after this frame was made by `make-frame'.  */
  bool_bf after_make_frame : 1;
406

407 408 409 410 411 412 413 414
  /* Whether the tool bar height change should be taken into account.  */
  bool_bf tool_bar_redisplayed : 1;
  bool_bf tool_bar_resized : 1;

  /* Inhibit implied resize before after_make_frame is set.  */
  bool_bf inhibit_horizontal_resize : 1;
  bool_bf inhibit_vertical_resize : 1;

415 416 417
  /* Non-zero if this frame's faces need to be recomputed.  */
  bool_bf face_change : 1;

418 419 420 421
  /* Non-zero if this frame's image cache cannot be freed because the
     frame is in the process of being redisplayed.  */
  bool_bf inhibit_clear_image_cache : 1;

422 423
  /* Bitfield area ends here.  */

424 425 426 427 428 429 430 431 432 433 434 435 436 437
  /* This frame's change stamp, set the last time window change
     functions were run for this frame.  Should never be 0 because
     that's the change stamp of a new window.  A window was not on a
     frame the last run_window_change_functions was called on it if
     it's change stamp differs from that of its frame.  */
  int change_stamp;

  /* This frame's number of windows, set the last time window change
     functions were run for this frame.  Should never be 0 even for
     minibuffer-only frames.  If no window has been added, this allows
     to detect whether a window was deleted on this frame since the
     last time run_window_change_functions was called on it.  */
  ptrdiff_t number_of_windows;

438
  /* Number of lines (rounded up) of tool bar.  REMOVE THIS  */
439
  int tool_bar_lines;
Gerd Moellmann's avatar
Gerd Moellmann committed
440

441
  /* Height of frame internal tool bar in pixels.  */
442 443
  int tool_bar_height;

444
  int n_tool_bar_rows;
445
  int n_tool_bar_items;
446

447
  /* A buffer for decode_mode_line.  */
Gerd Moellmann's avatar
Gerd Moellmann committed
448
  char *decode_mode_spec_buffer;
449

450 451
  /* See do_line_insertion_deletion_costs for info on these arrays.  */
  /* Cost of inserting 1 line on this frame.  */
452
  int *insert_line_cost;
453
  /* Cost of deleting 1 line on this frame.  */
454
  int *delete_line_cost;
455
  /* Cost of inserting n lines on this frame.  */
456
  int *insert_n_lines_cost;
457
  /* Cost of deleting n lines on this frame.  */
458 459
  int *delete_n_lines_cost;

460 461 462 463
  /* Text width of this frame (excluding fringes, vertical scroll bar
     and internal border widths) and text height (excluding menu bar,
     tool bar, horizontal scroll bar and internal border widths) in
     units of canonical characters.  */
464 465
  int text_cols, text_lines;

466 467 468
  /* Total width of this frame (including fringes, vertical scroll bar
     and internal border widths) and total height (including menu bar,
     tool bar, horizontal scroll bar and internal border widths) in
469
     units of canonical characters.  */
470
  int total_cols, total_lines;
471

472 473 474 475
  /* Text width of this frame (excluding fringes, vertical scroll bar
     and internal border widths) and text height (excluding menu bar,
     tool bar, horizontal scroll bar and internal border widths) in
     pixels.  */
476
  int text_width, text_height;
477

478
  /* New text height and width for pending size change.  0 if no change
Paul Eggert's avatar
Paul Eggert committed
479
     pending.  These values represent pixels or canonical character units
480
     according to the value of new_pixelwise and correlate to the
481 482
     text width/height of the frame.  */
  int new_width, new_height;
483 484 485 486

  /* Pixel position of the frame window (x and y offsets in root window).  */
  int left_pos, top_pos;

487
  /* Total width of this frame (including fringes, vertical scroll bar
488 489 490
     and internal border widths) and total height (including internal
     menu and tool bars, horizontal scroll bar and internal border
     widths) in pixels.  */
491
  int pixel_width, pixel_height;
492 493 494 495 496 497

  /* This is the gravity value for the specified window position.  */
  int win_gravity;

  /* The geometry flags for this window.  */
  int size_hint_flags;
498

499 500 501 502 503 504 505 506
  /* Border width of the frame window as known by the (X) window system.  */
  int border_width;

  /* Width of the internal border.  This is a line of background color
     just inside the window's border.  When the frame is selected,
     a highlighting is displayed inside the internal border.  */
  int internal_border_width;

507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
  /* Widths of dividers between this frame's windows in pixels.  */
  int right_divider_width, bottom_divider_width;

  /* Widths of fringes in pixels.  */
  int left_fringe_width, right_fringe_width;

  /* Total width of fringes reserved for drawing truncation bitmaps,
     continuation bitmaps and alike - REMOVE THIS !!!!.    */
  int fringe_cols;

  /* Number of lines of menu bar.  */
  int menu_bar_lines;

  /* Pixel height of menubar.  */
  int menu_bar_height;
522

523 524 525 526 527
  /* Canonical X unit.  Width of default font, in pixels.  */
  int column_width;

  /* Canonical Y unit.  Height of a line, in pixels.  */
  int line_height;
528

529
  /* The terminal device that this frame uses.  If this is NULL, then
530
     the frame has been deleted.  */
531
  struct terminal *terminal;
Juanma Barranquero's avatar
Juanma Barranquero committed
532

533
  /* Device-dependent, frame-local auxiliary data used for displaying
534
     the contents.  When the frame is deleted, this data is deleted as
535
     well.  */
Gerd Moellmann's avatar
Gerd Moellmann committed
536 537
  union output_data
  {
538 539 540 541
    struct tty_output *tty;     /* From termchar.h.  */
    struct x_output *x;         /* From xterm.h.  */
    struct w32_output *w32;     /* From w32term.h.  */
    struct ns_output *ns;       /* From nsterm.h.  */
542
    intptr_t nothing;
Gerd Moellmann's avatar
Gerd Moellmann committed
543 544
  }
  output_data;
Jim Blandy's avatar
Jim Blandy committed
545

546
  /* List of font-drivers available on the frame.  */
547 548
  struct font_driver_list *font_driver_list;

549 550 551 552 553
#if defined (HAVE_X_WINDOWS)
  /* Used by x_wait_for_event when watching for an X event on this frame.  */
  int wait_event_type;
#endif

554 555 556 557 558 559 560 561 562 563 564 565 566 567
  /* What kind of text cursor should we draw in the future?
     This should always be filled_box_cursor or bar_cursor.  */
  enum text_cursor_kinds desired_cursor;

  /* Width of bar cursor (if we are using that).  */
  int cursor_width;

  /* What kind of text cursor should we draw when the cursor blinks off?
     This can be filled_box_cursor or bar_cursor or no_cursor.  */
  enum text_cursor_kinds blink_off_cursor;

  /* Width of bar cursor (if we are using that) for blink-off state.  */
  int blink_off_cursor_width;

568 569 570 571 572 573 574 575
  /* Configured width of the scroll bar, in pixels and in characters.
     config_scroll_bar_cols tracks config_scroll_bar_width if the
     latter is positive; a zero value in config_scroll_bar_width means
     to compute the actual width on the fly, using config_scroll_bar_cols
     and the current font width.  */
  int config_scroll_bar_width;
  int config_scroll_bar_cols;

576 577 578 579 580 581 582 583
  /* Configured height of the scroll bar, in pixels and in characters.
     config_scroll_bar_lines tracks config_scroll_bar_height if the
     latter is positive; a zero value in config_scroll_bar_height means
     to compute the actual width on the fly, using
     config_scroll_bar_lines and the current font width.  */
  int config_scroll_bar_height;
  int config_scroll_bar_lines;

584
  /* The baud rate that was used to calculate costs for this frame.  */
585
  intmax_t cost_calculation_baud_rate;
586

587
  /* Frame opacity
588
     alpha[0]: alpha transparency of the active frame
589 590
     alpha[1]: alpha transparency of inactive frames
     Negative values mean not to change alpha.  */
591 592
  double alpha[2];

593 594 595 596
  /* Exponent for gamma correction of colors.  1/(VIEWING_GAMMA *
     SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
     frame parameter.  0 means don't do gamma correction.  */
  double gamma;
597 598 599

  /* Additional space to put between text lines on this frame.  */
  int extra_line_spacing;
600

601
  /* All display backends seem to need these two pixel values.  */
602 603
  unsigned long background_pixel;
  unsigned long foreground_pixel;
604 605 606 607 608 609

#ifdef NS_IMPL_COCOA
  /* NSAppearance theme used on this frame.  */
  enum ns_appearance_type ns_appearance;
  bool_bf ns_transparent_titlebar;
#endif
Paul Eggert's avatar
Paul Eggert committed
610
} GCALIGNED_STRUCT;
Jim Blandy's avatar
Jim Blandy committed
611

612 613
/* Most code should use these functions to set Lisp fields in struct frame.  */

Paul Eggert's avatar
Paul Eggert committed
614
INLINE void
615 616 617 618
fset_buffer_list (struct frame *f, Lisp_Object val)
{
  f->buffer_list = val;
}
Paul Eggert's avatar
Paul Eggert committed
619
INLINE void
620 621 622 623
fset_buried_buffer_list (struct frame *f, Lisp_Object val)
{
  f->buried_buffer_list = val;
}
Paul Eggert's avatar
Paul Eggert committed
624
INLINE void
625 626 627 628
fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
{
  f->condemned_scroll_bars = val;
}
Paul Eggert's avatar
Paul Eggert committed
629
INLINE void
630 631 632 633
fset_face_alist (struct frame *f, Lisp_Object val)
{
  f->face_alist = val;
}
634
#if defined (HAVE_WINDOW_SYSTEM)
635 636 637 638 639 640
INLINE void
fset_parent_frame (struct frame *f, Lisp_Object val)
{
  f->parent_frame = val;
}
#endif
Paul Eggert's avatar
Paul Eggert committed
641
INLINE void
642 643 644 645
fset_focus_frame (struct frame *f, Lisp_Object val)
{
  f->focus_frame = val;
}
Paul Eggert's avatar
Paul Eggert committed
646
INLINE void
647 648 649 650
fset_icon_name (struct frame *f, Lisp_Object val)
{
  f->icon_name = val;
}
Paul Eggert's avatar
Paul Eggert committed
651
INLINE void
652 653 654 655
fset_menu_bar_items (struct frame *f, Lisp_Object val)
{
  f->menu_bar_items = val;
}
Paul Eggert's avatar
Paul Eggert committed
656
INLINE void
657 658 659 660
fset_menu_bar_vector (struct frame *f, Lisp_Object val)
{
  f->menu_bar_vector = val;
}
661
#if defined (HAVE_X_WINDOWS) && ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
Paul Eggert's avatar
Paul Eggert committed
662
INLINE void
663 664 665 666
fset_menu_bar_window (struct frame *f, Lisp_Object val)
{
  f->menu_bar_window = val;
}
667
#endif
Paul Eggert's avatar
Paul Eggert committed
668
INLINE void
669 670 671 672
fset_name (struct frame *f, Lisp_Object val)
{
  f->name = val;
}
Paul Eggert's avatar
Paul Eggert committed
673
INLINE void
674 675 676 677
fset_param_alist (struct frame *f, Lisp_Object val)
{
  f->param_alist = val;
}
Paul Eggert's avatar
Paul Eggert committed
678
INLINE void
679 680 681 682
fset_root_window (struct frame *f, Lisp_Object val)
{
  f->root_window = val;
}
Paul Eggert's avatar
Paul Eggert committed
683
INLINE void
684 685 686 687
fset_scroll_bars (struct frame *f, Lisp_Object val)
{
  f->scroll_bars = val;
}
Paul Eggert's avatar
Paul Eggert committed
688
INLINE void
689 690 691 692
fset_selected_window (struct frame *f, Lisp_Object val)
{
  f->selected_window = val;
}
Paul Eggert's avatar
Paul Eggert committed
693
INLINE void
694 695 696 697 698
fset_old_selected_window (struct frame *f, Lisp_Object val)
{
  f->old_selected_window = val;
}
INLINE void
699 700 701 702
fset_title (struct frame *f, Lisp_Object val)
{
  f->title = val;
}
Paul Eggert's avatar
Paul Eggert committed
703
INLINE void
704 705 706 707
fset_tool_bar_items (struct frame *f, Lisp_Object val)
{
  f->tool_bar_items = val;
}
708
#ifdef USE_GTK
Paul Eggert's avatar
Paul Eggert committed
709
INLINE void
710 711 712 713
fset_tool_bar_position (struct frame *f, Lisp_Object val)
{
  f->tool_bar_position = val;
}
714
#endif /* USE_GTK */
715
#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
Paul Eggert's avatar
Paul Eggert committed
716
INLINE void
717 718 719 720
fset_tool_bar_window (struct frame *f, Lisp_Object val)
{
  f->tool_bar_window = val;
}
Paul Eggert's avatar
Paul Eggert committed
721
INLINE void
722 723 724 725
fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
{
  f->current_tool_bar_string = val;
}
Paul Eggert's avatar
Paul Eggert committed
726
INLINE void
727 728 729 730 731
fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
{
  f->desired_tool_bar_string = val;
}
#endif /* HAVE_WINDOW_SYSTEM && !USE_GTK && !HAVE_NS */
732

Paul Eggert's avatar
Paul Eggert committed
733 734 735
INLINE double
NUMVAL (Lisp_Object x)
{
736
  return NUMBERP (x) ? XFLOATINT (x) : -1;
Paul Eggert's avatar
Paul Eggert committed
737
}
738

Paul Eggert's avatar
Paul Eggert committed
739
INLINE double
740 741 742 743 744 745 746 747
default_pixels_per_inch_x (void)
{
  Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
		   ? XCAR (Vdisplay_pixels_per_inch)
		   : Vdisplay_pixels_per_inch);
  return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
}

Paul Eggert's avatar
Paul Eggert committed
748
INLINE double
749 750 751 752 753 754 755 756
default_pixels_per_inch_y (void)
{
  Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
		   ? XCDR (Vdisplay_pixels_per_inch)
		   : Vdisplay_pixels_per_inch);
  return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
}

757
#define FRAME_KBOARD(f) ((f)->terminal->kboard)
758

759 760 761
/* Return a pointer to the image cache of frame F.  */
#define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)

762
#define XFRAME(p) \
763
  (eassert (FRAMEP (p)), XUNTAG (p, Lisp_Vectorlike, struct frame))
764
#define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
Jim Blandy's avatar
Jim Blandy committed
765

Richard M. Stallman's avatar
Richard M. Stallman committed
766
/* Given a window, return its frame as a Lisp_Object.  */
767
#define WINDOW_FRAME(w) ((w)->frame)
Jim Blandy's avatar
Jim Blandy committed
768

Richard M. Stallman's avatar
Richard M. Stallman committed
769
/* Test a frame for particular kinds of display methods.  */
770
#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
Richard M. Stallman's avatar
Richard M. Stallman committed
771
#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
772
#define FRAME_X_P(f) ((f)->output_method == output_x_window)
Daniel Colascione's avatar
Daniel Colascione committed
773
#ifndef HAVE_NTGUI
774
#define FRAME_W32_P(f) false
775
#else
776
#define FRAME_W32_P(f) ((f)->output_method == output_w32)
777 778
#endif
#ifndef MSDOS
779
#define FRAME_MSDOS_P(f) false
780
#else
781
#define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
782 783
#endif
#ifndef HAVE_NS
784
#define FRAME_NS_P(f) false
785
#else
786
#define FRAME_NS_P(f) ((f)->output_method == output_ns)
787
#endif
788

789 790
/* FRAME_WINDOW_P tests whether the frame is a window, and is
   defined to be the predicate for the window system being used.  */
Gerd Moellmann's avatar
Gerd Moellmann committed
791

792 793 794 795
#ifdef HAVE_X_WINDOWS
#define FRAME_WINDOW_P(f) FRAME_X_P (f)
#endif
#ifdef HAVE_NTGUI
796
#define FRAME_WINDOW_P(f) FRAME_W32_P (f)
797
#endif
798 799 800
#ifdef HAVE_NS
#define FRAME_WINDOW_P(f) FRAME_NS_P(f)
#endif
801
#ifndef FRAME_WINDOW_P
802
#define FRAME_WINDOW_P(f) ((void) (f), false)
803
#endif
804

805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
/* Dots per inch of the screen the frame F is on.  */

#ifdef HAVE_WINDOW_SYSTEM

#define FRAME_RES_X(f)						\
  (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
#define FRAME_RES_Y(f)						\
  (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)

#else /* !HAVE_WINDOW_SYSTEM */

/* Defaults when no window system available.  */

#define FRAME_RES_X(f) default_pixels_per_inch_x ()
#define FRAME_RES_Y(f) default_pixels_per_inch_y ()

#endif /* HAVE_WINDOW_SYSTEM */

823 824
/* Return a pointer to the structure holding information about the
   region of text, if any, that is currently shown in mouse-face on
825
   frame F.  We need to define two versions because a TTY-only build
826
   does not have FRAME_DISPLAY_INFO.  */
827 828
#ifdef HAVE_WINDOW_SYSTEM
# define MOUSE_HL_INFO(F)					\
829
  (FRAME_WINDOW_P(F)						\
830
   ? &FRAME_DISPLAY_INFO(F)->mouse_highlight			\
831
   : &(F)->output_data.tty->display_info->mouse_highlight)
832 833
#else
# define MOUSE_HL_INFO(F)					\
834
  (&(F)->output_data.tty->display_info->mouse_highlight)
835
#endif
836

837
/* True if frame F is still alive (not deleted).  */
838
#define FRAME_LIVE_P(f) ((f)->terminal != 0)
Richard M. Stallman's avatar
Richard M. Stallman committed
839

840
/* True if frame F is a minibuffer-only frame.  */
Jim Blandy's avatar
Jim Blandy committed
841 842
#define FRAME_MINIBUF_ONLY_P(f) \
  EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
Richard M. Stallman's avatar
Richard M. Stallman committed
843

844
/* True if frame F contains it's own minibuffer window.  Frame always has
845 846 847 848
   minibuffer window, but it could use minibuffer window of another frame.  */
#define FRAME_HAS_MINIBUF_P(f)					\
  (WINDOWP (f->minibuffer_window)				\
   && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
Richard M. Stallman's avatar
Richard M. Stallman committed
849

850 851 852
/* Pixel width of frame F.  */
#define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)

853
/* Pixel height of frame F.  */
854 855
#define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)

856 857 858
/* Width of frame F, measured in canonical character columns,
   not including scroll bars if any.  */
#define FRAME_COLS(f) (f)->text_cols
859 860 861 862 863

/* Height of frame F, measured in canonical lines, including
   non-toolkit menu bar and non-toolkit tool bar lines.  */
#define FRAME_LINES(f) (f)->text_lines

864 865 866 867 868
/* Width of frame F, measured in pixels not including the width for
   fringes, scroll bar, and internal borders.  */
#define FRAME_TEXT_WIDTH(f) (f)->text_width

/* Height of frame F, measured in pixels not including the height
869
   for scroll bar and internal borders.  */
870
#define FRAME_TEXT_HEIGHT(f) (f)->text_height
Richard M. Stallman's avatar
Richard M. Stallman committed
871 872 873 874

/* Number of lines of frame F used for menu bar.
   This is relevant on terminal frames and on
   X Windows when not using the X toolkit.
875
   These lines are counted in FRAME_LINES.  */
876
#define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
Richard M. Stallman's avatar
Richard M. Stallman committed
877

878 879 880
/* Pixel height of frame F's menu bar.  */
#define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height

881
/* True if this frame should display a tool bar
Jan Djärv's avatar
Jan Djärv committed
882
   in a way that does not use any text lines.  */
883
#ifdef HAVE_EXT_TOOL_BAR
Jan Djärv's avatar
Jan Djärv committed
884 885
#define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
#else
886
#define FRAME_EXTERNAL_TOOL_BAR(f) false
Jan Djärv's avatar
Jan Djärv committed
887 888
#endif

889 890 891 892
/* This is really supported only with GTK.  */
#ifdef USE_GTK
#define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
#else
893
#define FRAME_TOOL_BAR_POSITION(f) ((void) (f), Qtop)
894 895
#endif

896 897
/* Number of lines of frame F used for the tool-bar.  */
#define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
Gerd Moellmann's avatar
Gerd Moellmann committed
898

899 900
/* Pixel height of frame F's tool-bar.  */
#define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
Jan Djärv's avatar
Jan Djärv committed
901

Gerd Moellmann's avatar
Gerd Moellmann committed
902 903
/* Lines above the top-most window in frame F.  */
#define FRAME_TOP_MARGIN(F) \
904
  (FRAME_MENU_BAR_LINES (F) + FRAME_TOOL_BAR_LINES (F))
Gerd Moellmann's avatar
Gerd Moellmann committed
905

906 907 908
/* Pixel height of frame F's top margin.  */
#define FRAME_TOP_MARGIN_HEIGHT(F)				\
  (FRAME_MENU_BAR_HEIGHT (F) + FRAME_TOOL_BAR_HEIGHT (F))
909

910
/* True if this frame should display a menu bar
Richard M. Stallman's avatar
Richard M. Stallman committed
911
   in a way that does not use any text lines.  */
912
#ifdef HAVE_EXT_MENU_BAR
913
#define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
914
#else
915
#define FRAME_EXTERNAL_MENU_BAR(f) false
916
#endif
917 918

/* True if frame F is currently visible.  */
919
#define FRAME_VISIBLE_P(f) (f)->visible
Richard M. Stallman's avatar
Richard M. Stallman committed
920

921
/* True if frame F is currently visible but hidden.  */
Geoff Voelker's avatar
Geoff Voelker committed
922
#define FRAME_OBSCURED_P(f) ((f)->visible > 1)
Richard M. Stallman's avatar
Richard M. Stallman committed
923

924
/* True if frame F is currently iconified.  */
Richard M. Stallman's avatar
Richard M. Stallman committed
925 926
#define FRAME_ICONIFIED_P(f) (f)->iconified

927
/* Mark frame F as currently garbaged.  */
928 929
#define SET_FRAME_GARBAGED(f)				\
  (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
930

931
/* True if frame F is currently garbaged.  */
Jim Blandy's avatar
Jim Blandy committed
932
#define FRAME_GARBAGED_P(f) (f)->garbaged
Richard M. Stallman's avatar
Richard M. Stallman committed
933

934
/* True means do not allow splitting this frame's window.  */
Jim Blandy's avatar
Jim Blandy committed
935
#define FRAME_NO_SPLIT_P(f) (f)->no_split
Richard M. Stallman's avatar
Richard M. Stallman committed
936 937

/* Not really implemented.  */
Jim Blandy's avatar
Jim Blandy committed
938
#define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
Richard M. Stallman's avatar
Richard M. Stallman committed
939

940
/* True if all windows except selected window and mini window
941 942 943
   are frozen on frame F.  */
#define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts

944 945 946
/* True if at least one window changed on frame F since the last time
   window change functions were run on F.  */
#define FRAME_WINDOW_CHANGE(f) (f)->window_change
Richard M. Stallman's avatar
Richard M. Stallman committed
947

948 949 950 951
/* True if running window state change functions has been explicitly
   requested for this frame since last redisplay.  */
#define FRAME_WINDOW_STATE_CHANGE(f) (f)->window_state_change

Richard M. Stallman's avatar
Richard M. Stallman committed
952
/* The minibuffer window of frame F, if it has one; otherwise nil.  */
953
#define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
Richard M. Stallman's avatar
Richard M. Stallman committed
954 955

/* The root window of the window tree of frame F.  */
956
#define FRAME_ROOT_WINDOW(f) f->root_window
Richard M. Stallman's avatar
Richard M. Stallman committed
957

958
/* The currently selected window of frame F.  */
959
#define FRAME_SELECTED_WINDOW(f) f->selected_window
960 961
/* The old selected window of frame F.  */
#define FRAME_OLD_SELECTED_WINDOW(f) f->old_selected_window
Richard M. Stallman's avatar
Richard M. Stallman committed
962

963 964
#define FRAME_INSERT_COST(f) (f)->insert_line_cost
#define FRAME_DELETE_COST(f) (f)->delete_line_cost
Jim Blandy's avatar
Jim Blandy committed
965 966
#define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
#define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
967
#define FRAME_FOCUS_FRAME(f) f->focus_frame