root/src/frame.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. fset_buffer_list
  2. fset_buried_buffer_list
  3. fset_condemned_scroll_bars
  4. fset_face_hash_table
  5. fset_parent_frame
  6. fset_focus_frame
  7. fset_icon_name
  8. fset_menu_bar_items
  9. fset_menu_bar_vector
  10. fset_menu_bar_window
  11. fset_name
  12. fset_param_alist
  13. fset_root_window
  14. fset_scroll_bars
  15. fset_selected_window
  16. fset_old_selected_window
  17. fset_title
  18. fset_tab_bar_items
  19. fset_tab_bar_window
  20. fset_current_tab_bar_string
  21. fset_desired_tab_bar_string
  22. fset_tool_bar_items
  23. fset_tool_bar_window
  24. fset_current_tool_bar_string
  25. fset_desired_tool_bar_string
  26. fset_tool_bar_position
  27. NUMVAL
  28. default_pixels_per_inch_x
  29. default_pixels_per_inch_y
  30. SET_FRAME_VISIBLE
  31. SET_FRAME_ICONIFIED
  32. window_system_available
  33. frame_dimension
  34. FRAME_FRINGE_COLS
  35. FRAME_LEFT_FRINGE_WIDTH
  36. FRAME_RIGHT_FRINGE_WIDTH
  37. FRAME_TOTAL_FRINGE_WIDTH
  38. FRAME_CHILD_FRAME_BORDER_WIDTH
  39. FRAME_INTERNAL_BORDER_WIDTH
  40. FRAME_RIGHT_DIVIDER_WIDTH
  41. FRAME_BOTTOM_DIVIDER_WIDTH
  42. FACE_FROM_ID
  43. FACE_FROM_ID_OR_NULL
  44. IMAGE_FROM_ID
  45. IMAGE_OPT_FROM_ID
  46. gui_set_bitmap_icon
  47. flush_frame

     1 /* Define frame-object for GNU Emacs.
     2    Copyright (C) 1993-1994, 1999-2023 Free Software Foundation, Inc.
     3 
     4 This file is part of GNU Emacs.
     5 
     6 GNU Emacs is free software: you can redistribute it and/or modify
     7 it under the terms of the GNU General Public License as published by
     8 the Free Software Foundation, either version 3 of the License, or (at
     9 your option) any later version.
    10 
    11 GNU Emacs is distributed in the hope that it will be useful,
    12 but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 GNU General Public License for more details.
    15 
    16 You should have received a copy of the GNU General Public License
    17 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    18 
    19 #ifndef EMACS_FRAME_H
    20 #define EMACS_FRAME_H
    21 
    22 #include "termhooks.h"
    23 #include "window.h"
    24 
    25 INLINE_HEADER_BEGIN
    26 
    27 enum vertical_scroll_bar_type
    28 {
    29   vertical_scroll_bar_none,
    30   vertical_scroll_bar_left,
    31   vertical_scroll_bar_right
    32 };
    33 
    34 #ifdef HAVE_WINDOW_SYSTEM
    35 
    36 enum fullscreen_type
    37 {
    38   FULLSCREEN_NONE,
    39   FULLSCREEN_WIDTH     = 0x1,
    40   FULLSCREEN_HEIGHT    = 0x2,
    41   FULLSCREEN_BOTH      = 0x3, /* Not a typo but means "width and height".  */
    42   FULLSCREEN_MAXIMIZED = 0x4,
    43 #ifdef HAVE_NTGUI
    44   FULLSCREEN_WAIT      = 0x8
    45 #endif
    46 };
    47 
    48 enum z_group
    49 {
    50   z_group_none,
    51   z_group_above,
    52   z_group_below,
    53   z_group_above_suspended,
    54 };
    55 
    56 enum internal_border_part
    57   {
    58    INTERNAL_BORDER_NONE,
    59    INTERNAL_BORDER_LEFT_EDGE,
    60    INTERNAL_BORDER_TOP_LEFT_CORNER,
    61    INTERNAL_BORDER_TOP_EDGE,
    62    INTERNAL_BORDER_TOP_RIGHT_CORNER,
    63    INTERNAL_BORDER_RIGHT_EDGE,
    64    INTERNAL_BORDER_BOTTOM_RIGHT_CORNER,
    65    INTERNAL_BORDER_BOTTOM_EDGE,
    66    INTERNAL_BORDER_BOTTOM_LEFT_CORNER,
    67   };
    68 
    69 #ifdef NS_IMPL_COCOA
    70 enum ns_appearance_type
    71   {
    72     ns_appearance_system_default,
    73     ns_appearance_aqua,
    74     ns_appearance_vibrant_dark
    75   };
    76 #endif
    77 #endif /* HAVE_WINDOW_SYSTEM */
    78 
    79 #ifdef HAVE_TEXT_CONVERSION
    80 
    81 enum text_conversion_operation
    82   {
    83     TEXTCONV_START_BATCH_EDIT,
    84     TEXTCONV_END_BATCH_EDIT,
    85     TEXTCONV_COMMIT_TEXT,
    86     TEXTCONV_FINISH_COMPOSING_TEXT,
    87     TEXTCONV_SET_COMPOSING_TEXT,
    88     TEXTCONV_SET_COMPOSING_REGION,
    89     TEXTCONV_SET_POINT_AND_MARK,
    90     TEXTCONV_DELETE_SURROUNDING_TEXT,
    91     TEXTCONV_REQUEST_POINT_UPDATE,
    92     TEXTCONV_BARRIER,
    93   };
    94 
    95 /* Structure describing a single edit being performed by the input
    96    method that should be executed in the context of
    97    kbd_buffer_get_event.  */
    98 
    99 struct text_conversion_action
   100 {
   101   /* The next text conversion action.  */
   102   struct text_conversion_action *next;
   103 
   104   /* Any associated data.  */
   105   Lisp_Object data;
   106 
   107   /* The operation being performed.  */
   108   enum text_conversion_operation operation;
   109 
   110   /* Counter value.  */
   111   unsigned long counter;
   112 };
   113 
   114 /* Structure describing the text conversion state associated with a
   115    frame.  */
   116 
   117 struct text_conversion_state
   118 {
   119   /* List of text conversion actions associated with this frame.  */
   120   struct text_conversion_action *actions;
   121 
   122   /* Markers representing the composing region.  */
   123   Lisp_Object compose_region_start, compose_region_end;
   124 
   125   /* Overlay representing the composing region.  */
   126   Lisp_Object compose_region_overlay;
   127 
   128   /* The number of ongoing ``batch edits'' that are causing point
   129      reporting to be delayed.  */
   130   int batch_edit_count;
   131 
   132   /* Mask containing what must be updated after batch edits end.  */
   133   int batch_edit_flags;
   134 };
   135 
   136 #endif
   137 
   138 /* The structure representing a frame.  */
   139 
   140 struct frame
   141 {
   142   union vectorlike_header header;
   143 
   144   /* All Lisp_Object components must come first.
   145      That ensures they are all aligned normally.  */
   146 
   147   /* Name of this frame: a Lisp string.  It is used for looking up resources,
   148      as well as for the title in some cases.  */
   149   Lisp_Object name;
   150 
   151   /* The name to use for the icon, the last time
   152      it was refreshed.  nil means not explicitly specified.  */
   153   Lisp_Object icon_name;
   154 
   155   /* This is the frame title specified explicitly, if any.
   156      Usually it is nil.  */
   157   Lisp_Object title;
   158 
   159 #if defined (HAVE_WINDOW_SYSTEM)
   160   /* This frame's parent frame, if it has one.  */
   161   Lisp_Object parent_frame;
   162 #endif /* HAVE_WINDOW_SYSTEM */
   163 
   164   /* Last device to move over this frame.  Any value that isn't a
   165      string means the "Virtual core pointer".  */
   166   Lisp_Object last_mouse_device;
   167 
   168   /* The frame which should receive keystrokes that occur in this
   169      frame, or nil if they should go to the frame itself.  This is
   170      usually nil, but if the frame is minibufferless, we can use this
   171      to redirect keystrokes to a surrogate minibuffer frame when
   172      needed.
   173 
   174      Note that a value of nil is different from having the field point
   175      to the frame itself.  Whenever the Fselect_frame function is used
   176      to shift from one frame to the other, any redirections to the
   177      original frame are shifted to the newly selected frame; if
   178      focus_frame is nil, Fselect_frame will leave it alone.  */
   179   Lisp_Object focus_frame;
   180 
   181   /* This frame's root window.  Every frame has one.
   182      If the frame has only a minibuffer window, this is it.
   183      Otherwise, if the frame has a minibuffer window, this is its sibling.  */
   184   Lisp_Object root_window;
   185 
   186   /* This frame's selected window.
   187      Each frame has its own window hierarchy
   188      and one of the windows in it is selected within the frame.
   189      This window may be the mini-window of the frame, if any.
   190      The selected window of the selected frame is Emacs's selected window.  */
   191   Lisp_Object selected_window;
   192 
   193   /* This frame's selected window when run_window_change_functions was
   194      called the last time on this frame.  */
   195   Lisp_Object old_selected_window;
   196 
   197   /* This frame's minibuffer window.
   198      Most frames have their own minibuffer windows,
   199      but only the selected frame's minibuffer window
   200      can actually appear to exist.  */
   201   Lisp_Object minibuffer_window;
   202 
   203   /* Parameter alist of this frame.
   204      These are the parameters specified when creating the frame
   205      or modified with modify-frame-parameters.  */
   206   Lisp_Object param_alist;
   207 
   208   /* List of scroll bars on this frame.
   209      Actually, we don't specify exactly what is stored here at all; the
   210      scroll bar implementation code can use it to store anything it likes.
   211      This field is marked by the garbage collector.  It is here
   212      instead of in the `device' structure so that the garbage
   213      collector doesn't need to look inside the window-system-dependent
   214      structure.  */
   215   Lisp_Object scroll_bars;
   216   Lisp_Object condemned_scroll_bars;
   217 
   218   /* Vector describing the items to display in the menu bar.
   219      Each item has four elements in this vector.
   220      They are KEY, STRING, SUBMAP, and HPOS.
   221      (HPOS is not used in when the X toolkit is in use.)
   222      There are four additional elements of nil at the end, to terminate.  */
   223   Lisp_Object menu_bar_items;
   224 
   225   /* Hash table of FACE-NAME keys and FACE-VECTOR-DATA values.  */
   226   Lisp_Object face_hash_table;
   227 
   228   /* A vector that records the entire structure of this frame's menu bar.
   229      For the format of the data, see extensive comments in xmenu.c.
   230      Only the X toolkit version uses this.  */
   231   Lisp_Object menu_bar_vector;
   232 
   233   /* Predicate for selecting buffers for other-buffer.  */
   234   Lisp_Object buffer_predicate;
   235 
   236   /* List of buffers viewed in this frame, for other-buffer.  */
   237   Lisp_Object buffer_list;
   238 
   239   /* List of buffers that were viewed, then buried in this frame.  The
   240      most recently buried buffer is first.  For last-buffer.  */
   241   Lisp_Object buried_buffer_list;
   242 
   243 #if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
   244   /* A dummy window used to display menu bars under X when no X
   245      toolkit support is available.  */
   246   Lisp_Object menu_bar_window;
   247 #endif
   248 
   249 #if defined (HAVE_WINDOW_SYSTEM)
   250   /* A window used to display the tab-bar of a frame.  */
   251   Lisp_Object tab_bar_window;
   252 
   253   /* Desired and current contents displayed in that window.  */
   254   Lisp_Object desired_tab_bar_string;
   255   Lisp_Object current_tab_bar_string;
   256 #endif
   257 
   258 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   259   /* A window used to display the tool-bar of a frame.  */
   260   Lisp_Object tool_bar_window;
   261 
   262   /* Desired and current contents displayed in that window.  */
   263   Lisp_Object desired_tool_bar_string;
   264   Lisp_Object current_tool_bar_string;
   265 #endif
   266 
   267   /* Where tool bar is, can be left, right, top or bottom.
   268      Except with GTK, the only supported position is `top'.  */
   269   Lisp_Object tool_bar_position;
   270 
   271 #if defined (HAVE_XFT) || defined (HAVE_FREETYPE)
   272   /* List of data specific to font-driver and frame, but common to faces.  */
   273   Lisp_Object font_data;
   274 #endif
   275 
   276   /* Desired and current tab-bar items.  */
   277   Lisp_Object tab_bar_items;
   278 
   279   /* Desired and current tool-bar items.  */
   280   Lisp_Object tool_bar_items;
   281   /* tool_bar_items should be the last Lisp_Object member.  */
   282 
   283   /* Cache of realized faces.  */
   284   struct face_cache *face_cache;
   285 
   286   /* Tab-bar item index of the item on which a mouse button was pressed.  */
   287   int last_tab_bar_item;
   288 
   289 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   290   /* Tool-bar item index of the item on which a mouse button was pressed.  */
   291   int last_tool_bar_item;
   292 #endif
   293 
   294   /* Number of elements in `menu_bar_vector' that have meaningful data.  */
   295   int menu_bar_items_used;
   296 
   297 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)
   298   /* A buffer to hold the frame's name.  Since this is used by the
   299      window system toolkit, we can't use the Lisp string's pointer
   300      (`name', above) because it might get relocated.  */
   301   char *namebuf;
   302 #endif
   303 
   304 #ifdef USE_X_TOOLKIT
   305   /* Used to pass geometry parameters to toolkit functions.  */
   306   char *shell_position;
   307 #endif
   308 
   309   /* Glyph pool and matrix.  */
   310   struct glyph_pool *current_pool;
   311   struct glyph_pool *desired_pool;
   312   struct glyph_matrix *desired_matrix;
   313   struct glyph_matrix *current_matrix;
   314 
   315   /* Bitfield area begins here.  Keep them together to avoid extra padding.  */
   316 
   317   /* True means that glyphs on this frame have been initialized so it can
   318      be used for output.  */
   319   bool_bf glyphs_initialized_p : 1;
   320 
   321   /* Set to true in adjust_frame_size when one of the frame's sizes
   322      changed.  Clear the frame in clear_garbaged_frames if set.  */
   323   bool_bf resized_p : 1;
   324 
   325   /* Set to true if the default face for the frame has been
   326      realized.  Reset to zero whenever the default face changes.
   327      Used to see the difference between a font change and face change.  */
   328   bool_bf default_face_done_p : 1;
   329 
   330   /* Set to true if this frame has already been hscrolled during
   331      current redisplay.  */
   332   bool_bf already_hscrolled_p : 1;
   333 
   334   /* Set to true when current redisplay has updated frame.  */
   335   bool_bf updated_p : 1;
   336 
   337 #if defined (HAVE_WINDOW_SYSTEM)
   338   /* Set to true to minimize tab-bar height even when
   339      auto-resize-tab-bar is set to grow-only.  */
   340   bool_bf minimize_tab_bar_window_p : 1;
   341 #endif
   342 
   343 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   344   /* Set to true to minimize tool-bar height even when
   345      auto-resize-tool-bar is set to grow-only.  */
   346   bool_bf minimize_tool_bar_window_p : 1;
   347 
   348   /* Whether or not the tool bar contains a ``new line'' item.  If
   349      true, tool bar rows will be allowed to differ in height.  */
   350   bool_bf tool_bar_wraps_p : 1;
   351 #endif
   352 
   353 #ifdef HAVE_EXT_TOOL_BAR
   354   /* True means using a tool bar that comes from the toolkit.  */
   355   bool_bf external_tool_bar : 1;
   356 #endif
   357 
   358   /* True means that fonts have been loaded since the last glyph
   359      matrix adjustments.  */
   360   bool_bf fonts_changed : 1;
   361 
   362   /* True means that cursor type has been changed.  */
   363   bool_bf cursor_type_changed : 1;
   364 
   365   /* True if it needs to be redisplayed.  */
   366   bool_bf redisplay : 1;
   367 
   368 #ifdef HAVE_EXT_MENU_BAR
   369   /* True means using a menu bar that comes from the toolkit.  */
   370   bool_bf external_menu_bar : 1;
   371 #endif
   372 
   373   /* Next two bitfields are mutually exclusive.  They might both be
   374      zero if the frame has been made invisible without an icon.  */
   375 
   376   /* Nonzero if the frame is currently displayed; we check
   377      it to see if we should bother updating the frame's contents.
   378 
   379      On ttys and on Windows NT/9X, to avoid wasting effort updating
   380      visible frames that are actually completely obscured by other
   381      windows on the display, we bend the meaning of visible slightly:
   382      if equal to 2, then the frame is obscured - we still consider
   383      it to be "visible" as seen from lisp, but we don't bother
   384      updating it.  */
   385   unsigned visible : 2;
   386 
   387   /* True if the frame is currently iconified.  Do not
   388      set this directly, use SET_FRAME_ICONIFIED instead.  */
   389   bool_bf iconified : 1;
   390 
   391   /* True if this frame should be fully redisplayed.  Disables all
   392      optimizations while rebuilding matrices and redrawing.  */
   393   bool_bf garbaged : 1;
   394 
   395   /* False means, if this frame has just one window,
   396      show no modeline for that window.  */
   397   bool_bf wants_modeline : 1;
   398 
   399   /* True means raise this frame to the top of the heap when selected.  */
   400   bool_bf auto_raise : 1;
   401 
   402   /* True means lower this frame to the bottom of the stack when left.  */
   403   bool_bf auto_lower : 1;
   404 
   405   /* True if frame's root window can't be split.  */
   406   bool_bf no_split : 1;
   407 
   408   /* If this is set, then Emacs won't change the frame name to indicate
   409      the current buffer, etcetera.  If the user explicitly sets the frame
   410      name, this gets set.  If the user sets the name to Qnil, this is
   411      cleared.  */
   412   bool_bf explicit_name : 1;
   413 
   414   /* True if at least one window on this frame changed since the last
   415      call of run_window_change_functions.  Changes are either "state
   416      changes" (a window has been created, deleted or got assigned
   417      another buffer) or "size changes" (the total or body size of a
   418      window changed).  run_window_change_functions exits early unless
   419      either this flag is true or a window selection happened on this
   420      frame.  */
   421   bool_bf window_change : 1;
   422 
   423   /* True if running window state change functions has been explicitly
   424      requested for this frame since last redisplay.  */
   425   bool_bf window_state_change : 1;
   426 
   427   /* True if the mouse has moved on this display device
   428      since the last time we checked.  */
   429   bool_bf mouse_moved : 1;
   430 
   431   /* True means that the pointer is invisible.  */
   432   bool_bf pointer_invisible : 1;
   433 
   434   /* True means that all windows except mini-window and
   435      selected window on this frame have frozen window starts.  */
   436   bool_bf frozen_window_starts : 1;
   437 
   438   /* The output method says how the contents of this frame are
   439      displayed.  It could be using termcap, or using an X window.
   440      This must be the same as the terminal->type. */
   441   ENUM_BF (output_method) output_method : 4;
   442 
   443 #ifdef HAVE_WINDOW_SYSTEM
   444   /* True if this frame is a tooltip frame.  */
   445   bool_bf tooltip : 1;
   446 
   447   /* See FULLSCREEN_ enum on top.  */
   448   ENUM_BF (fullscreen_type) want_fullscreen : 4;
   449 
   450   /* If not vertical_scroll_bar_none, we should actually
   451      display the scroll bars of this type on this frame.  */
   452   ENUM_BF (vertical_scroll_bar_type) vertical_scroll_bar_type : 2;
   453 
   454   /* Nonzero if we should actually display horizontal scroll bars on this frame.  */
   455   bool_bf horizontal_scroll_bars : 1;
   456 
   457   /* True if this is an undecorated frame.  */
   458   bool_bf undecorated : 1;
   459 
   460 #ifndef HAVE_NTGUI
   461   /* True if this is an override_redirect frame.  */
   462   bool_bf override_redirect : 1;
   463 #endif
   464 
   465   /* Nonzero if this frame's icon should not appear on its display's taskbar.  */
   466   bool_bf skip_taskbar : 1;
   467 
   468   /* Nonzero if this frame's window F's X window does not want to
   469      receive input focus when it is mapped.  */
   470   bool_bf no_focus_on_map : 1;
   471 
   472   /* Nonzero if this frame's window does not want to receive input focus
   473      via mouse clicks or by moving the mouse into it.  */
   474   bool_bf no_accept_focus : 1;
   475 
   476   /* The z-group this frame's window belongs to. */
   477   ENUM_BF (z_group) z_group : 2;
   478 
   479   /* Non-zero if display of truncation and continuation glyphs outside
   480      the fringes is suppressed.  */
   481   bool_bf no_special_glyphs : 1;
   482 #endif /* HAVE_WINDOW_SYSTEM */
   483 
   484   /* True means set_window_size_hook requests can be processed for
   485      this frame.  */
   486   bool_bf can_set_window_size : 1;
   487 
   488   /* Set to true after this frame was made by `make-frame'.  */
   489   bool_bf after_make_frame : 1;
   490 
   491   /* Two sticky flags, that are both false when a frame is created.
   492      'display_tab_bar' sets the former to true the first time it
   493      displays the tab bar.  When the former is true, the next call of
   494      'x_change_tab_bar_height' and associates sets the latter true and
   495      tries to adjust the frame height in a way that the now valid pixel
   496      height of the tab bar is taken into account by the frame's native
   497      height.  */
   498   bool_bf tab_bar_redisplayed : 1;
   499   bool_bf tab_bar_resized : 1;
   500 
   501   /* Two sticky flags, that are both false when a frame is created.
   502      'redisplay_tool_bar' sets the former to true the first time it
   503      displays the tool bar.  When the former is true, the next call of
   504      'x_change_tool_bar_height' and associates sets the latter true and
   505      tries to adjust the frame height in a way that the now valid pixel
   506      height of the tool bar is taken into account by the frame's native
   507      height.  */
   508   bool_bf tool_bar_redisplayed : 1;
   509   bool_bf tool_bar_resized : 1;
   510 
   511   /* Inhibit implied resize before after_make_frame is set.  */
   512   bool_bf inhibit_horizontal_resize : 1;
   513   bool_bf inhibit_vertical_resize : 1;
   514 
   515   /* Non-zero if this frame's faces need to be recomputed.  */
   516   bool_bf face_change : 1;
   517 
   518   /* Non-zero if this frame's image cache and face cache cannot be
   519      freed because the frame is in the process of being redisplayed.  */
   520   bool_bf inhibit_clear_image_cache : 1;
   521 
   522   /* True when new_width or new_height were set by change_frame_size,
   523      false when they were set by adjust_frame_size internally or not
   524      set.  */
   525   bool_bf new_size_p : 1;
   526 
   527   /* True when frame was invisible before first MapNotify event.  Used
   528      in X builds only.  */
   529   bool_bf was_invisible : 1;
   530 
   531   /* True when the frame isn't selected, and selecting it in the
   532      future should select the mini-window rather than the currently
   533      selected window in the frame, assuming there is still an active
   534      minibuffer in that mini-window.  */
   535   bool_bf select_mini_window_flag : 1;
   536   /* Bitfield area ends here.  */
   537 
   538   /* This frame's change stamp, set the last time window change
   539      functions were run for this frame.  Should never be 0 because
   540      that's the change stamp of a new window.  A window was not on a
   541      frame the last run_window_change_functions was called on it if
   542      it's change stamp differs from that of its frame.  */
   543   int change_stamp;
   544 
   545   /* This frame's number of windows, set the last time window change
   546      functions were run for this frame.  Should never be 0 even for
   547      minibuffer-only frames.  If no window has been added, this allows
   548      to detect whether a window was deleted on this frame since the
   549      last time run_window_change_functions was called on it.  */
   550   ptrdiff_t number_of_windows;
   551 
   552   /* Number of frame lines (rounded up) of tab bar.  */
   553   int tab_bar_lines;
   554 
   555   /* Height of frame internal tab bar in pixels.  */
   556   int tab_bar_height;
   557 
   558   int n_tab_bar_rows;
   559   int n_tab_bar_items;
   560 
   561   /* Number of frame lines (rounded up) of tool bar.  */
   562   int tool_bar_lines;
   563 
   564   /* Height of frame internal tool bar in pixels.  */
   565   int tool_bar_height;
   566 
   567   int n_tool_bar_rows;
   568   int n_tool_bar_items;
   569 
   570   /* A buffer for decode_mode_line.  */
   571   char *decode_mode_spec_buffer;
   572 
   573   /* See do_line_insertion_deletion_costs for info on these arrays.  */
   574   /* Cost of inserting 1 line on this frame.  */
   575   int *insert_line_cost;
   576   /* Cost of deleting 1 line on this frame.  */
   577   int *delete_line_cost;
   578   /* Cost of inserting n lines on this frame.  */
   579   int *insert_n_lines_cost;
   580   /* Cost of deleting n lines on this frame.  */
   581   int *delete_n_lines_cost;
   582 
   583   /* Text width and height of this frame in (and maybe rounded to) frame
   584      columns and lines.  */
   585   int text_cols, text_lines;
   586   /* Text width and height of this frame in pixels.  */
   587   int text_width, text_height;
   588 
   589   /* Native width of this frame in (and maybe rounded to) frame columns
   590      and lines.  */
   591   int total_cols, total_lines;
   592   /* Native width and height of this frame in pixels.  */
   593   int pixel_width, pixel_height;
   594   /* New native width and height of this frame for pending size change,
   595      in pixels.  -1 if no change pending.  */
   596   int new_width, new_height;
   597 
   598   /* Pixel position of the frame window (x and y offsets in root window).  */
   599   int left_pos, top_pos;
   600 
   601   /* This is the gravity value for the specified window position.  */
   602   int win_gravity;
   603 
   604   /* The geometry flags for this window.  */
   605   int size_hint_flags;
   606 
   607   /* Border width of the frame window as known by the (X) window system.  */
   608   int border_width;
   609 
   610   /* Width of child frames' internal border.  Acts as
   611      internal_border_width for child frames.  */
   612   int child_frame_border_width;
   613 
   614   /* Width of the internal border.  This is a line of background color
   615      just inside the window's border.  When the frame is selected,
   616      a highlighting is displayed inside the internal border.  */
   617   int internal_border_width;
   618 
   619   /* Widths of dividers between this frame's windows in pixels.  */
   620   int right_divider_width, bottom_divider_width;
   621 
   622   /* Widths of fringes in pixels.  */
   623   int left_fringe_width, right_fringe_width;
   624 
   625   /* Total width of fringes reserved for drawing truncation bitmaps,
   626      continuation bitmaps and alike - REMOVE THIS !!!!.    */
   627   int fringe_cols;
   628 
   629   /* Number of lines of menu bar.  */
   630   int menu_bar_lines;
   631 
   632   /* Pixel height of menubar.  */
   633   int menu_bar_height;
   634 
   635   /* Canonical X unit.  Width of default font, in pixels.  */
   636   int column_width;
   637 
   638   /* Canonical Y unit.  Height of a line, in pixels.  */
   639   int line_height;
   640 
   641   /* The terminal device that this frame uses.  If this is NULL, then
   642      the frame has been deleted.  */
   643   struct terminal *terminal;
   644 
   645   /* Device-dependent, frame-local auxiliary data used for displaying
   646      the contents.  When the frame is deleted, this data is deleted as
   647      well.  */
   648   union output_data
   649   {
   650     struct tty_output *tty;             /* From termchar.h.  */
   651     struct x_output *x;                 /* From xterm.h.  */
   652     struct w32_output *w32;             /* From w32term.h.  */
   653     struct ns_output *ns;               /* From nsterm.h.  */
   654     struct pgtk_output *pgtk;           /* From pgtkterm.h. */
   655     struct haiku_output *haiku;         /* From haikuterm.h. */
   656     struct android_output *android;     /* From androidterm.h.  */
   657   }
   658   output_data;
   659 
   660   /* List of font-drivers available on the frame.  */
   661   struct font_driver_list *font_driver_list;
   662 
   663 #if defined HAVE_X_WINDOWS || defined HAVE_ANDROID
   664   /* Used by x_wait_for_event when watching for an X event on this
   665      frame.  */
   666   int wait_event_type;
   667 #endif
   668 
   669   /* What kind of text cursor should we draw in the future?
   670      This should always be filled_box_cursor or bar_cursor.  */
   671   enum text_cursor_kinds desired_cursor;
   672 
   673   /* Width of bar cursor (if we are using that).  */
   674   int cursor_width;
   675 
   676   /* What kind of text cursor should we draw when the cursor blinks off?
   677      This can be filled_box_cursor or bar_cursor or no_cursor.  */
   678   enum text_cursor_kinds blink_off_cursor;
   679 
   680   /* Width of bar cursor (if we are using that) for blink-off state.  */
   681   int blink_off_cursor_width;
   682 
   683   /* Configured width of the scroll bar, in pixels and in characters.
   684      config_scroll_bar_cols tracks config_scroll_bar_width if the
   685      latter is positive; a zero value in config_scroll_bar_width means
   686      to compute the actual width on the fly, using config_scroll_bar_cols
   687      and the current font width.  */
   688   int config_scroll_bar_width;
   689   int config_scroll_bar_cols;
   690 
   691   /* Configured height of the scroll bar, in pixels and in characters.
   692      config_scroll_bar_lines tracks config_scroll_bar_height if the
   693      latter is positive; a zero value in config_scroll_bar_height means
   694      to compute the actual width on the fly, using
   695      config_scroll_bar_lines and the current font width.  */
   696   int config_scroll_bar_height;
   697   int config_scroll_bar_lines;
   698 
   699   /* The baud rate that was used to calculate costs for this frame.  */
   700   intmax_t cost_calculation_baud_rate;
   701 
   702   /* Frame opacity
   703      alpha[0]: alpha transparency of the active frame
   704      alpha[1]: alpha transparency of inactive frames
   705      Negative values mean not to change alpha.  */
   706   double alpha[2];
   707 
   708   /* Background opacity */
   709   double alpha_background;
   710 
   711   /* Exponent for gamma correction of colors.  1/(VIEWING_GAMMA *
   712      SCREEN_GAMMA) where viewing_gamma is 0.4545 and SCREEN_GAMMA is a
   713      frame parameter.  0 means don't do gamma correction.  */
   714   double gamma;
   715 
   716   /* Additional space to put between text lines on this frame.  */
   717   int extra_line_spacing;
   718 
   719   /* All display backends seem to need these two pixel values.  */
   720   unsigned long background_pixel;
   721   unsigned long foreground_pixel;
   722 
   723 #ifdef NS_IMPL_COCOA
   724   /* NSAppearance theme used on this frame.  */
   725   enum ns_appearance_type ns_appearance;
   726   bool_bf ns_transparent_titlebar;
   727 #endif
   728 
   729 #ifdef HAVE_TEXT_CONVERSION
   730   /* Text conversion state used by certain input methods.  */
   731   struct text_conversion_state conversion;
   732 #endif
   733 } GCALIGNED_STRUCT;
   734 
   735 /* Most code should use these functions to set Lisp fields in struct frame.  */
   736 
   737 INLINE void
   738 fset_buffer_list (struct frame *f, Lisp_Object val)
   739 {
   740   f->buffer_list = val;
   741 }
   742 INLINE void
   743 fset_buried_buffer_list (struct frame *f, Lisp_Object val)
   744 {
   745   f->buried_buffer_list = val;
   746 }
   747 INLINE void
   748 fset_condemned_scroll_bars (struct frame *f, Lisp_Object val)
   749 {
   750   f->condemned_scroll_bars = val;
   751 }
   752 INLINE void
   753 fset_face_hash_table (struct frame *f, Lisp_Object val)
   754 {
   755   f->face_hash_table = val;
   756 }
   757 #if defined (HAVE_WINDOW_SYSTEM)
   758 INLINE void
   759 fset_parent_frame (struct frame *f, Lisp_Object val)
   760 {
   761   f->parent_frame = val;
   762 }
   763 #endif
   764 INLINE void
   765 fset_focus_frame (struct frame *f, Lisp_Object val)
   766 {
   767   f->focus_frame = val;
   768 }
   769 INLINE void
   770 fset_icon_name (struct frame *f, Lisp_Object val)
   771 {
   772   f->icon_name = val;
   773 }
   774 INLINE void
   775 fset_menu_bar_items (struct frame *f, Lisp_Object val)
   776 {
   777   f->menu_bar_items = val;
   778 }
   779 INLINE void
   780 fset_menu_bar_vector (struct frame *f, Lisp_Object val)
   781 {
   782   f->menu_bar_vector = val;
   783 }
   784 #if defined HAVE_WINDOW_SYSTEM && !defined HAVE_EXT_MENU_BAR
   785 INLINE void
   786 fset_menu_bar_window (struct frame *f, Lisp_Object val)
   787 {
   788   f->menu_bar_window = val;
   789 }
   790 #endif
   791 INLINE void
   792 fset_name (struct frame *f, Lisp_Object val)
   793 {
   794   f->name = val;
   795 }
   796 INLINE void
   797 fset_param_alist (struct frame *f, Lisp_Object val)
   798 {
   799   f->param_alist = val;
   800 }
   801 INLINE void
   802 fset_root_window (struct frame *f, Lisp_Object val)
   803 {
   804   f->root_window = val;
   805 }
   806 INLINE void
   807 fset_scroll_bars (struct frame *f, Lisp_Object val)
   808 {
   809   f->scroll_bars = val;
   810 }
   811 INLINE void
   812 fset_selected_window (struct frame *f, Lisp_Object val)
   813 {
   814   f->selected_window = val;
   815 }
   816 INLINE void
   817 fset_old_selected_window (struct frame *f, Lisp_Object val)
   818 {
   819   f->old_selected_window = val;
   820 }
   821 INLINE void
   822 fset_title (struct frame *f, Lisp_Object val)
   823 {
   824   f->title = val;
   825 }
   826 INLINE void
   827 fset_tab_bar_items (struct frame *f, Lisp_Object val)
   828 {
   829   f->tab_bar_items = val;
   830 }
   831 #if defined (HAVE_WINDOW_SYSTEM)
   832 INLINE void
   833 fset_tab_bar_window (struct frame *f, Lisp_Object val)
   834 {
   835   f->tab_bar_window = val;
   836 }
   837 INLINE void
   838 fset_current_tab_bar_string (struct frame *f, Lisp_Object val)
   839 {
   840   f->current_tab_bar_string = val;
   841 }
   842 INLINE void
   843 fset_desired_tab_bar_string (struct frame *f, Lisp_Object val)
   844 {
   845   f->desired_tab_bar_string = val;
   846 }
   847 #endif /* HAVE_WINDOW_SYSTEM */
   848 INLINE void
   849 fset_tool_bar_items (struct frame *f, Lisp_Object val)
   850 {
   851   f->tool_bar_items = val;
   852 }
   853 
   854 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   855 
   856 INLINE void
   857 fset_tool_bar_window (struct frame *f, Lisp_Object val)
   858 {
   859   f->tool_bar_window = val;
   860 }
   861 INLINE void
   862 fset_current_tool_bar_string (struct frame *f, Lisp_Object val)
   863 {
   864   f->current_tool_bar_string = val;
   865 }
   866 INLINE void
   867 fset_desired_tool_bar_string (struct frame *f, Lisp_Object val)
   868 {
   869   f->desired_tool_bar_string = val;
   870 }
   871 
   872 #endif /* HAVE_WINDOW_SYSTEM && !HAVE_EXT_TOOL_BAR */
   873 
   874 INLINE void
   875 fset_tool_bar_position (struct frame *f, Lisp_Object val)
   876 {
   877   f->tool_bar_position = val;
   878 }
   879 
   880 INLINE double
   881 NUMVAL (Lisp_Object x)
   882 {
   883   return NUMBERP (x) ? XFLOATINT (x) : -1;
   884 }
   885 
   886 INLINE double
   887 default_pixels_per_inch_x (void)
   888 {
   889   Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
   890                    ? XCAR (Vdisplay_pixels_per_inch)
   891                    : Vdisplay_pixels_per_inch);
   892   return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
   893 }
   894 
   895 INLINE double
   896 default_pixels_per_inch_y (void)
   897 {
   898   Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
   899                    ? XCDR (Vdisplay_pixels_per_inch)
   900                    : Vdisplay_pixels_per_inch);
   901   return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
   902 }
   903 
   904 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
   905 
   906 /* Return a pointer to the image cache of frame F.  */
   907 #define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
   908 
   909 #define XFRAME(p) \
   910   (eassert (FRAMEP (p)), XUNTAG (p, Lisp_Vectorlike, struct frame))
   911 #define XSETFRAME(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_FRAME))
   912 
   913 /* Given a window, return its frame as a Lisp_Object.  */
   914 #define WINDOW_FRAME(w) ((w)->frame)
   915 
   916 /* Test a frame for particular kinds of display methods.  */
   917 #define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
   918 #define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
   919 #define FRAME_X_P(f) ((f)->output_method == output_x_window)
   920 #ifndef HAVE_NTGUI
   921 #define FRAME_W32_P(f) false
   922 #else
   923 #define FRAME_W32_P(f) ((f)->output_method == output_w32)
   924 #endif
   925 #ifndef MSDOS
   926 #define FRAME_MSDOS_P(f) false
   927 #else
   928 #define FRAME_MSDOS_P(f) ((f)->output_method == output_msdos_raw)
   929 #endif
   930 #ifndef HAVE_NS
   931 #define FRAME_NS_P(f) false
   932 #else
   933 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
   934 #endif
   935 #ifndef HAVE_PGTK
   936 #define FRAME_PGTK_P(f) false
   937 #else
   938 #define FRAME_PGTK_P(f) ((f)->output_method == output_pgtk)
   939 #endif
   940 #ifndef HAVE_HAIKU
   941 #define FRAME_HAIKU_P(f) false
   942 #else
   943 #define FRAME_HAIKU_P(f) ((f)->output_method == output_haiku)
   944 #endif
   945 #ifndef HAVE_ANDROID
   946 #define FRAME_ANDROID_P(f) false
   947 #else
   948 #define FRAME_ANDROID_P(f) ((f)->output_method == output_android)
   949 #endif
   950 
   951 /* FRAME_WINDOW_P tests whether the frame is a graphical window system
   952    frame.  */
   953 #ifdef HAVE_X_WINDOWS
   954 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
   955 #endif
   956 #ifdef HAVE_NTGUI
   957 #define FRAME_WINDOW_P(f) FRAME_W32_P (f)
   958 #endif
   959 #ifdef HAVE_NS
   960 #define FRAME_WINDOW_P(f) FRAME_NS_P(f)
   961 #endif
   962 #ifdef HAVE_PGTK
   963 #define FRAME_WINDOW_P(f) FRAME_PGTK_P(f)
   964 #endif
   965 #ifdef HAVE_HAIKU
   966 #define FRAME_WINDOW_P(f) FRAME_HAIKU_P (f)
   967 #endif
   968 #ifdef HAVE_ANDROID
   969 #define FRAME_WINDOW_P(f) FRAME_ANDROID_P (f)
   970 #endif
   971 #ifndef FRAME_WINDOW_P
   972 #define FRAME_WINDOW_P(f) ((void) (f), false)
   973 #endif
   974 
   975 /* Dots per inch of the screen the frame F is on.  */
   976 
   977 #ifdef HAVE_WINDOW_SYSTEM
   978 
   979 #define FRAME_RES_X(f)                                          \
   980   (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resx)
   981 #define FRAME_RES_Y(f)                                          \
   982   (eassert (FRAME_WINDOW_P (f)), FRAME_DISPLAY_INFO (f)->resy)
   983 
   984 #ifdef HAVE_ANDROID
   985 
   986 /* Android systems use a font scaling factor independent from the
   987    display DPI.  */
   988 
   989 #define FRAME_RES(f)                                            \
   990   (eassert (FRAME_WINDOW_P (f)),                                \
   991    FRAME_DISPLAY_INFO (f)->font_resolution)
   992 
   993 #else /* !HAVE_ANDROID */
   994 #define FRAME_RES(f) (FRAME_RES_Y (f))
   995 #endif /* HAVE_ANDROID */
   996 
   997 #else /* !HAVE_WINDOW_SYSTEM */
   998 
   999 /* Defaults when no window system available.  */
  1000 
  1001 #define FRAME_RES_X(f)  default_pixels_per_inch_x ()
  1002 #define FRAME_RES_Y(f)  default_pixels_per_inch_y ()
  1003 #define FRAME_RES(f)    default_pixels_per_inch_y ()
  1004 
  1005 #endif /* HAVE_WINDOW_SYSTEM */
  1006 
  1007 /* Return a pointer to the structure holding information about the
  1008    region of text, if any, that is currently shown in mouse-face on
  1009    frame F.  We need to define two versions because a TTY-only build
  1010    does not have FRAME_DISPLAY_INFO.  */
  1011 #ifdef HAVE_WINDOW_SYSTEM
  1012 #ifndef HAVE_ANDROID
  1013 # define MOUSE_HL_INFO(F)                                       \
  1014   (FRAME_WINDOW_P (F)                                           \
  1015    ? &FRAME_DISPLAY_INFO(F)->mouse_highlight                    \
  1016    : &(F)->output_data.tty->display_info->mouse_highlight)
  1017 #else
  1018 /* There is no "struct tty_output" on Android at all.  */
  1019 # define MOUSE_HL_INFO(F)                                       \
  1020   (&FRAME_DISPLAY_INFO(F)->mouse_highlight)
  1021 #endif
  1022 #else
  1023 # define MOUSE_HL_INFO(F)                                       \
  1024   (&(F)->output_data.tty->display_info->mouse_highlight)
  1025 #endif
  1026 
  1027 /* True if frame F is still alive (not deleted).  */
  1028 #define FRAME_LIVE_P(f) ((f)->terminal != 0)
  1029 
  1030 /* True if frame F is a minibuffer-only frame.  */
  1031 #define FRAME_MINIBUF_ONLY_P(f) \
  1032   EQ (FRAME_ROOT_WINDOW (f), FRAME_MINIBUF_WINDOW (f))
  1033 
  1034 /* True if frame F contains it's own minibuffer window.  Frame always has
  1035    minibuffer window, but it could use minibuffer window of another frame.  */
  1036 #define FRAME_HAS_MINIBUF_P(f)                                  \
  1037   (WINDOWP (f->minibuffer_window)                               \
  1038    && XFRAME (XWINDOW (f->minibuffer_window)->frame) == f)
  1039 
  1040 /* Scale factor of frame F.  */
  1041 #if defined HAVE_NS
  1042 # define FRAME_SCALE_FACTOR(f) (FRAME_NS_P (f) ? ns_frame_scale_factor (f) : 1)
  1043 #elif defined HAVE_PGTK
  1044 # define FRAME_SCALE_FACTOR(f) (FRAME_PGTK_P (f) ? pgtk_frame_scale_factor (f) : 1)
  1045 #else
  1046 # define FRAME_SCALE_FACTOR(f) 1
  1047 #endif
  1048 
  1049 /* Native width and height of frame F, in pixels and frame
  1050    columns/lines.  */
  1051 #define FRAME_PIXEL_WIDTH(f) ((f)->pixel_width)
  1052 #define FRAME_PIXEL_HEIGHT(f) ((f)->pixel_height)
  1053 #define FRAME_TOTAL_COLS(f) ((f)->total_cols)
  1054 #define FRAME_TOTAL_LINES(f) ((f)->total_lines)
  1055 
  1056 /* Text width and height of frame F, in pixels and frame
  1057    columns/lines.  */
  1058 #define FRAME_TEXT_WIDTH(f) (f)->text_width
  1059 #define FRAME_TEXT_HEIGHT(f) (f)->text_height
  1060 #define FRAME_COLS(f) ((f)->text_cols)
  1061 #define FRAME_LINES(f) ((f)->text_lines)
  1062 
  1063 /* True if this frame should display an external menu bar.  */
  1064 #ifdef HAVE_EXT_MENU_BAR
  1065 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
  1066 #else
  1067 #define FRAME_EXTERNAL_MENU_BAR(f) false
  1068 #endif
  1069 
  1070 /* Size of frame F's internal menu bar in frame lines and pixels.  */
  1071 #define FRAME_MENU_BAR_LINES(f) (f)->menu_bar_lines
  1072 #define FRAME_MENU_BAR_HEIGHT(f) (f)->menu_bar_height
  1073 
  1074 /* Size of frame F's tab bar in frame lines and pixels.  */
  1075 #define FRAME_TAB_BAR_LINES(f) (f)->tab_bar_lines
  1076 #define FRAME_TAB_BAR_HEIGHT(f) (f)->tab_bar_height
  1077 
  1078 /* True if this frame should display an external tool bar.  */
  1079 #ifdef HAVE_EXT_TOOL_BAR
  1080 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
  1081 #else
  1082 #define FRAME_EXTERNAL_TOOL_BAR(f) false
  1083 #endif
  1084 
  1085 /* Position of F's tool bar; one of Qtop, Qleft, Qright, or
  1086    Qbottom.
  1087 
  1088    Qleft and Qright are not supported outside GTK+.  */
  1089 #define FRAME_TOOL_BAR_POSITION(f) (f)->tool_bar_position
  1090 
  1091 /* Size of frame F's internal tool bar in frame lines and pixels.  */
  1092 #define FRAME_TOOL_BAR_LINES(f) (f)->tool_bar_lines
  1093 #define FRAME_TOOL_BAR_HEIGHT(f) (f)->tool_bar_height
  1094 
  1095 /* Size of F's tool bar if it is placed at the top of the
  1096    frame, else 0.  */
  1097 
  1098 #define FRAME_TOOL_BAR_TOP_HEIGHT(f)                    \
  1099   ((BASE_EQ ((f)->tool_bar_position, Qtop))             \
  1100    ? (f)->tool_bar_height : 0)
  1101 
  1102 #define FRAME_TOOL_BAR_TOP_LINES(f)                     \
  1103   ((BASE_EQ ((f)->tool_bar_position, Qtop))             \
  1104    ? (f)->tool_bar_lines : 0)
  1105 
  1106 /* Size of F's tool bar if it is placed at the bottom of the
  1107    frame.  */
  1108 #define FRAME_TOOL_BAR_BOTTOM_HEIGHT(f)                 \
  1109   ((BASE_EQ ((f)->tool_bar_position, Qbottom))          \
  1110    ? (f)->tool_bar_height : 0)
  1111 
  1112 #define FRAME_TOOL_BAR_BOTTOM_LINES(f)                  \
  1113   ((BASE_EQ ((f)->tool_bar_position, Qbottom))          \
  1114    ? (f)->tool_bar_lines : 0)
  1115 
  1116 /* Height of frame F's top margin in frame lines.  */
  1117 #define FRAME_TOP_MARGIN(F)                     \
  1118   (FRAME_MENU_BAR_LINES (F)                     \
  1119    + FRAME_TAB_BAR_LINES (F)                    \
  1120    + FRAME_TOOL_BAR_TOP_LINES (F))
  1121 
  1122 /* Pixel height of frame F's top margin.  */
  1123 
  1124 #define FRAME_TOP_MARGIN_HEIGHT(F)              \
  1125   (FRAME_MENU_BAR_HEIGHT (F)                    \
  1126    + FRAME_TAB_BAR_HEIGHT (F)                   \
  1127    + FRAME_TOOL_BAR_TOP_HEIGHT (F))
  1128 
  1129 /* Height of F's bottom margin in frame lines.  */
  1130 
  1131 #define FRAME_BOTTOM_MARGIN(f)                  \
  1132   (FRAME_TOOL_BAR_BOTTOM_LINES (f))
  1133 
  1134 /* Pixel height of frame F's bottom margin.  */
  1135 
  1136 #define FRAME_BOTTOM_MARGIN_HEIGHT(f)           \
  1137   (FRAME_TOOL_BAR_BOTTOM_HEIGHT (f))
  1138 
  1139 /* Size of both vertical margins combined.  */
  1140 
  1141 #define FRAME_MARGINS(F)                        \
  1142   (FRAME_MENU_BAR_LINES (F)                     \
  1143    + FRAME_TAB_BAR_LINES (F)                    \
  1144    + FRAME_TOOL_BAR_LINES (F))
  1145 
  1146 #define FRAME_MARGIN_HEIGHT(F)                  \
  1147   (FRAME_MENU_BAR_HEIGHT (F)                    \
  1148    + FRAME_TAB_BAR_HEIGHT (F)                   \
  1149    + FRAME_TOOL_BAR_HEIGHT (F))
  1150 
  1151 /* True if frame F is currently visible.  */
  1152 #define FRAME_VISIBLE_P(f) (f)->visible
  1153 
  1154 /* True if frame F should be redisplayed.  This is normally the same
  1155    as FRAME_VISIBLE_P (f).  Under X, frames can continue to be
  1156    displayed to the user by the compositing manager even if they are
  1157    invisible, so this also checks whether or not the frame is reported
  1158    visible by the X server.  */
  1159 
  1160 #ifndef HAVE_X_WINDOWS
  1161 #define FRAME_REDISPLAY_P(f) (FRAME_VISIBLE_P (f))
  1162 #else
  1163 #define FRAME_REDISPLAY_P(f) (FRAME_VISIBLE_P (f)               \
  1164                               || (FRAME_X_P (f)                 \
  1165                                   && FRAME_X_VISIBLE (f)))
  1166 #endif
  1167 
  1168 /* True if frame F is currently visible but hidden.  */
  1169 #define FRAME_OBSCURED_P(f) ((f)->visible > 1)
  1170 
  1171 /* True if frame F is currently iconified.  */
  1172 #define FRAME_ICONIFIED_P(f) (f)->iconified
  1173 
  1174 /* Mark frame F as currently garbaged.  */
  1175 #define SET_FRAME_GARBAGED(f)                           \
  1176   (frame_garbaged = true, fset_redisplay (f), f->garbaged = true)
  1177 
  1178 /* True if frame F is currently garbaged.  */
  1179 #define FRAME_GARBAGED_P(f) (f)->garbaged
  1180 
  1181 /* True means do not allow splitting this frame's window.  */
  1182 #define FRAME_NO_SPLIT_P(f) (f)->no_split
  1183 
  1184 /* Not really implemented.  */
  1185 #define FRAME_WANTS_MODELINE_P(f) (f)->wants_modeline
  1186 
  1187 /* True if all windows except selected window and mini window
  1188    are frozen on frame F.  */
  1189 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
  1190 
  1191 /* True if at least one window changed on frame F since the last time
  1192    window change functions were run on F.  */
  1193 #define FRAME_WINDOW_CHANGE(f) (f)->window_change
  1194 
  1195 /* True if running window state change functions has been explicitly
  1196    requested for this frame since last redisplay.  */
  1197 #define FRAME_WINDOW_STATE_CHANGE(f) (f)->window_state_change
  1198 
  1199 /* The minibuffer window of frame F, if it has one; otherwise nil.  */
  1200 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
  1201 
  1202 /* The root window of the window tree of frame F.  */
  1203 #define FRAME_ROOT_WINDOW(f) f->root_window
  1204 
  1205 /* The currently selected window of frame F.  */
  1206 #define FRAME_SELECTED_WINDOW(f) f->selected_window
  1207 /* The old selected window of frame F.  */
  1208 #define FRAME_OLD_SELECTED_WINDOW(f) f->old_selected_window
  1209 
  1210 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
  1211 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
  1212 #define FRAME_INSERTN_COST(f) (f)->insert_n_lines_cost
  1213 #define FRAME_DELETEN_COST(f) (f)->delete_n_lines_cost
  1214 #define FRAME_FOCUS_FRAME(f) f->focus_frame
  1215 
  1216 #ifdef HAVE_WINDOW_SYSTEM
  1217 /* This frame slot says whether scroll bars are currently enabled for frame F,
  1218    and which side they are on.  */
  1219 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
  1220 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
  1221   ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
  1222 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
  1223   ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
  1224 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
  1225   ((f)->vertical_scroll_bar_type == vertical_scroll_bar_right)
  1226 #else /* not HAVE_WINDOW_SYSTEM */
  1227 /* If there is no window system, there are no scroll bars.  */
  1228 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) \
  1229   ((void) (f), vertical_scroll_bar_none)
  1230 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) (f), 0)
  1231 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) (f), 0)
  1232 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) (f), 0)
  1233 #endif /* HAVE_WINDOW_SYSTEM */
  1234 
  1235 #if defined (HAVE_WINDOW_SYSTEM)
  1236 #define FRAME_UNDECORATED(f) ((f)->undecorated)
  1237 #ifdef HAVE_NTGUI
  1238 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
  1239 #else
  1240 #define FRAME_OVERRIDE_REDIRECT(f) ((f)->override_redirect)
  1241 #endif
  1242 #define FRAME_PARENT_FRAME(f)                   \
  1243   (NILP ((f)->parent_frame)                     \
  1244    ? NULL                                       \
  1245    : XFRAME ((f)->parent_frame))
  1246 #define FRAME_SKIP_TASKBAR(f) ((f)->skip_taskbar)
  1247 #define FRAME_NO_FOCUS_ON_MAP(f) ((f)->no_focus_on_map)
  1248 #define FRAME_NO_ACCEPT_FOCUS(f) ((f)->no_accept_focus)
  1249 #define FRAME_NO_SPECIAL_GLYPHS(f) ((f)->no_special_glyphs)
  1250 #define FRAME_Z_GROUP(f) ((f)->z_group)
  1251 #define FRAME_Z_GROUP_NONE(f) ((f)->z_group == z_group_none)
  1252 #define FRAME_Z_GROUP_ABOVE(f) ((f)->z_group == z_group_above)
  1253 #define FRAME_Z_GROUP_ABOVE_SUSPENDED(f)        \
  1254   ((f)->z_group == z_group_above_suspended)
  1255 #define FRAME_Z_GROUP_BELOW(f) ((f)->z_group == z_group_below)
  1256 #define FRAME_TOOLTIP_P(f) ((f)->tooltip)
  1257 #ifdef NS_IMPL_COCOA
  1258 #define FRAME_NS_APPEARANCE(f) ((f)->ns_appearance)
  1259 #define FRAME_NS_TRANSPARENT_TITLEBAR(f) ((f)->ns_transparent_titlebar)
  1260 #endif
  1261 #else /* not HAVE_WINDOW_SYSTEM */
  1262 #define FRAME_UNDECORATED(f) ((void) (f), 0)
  1263 #define FRAME_OVERRIDE_REDIRECT(f) ((void) (f), 0)
  1264 #define FRAME_PARENT_FRAME(f) ((void) (f), NULL)
  1265 #define FRAME_SKIP_TASKBAR(f) ((void) (f), 0)
  1266 #define FRAME_NO_FOCUS_ON_MAP(f) ((void) (f), 0)
  1267 #define FRAME_NO_ACCEPT_FOCUS(f) ((void) (f), 0)
  1268 #define FRAME_NO_SPECIAL_GLYPHS(f) ((void) (f), 0)
  1269 #define FRAME_Z_GROUP(f) ((void) (f), z_group_none)
  1270 #define FRAME_Z_GROUP_NONE(f) ((void) (f), true)
  1271 #define FRAME_Z_GROUP_ABOVE(f) ((void) (f), false)
  1272 #define FRAME_Z_GROUP_BELOW(f) ((void) (f), false)
  1273 #define FRAME_TOOLTIP_P(f) ((void) f, false)
  1274 #endif /* HAVE_WINDOW_SYSTEM */
  1275 
  1276 /* Whether horizontal scroll bars are currently enabled for frame F.  */
  1277 #if USE_HORIZONTAL_SCROLL_BARS
  1278 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
  1279   ((f)->horizontal_scroll_bars)
  1280 #else
  1281 #define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) (f), 0)
  1282 #endif
  1283 
  1284 /* Width that a scroll bar in frame F should have, if there is one.
  1285    Measured in pixels.
  1286    If scroll bars are turned off, this is still nonzero.  */
  1287 #define FRAME_CONFIG_SCROLL_BAR_WIDTH(f) ((f)->config_scroll_bar_width)
  1288 
  1289 /* Height that a scroll bar in frame F should have, if there is one.
  1290    Measured in pixels.
  1291    If scroll bars are turned off, this is still nonzero.  */
  1292 #define FRAME_CONFIG_SCROLL_BAR_HEIGHT(f) ((f)->config_scroll_bar_height)
  1293 
  1294 /* Width that a scroll bar in frame F should have, if there is one.
  1295    Measured in columns (characters).
  1296    If scroll bars are turned off, this is still nonzero.  */
  1297 #define FRAME_CONFIG_SCROLL_BAR_COLS(f) ((f)->config_scroll_bar_cols)
  1298 
  1299 /* Height that a scroll bar in frame F should have, if there is one.
  1300    Measured in lines (characters).
  1301    If scroll bars are turned off, this is still nonzero.  */
  1302 #define FRAME_CONFIG_SCROLL_BAR_LINES(f) ((f)->config_scroll_bar_lines)
  1303 
  1304 /* Width of a left scroll bar in frame F, measured in pixels */
  1305 #define FRAME_LEFT_SCROLL_BAR_AREA_WIDTH(f)                             \
  1306   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)                           \
  1307    ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)                                  \
  1308    : 0)
  1309 
  1310 /* Width of a right scroll bar area in frame F, measured in pixels */
  1311 #define FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH(f)                            \
  1312   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)                          \
  1313    ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)                                  \
  1314    : 0)
  1315 
  1316 /* Width of a left scroll bar in frame F, measured in columns
  1317    (characters), but only if scroll bars are on the left.  If scroll
  1318    bars are on the right in this frame, or there are no scroll bars,
  1319    value is 0.  */
  1320 #define FRAME_LEFT_SCROLL_BAR_COLS(f)                   \
  1321   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)           \
  1322    ? FRAME_CONFIG_SCROLL_BAR_COLS (f)                   \
  1323    : 0)
  1324 
  1325 /* Width of a right scroll bar in frame F, measured in columns
  1326    (characters), but only if scroll bars are on the right.  If scroll
  1327    bars are on the left in this frame, or there are no scroll bars,
  1328    value is 0.  */
  1329 #define FRAME_RIGHT_SCROLL_BAR_COLS(f)                  \
  1330   (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)          \
  1331    ? FRAME_CONFIG_SCROLL_BAR_COLS (f)                   \
  1332    : 0)
  1333 
  1334 /* Width of a vertical scroll bar area in frame F, measured in
  1335    pixels.  */
  1336 #define FRAME_SCROLL_BAR_AREA_WIDTH(f)          \
  1337   (FRAME_HAS_VERTICAL_SCROLL_BARS (f)           \
  1338    ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f)          \
  1339    : 0)
  1340 
  1341 /* Height of horizontal scroll bar area in frame F, measured in
  1342    pixels.  */
  1343 #define FRAME_SCROLL_BAR_AREA_HEIGHT(f) \
  1344   (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
  1345    ? FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) \
  1346    : 0)
  1347 
  1348 /* Width of vertical scroll bar in frame F, measured in columns.  */
  1349 #define FRAME_SCROLL_BAR_COLS(f)      \
  1350   (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
  1351    ? FRAME_CONFIG_SCROLL_BAR_COLS (f) \
  1352    : 0)
  1353 
  1354 /* Height of horizontal scroll bar in frame F, measured in lines.  */
  1355 #define FRAME_SCROLL_BAR_LINES(f)       \
  1356   (FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) \
  1357    ? FRAME_CONFIG_SCROLL_BAR_LINES (f)  \
  1358    : 0)
  1359 
  1360 /* Maximum + 1 legitimate value for FRAME_CURSOR_X.  */
  1361 #define FRAME_CURSOR_X_LIMIT(f) \
  1362   (FRAME_COLS (f) + FRAME_LEFT_SCROLL_BAR_COLS (f))
  1363 
  1364 /* Nonzero if frame F has scroll bars.  */
  1365 #define FRAME_SCROLL_BARS(f) (f->scroll_bars)
  1366 #define FRAME_CONDEMNED_SCROLL_BARS(f) (f->condemned_scroll_bars)
  1367 
  1368 #define FRAME_MENU_BAR_ITEMS(f) (f->menu_bar_items)
  1369 #define FRAME_COST_BAUD_RATE(f) ((f)->cost_calculation_baud_rate)
  1370 
  1371 #define FRAME_DESIRED_CURSOR(f) ((f)->desired_cursor)
  1372 #define FRAME_BLINK_OFF_CURSOR(f) ((f)->blink_off_cursor)
  1373 #define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
  1374 #define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
  1375 
  1376 #define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
  1377 #define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
  1378 
  1379 /* Return a pointer to the face cache of frame F.  */
  1380 #define FRAME_FACE_CACHE(F)     (F)->face_cache
  1381 
  1382 /* Return the size of message_buf of the frame F.  We multiply the
  1383    width of the frame by 4 because multi-byte form may require at most
  1384    4-byte for a character.  */
  1385 
  1386 #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
  1387 
  1388 #define CHECK_FRAME(x) \
  1389   CHECK_TYPE (FRAMEP (x), Qframep, x)
  1390 
  1391 #define CHECK_LIVE_FRAME(x) \
  1392   CHECK_TYPE (FRAMEP (x) && FRAME_LIVE_P (XFRAME (x)), Qframe_live_p, x)
  1393 
  1394 /* FOR_EACH_FRAME (LIST_VAR, FRAME_VAR) followed by a statement is a
  1395    `for' loop which iterates over the elements of Vframe_list.  The
  1396    loop will set FRAME_VAR, a Lisp_Object, to each frame in
  1397    Vframe_list in succession and execute the statement.  LIST_VAR
  1398    should be a Lisp_Object too; it is used to iterate through the
  1399    Vframe_list.  Note that this macro walks over child frames and
  1400    the tooltip frame as well.
  1401 
  1402    This macro is a holdover from a time when multiple frames weren't always
  1403    supported.  An alternate definition of the macro would expand to
  1404    something which executes the statement once.  */
  1405 #define FOR_EACH_FRAME(list_var, frame_var)      \
  1406   for ((list_var) = Vframe_list;                 \
  1407        (CONSP (list_var)                         \
  1408         && (frame_var = XCAR (list_var), true)); \
  1409        list_var = XCDR (list_var))
  1410 
  1411 /* Reflect mouse movement when a complete frame update is performed.  */
  1412 #define FRAME_MOUSE_UPDATE(frame)                               \
  1413   do {                                                          \
  1414     Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (frame);               \
  1415     if (frame == hlinfo->mouse_face_mouse_frame)                \
  1416       {                                                         \
  1417         block_input ();                                         \
  1418         note_mouse_highlight (hlinfo->mouse_face_mouse_frame,   \
  1419                               hlinfo->mouse_face_mouse_x,       \
  1420                               hlinfo->mouse_face_mouse_y);      \
  1421         unblock_input ();                                       \
  1422       }                                                         \
  1423   } while (false)
  1424 
  1425 /* Handy macro to construct an argument to Fmodify_frame_parameters.  */
  1426 #define AUTO_FRAME_ARG(name, parameter, value)          \
  1427   AUTO_LIST1 (name, AUTO_CONS_EXPR (parameter, value))
  1428 
  1429 /* False means there are no visible garbaged frames.  */
  1430 extern bool frame_garbaged;
  1431 
  1432 /* Set visibility of frame F.
  1433    We call redisplay_other_windows to make sure the frame gets redisplayed
  1434    if some changes were applied to it while it wasn't visible (and hence
  1435    wasn't redisplayed).  */
  1436 INLINE void
  1437 SET_FRAME_VISIBLE (struct frame *f, int v)
  1438 {
  1439   eassert (0 <= v && v <= 2);
  1440   if (v)
  1441     {
  1442       if (v == 1 && f->visible != 1)
  1443         redisplay_other_windows ();
  1444       if (FRAME_GARBAGED_P (f))
  1445         frame_garbaged = true;
  1446     }
  1447   f->visible = v;
  1448 }
  1449 
  1450 /* Set iconified status of frame F.  */
  1451 INLINE void
  1452 SET_FRAME_ICONIFIED (struct frame *f, int i)
  1453 {
  1454 #ifdef HAVE_WINDOW_SYSTEM
  1455   Lisp_Object frame;
  1456 #endif
  1457 
  1458   eassert (0 <= (i) && (i) <= 1);
  1459 
  1460   f->iconified = i;
  1461 
  1462 #ifdef HAVE_WINDOW_SYSTEM
  1463   /* Iconifying a frame might cause the frame title to change if no
  1464      title was explicitly specified.  Force the frame title to be
  1465      recomputed.  */
  1466 
  1467   XSETFRAME (frame, f);
  1468 
  1469   if (FRAME_WINDOW_P (f))
  1470     gui_consider_frame_title (frame);
  1471 #endif
  1472 }
  1473 
  1474 extern Lisp_Object selected_frame;
  1475 extern Lisp_Object old_selected_frame;
  1476 
  1477 extern int frame_default_tab_bar_height;
  1478 
  1479 #ifndef HAVE_EXT_TOOL_BAR
  1480 extern int frame_default_tool_bar_height;
  1481 #endif
  1482 
  1483 #ifdef HAVE_WINDOW_SYSTEM
  1484 # define WINDOW_SYSTEM_RETURN
  1485 #else
  1486 # define WINDOW_SYSTEM_RETURN _Noreturn ATTRIBUTE_COLD
  1487 #endif
  1488 
  1489 extern WINDOW_SYSTEM_RETURN struct frame *
  1490   decode_window_system_frame (Lisp_Object);
  1491 extern struct frame *decode_live_frame (Lisp_Object);
  1492 extern struct frame *decode_any_frame (Lisp_Object);
  1493 extern struct frame *make_initial_frame (void);
  1494 extern struct frame *make_frame (bool);
  1495 #ifdef HAVE_WINDOW_SYSTEM
  1496 extern struct frame *make_minibuffer_frame (void);
  1497 extern struct frame *make_frame_without_minibuffer (Lisp_Object,
  1498                                                     struct kboard *,
  1499                                                     Lisp_Object);
  1500 extern bool display_available (void);
  1501 #endif
  1502 
  1503 INLINE bool
  1504 window_system_available (struct frame *f)
  1505 {
  1506 #ifdef HAVE_WINDOW_SYSTEM
  1507   return f ? FRAME_WINDOW_P (f) || FRAME_MSDOS_P (f) : display_available ();
  1508 #else
  1509   return false;
  1510 #endif
  1511 }
  1512 
  1513 extern WINDOW_SYSTEM_RETURN void check_window_system (struct frame *);
  1514 extern void frame_make_pointer_invisible (struct frame *);
  1515 extern void frame_make_pointer_visible (struct frame *);
  1516 extern Lisp_Object delete_frame (Lisp_Object, Lisp_Object);
  1517 extern bool frame_inhibit_resize (struct frame *, bool, Lisp_Object);
  1518 extern void adjust_frame_size (struct frame *, int, int, int, bool,
  1519                                Lisp_Object);
  1520 extern Lisp_Object mouse_position (bool);
  1521 extern void frame_size_history_plain (struct frame *, Lisp_Object);
  1522 extern void frame_size_history_extra (struct frame *, Lisp_Object,
  1523                                       int, int, int, int, int, int);
  1524 extern Lisp_Object Vframe_list;
  1525 
  1526 /* Value is a pointer to the selected frame.  If the selected frame
  1527    isn't live, abort.  */
  1528 
  1529 #define SELECTED_FRAME()                                \
  1530      ((FRAMEP (selected_frame)                          \
  1531        && FRAME_LIVE_P (XFRAME (selected_frame)))       \
  1532       ? XFRAME (selected_frame)                         \
  1533       : (emacs_abort (), (struct frame *) 0))
  1534 
  1535 
  1536 /***********************************************************************
  1537                         Display-related Macros
  1538  ***********************************************************************/
  1539 
  1540 /* Canonical y-unit on frame F.
  1541    This value currently equals the line height of the frame (which is
  1542    the height of the default font of F).  */
  1543 #define FRAME_LINE_HEIGHT(F) ((F)->line_height)
  1544 
  1545 /* Canonical x-unit on frame F.
  1546    This value currently equals the average width of the default font of F.  */
  1547 #define FRAME_COLUMN_WIDTH(F) ((F)->column_width)
  1548 
  1549 /* Get a frame's window system dimension.  If no window system, this is 0.  */
  1550 
  1551 INLINE int
  1552 frame_dimension (int x)
  1553 {
  1554 #ifdef HAVE_WINDOW_SYSTEM
  1555   return x;
  1556 #else
  1557   return 0;
  1558 #endif
  1559 }
  1560 
  1561 /* Total width of fringes reserved for drawing truncation bitmaps,
  1562    continuation bitmaps and alike.  The width is in canonical char
  1563    units of the frame.  This must currently be the case because window
  1564    sizes aren't pixel values.  If it weren't the case, we wouldn't be
  1565    able to split windows horizontally nicely.  */
  1566 INLINE int
  1567 FRAME_FRINGE_COLS (struct frame *f)
  1568 {
  1569   return frame_dimension (f->fringe_cols);
  1570 }
  1571 
  1572 /* Pixel-width of the left and right fringe.  */
  1573 
  1574 INLINE int
  1575 FRAME_LEFT_FRINGE_WIDTH (struct frame *f)
  1576 {
  1577   return frame_dimension (f->left_fringe_width);
  1578 }
  1579 INLINE int
  1580 FRAME_RIGHT_FRINGE_WIDTH (struct frame *f)
  1581 {
  1582   return frame_dimension (f->right_fringe_width);
  1583 }
  1584 
  1585 /* Total width of fringes in pixels.  */
  1586 
  1587 INLINE int
  1588 FRAME_TOTAL_FRINGE_WIDTH (struct frame *f)
  1589 {
  1590   return FRAME_LEFT_FRINGE_WIDTH (f) + FRAME_RIGHT_FRINGE_WIDTH (f);
  1591 }
  1592 
  1593 INLINE int
  1594 FRAME_CHILD_FRAME_BORDER_WIDTH (struct frame *f)
  1595 {
  1596   return frame_dimension (f->child_frame_border_width);
  1597 }
  1598 
  1599 /* Pixel-width of internal border.  Uses child_frame_border_width for
  1600    child frames if possible, and falls back on internal_border_width
  1601    otherwise.  */
  1602 INLINE int
  1603 FRAME_INTERNAL_BORDER_WIDTH (struct frame *f)
  1604 {
  1605 #ifdef HAVE_WINDOW_SYSTEM
  1606   return (FRAME_PARENT_FRAME(f)
  1607           ? (FRAME_CHILD_FRAME_BORDER_WIDTH(f) >= 0
  1608              ? FRAME_CHILD_FRAME_BORDER_WIDTH(f)
  1609              : frame_dimension (f->internal_border_width))
  1610           : frame_dimension (f->internal_border_width));
  1611 #else
  1612   return frame_dimension (f->internal_border_width);
  1613 #endif
  1614 }
  1615 
  1616 /* Pixel-size of window divider lines.  */
  1617 INLINE int
  1618 FRAME_RIGHT_DIVIDER_WIDTH (struct frame *f)
  1619 {
  1620   return frame_dimension (f->right_divider_width);
  1621 }
  1622 
  1623 INLINE int
  1624 FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
  1625 {
  1626   return frame_dimension (f->bottom_divider_width);
  1627 }
  1628 
  1629 /* Return a non-null pointer to the cached face with ID on frame F.  */
  1630 
  1631 INLINE struct face *
  1632 FACE_FROM_ID (struct frame *f, int id)
  1633 {
  1634   eassert (0 <= id && id < FRAME_FACE_CACHE (f)->used);
  1635   return FRAME_FACE_CACHE (f)->faces_by_id[id];
  1636 }
  1637 
  1638 /* Return a pointer to the face with ID on frame F, or null if such a
  1639    face doesn't exist.  */
  1640 
  1641 INLINE struct face *
  1642 FACE_FROM_ID_OR_NULL (struct frame *f, int id)
  1643 {
  1644   int used = FRAME_FACE_CACHE (f)->used;
  1645   eassume (0 <= used);
  1646   return 0 <= id && id < used ? FRAME_FACE_CACHE (f)->faces_by_id[id] : NULL;
  1647 }
  1648 
  1649 #ifdef HAVE_WINDOW_SYSTEM
  1650 
  1651 /* A non-null pointer to the image with id ID on frame F.  */
  1652 
  1653 INLINE struct image *
  1654 IMAGE_FROM_ID (struct frame *f, int id)
  1655 {
  1656   eassert (0 <= id && id < FRAME_IMAGE_CACHE (f)->used);
  1657   return FRAME_IMAGE_CACHE (f)->images[id];
  1658 }
  1659 
  1660 /* Value is a pointer to the image with id ID on frame F, or null if
  1661    no image with that id exists.  */
  1662 
  1663 INLINE struct image *
  1664 IMAGE_OPT_FROM_ID (struct frame *f, int id)
  1665 {
  1666   int used = FRAME_IMAGE_CACHE (f)->used;
  1667   eassume (0 <= used);
  1668   return 0 <= id && id < used ? FRAME_IMAGE_CACHE (f)->images[id] : NULL;
  1669 }
  1670 #endif
  1671 
  1672 /***********************************************************************
  1673             Conversion between canonical units and pixels
  1674  ***********************************************************************/
  1675 
  1676 /* Canonical x-values are fractions of FRAME_COLUMN_WIDTH, canonical
  1677    y-unit are fractions of FRAME_LINE_HEIGHT of a frame.  Both are
  1678    represented as Lisp numbers, i.e. integers or floats.  */
  1679 
  1680 /* Convert canonical value X to pixels.  F is the frame whose
  1681    canonical char width is to be used.  X must be a Lisp integer or
  1682    float.  Value is a C integer.  */
  1683 #define FRAME_PIXEL_X_FROM_CANON_X(F, X)                \
  1684   ((int) (XFLOATINT (X) * FRAME_COLUMN_WIDTH (F)))
  1685 
  1686 /* Convert canonical value Y to pixels.  F is the frame whose
  1687    canonical character height is to be used.  X must be a Lisp integer
  1688    or float.  Value is a C integer.  */
  1689 #define FRAME_PIXEL_Y_FROM_CANON_Y(F, Y)                \
  1690   ((int) (XFLOATINT (Y) * FRAME_LINE_HEIGHT (F)))
  1691 
  1692 /* Convert pixel-value X to canonical units.  F is the frame whose
  1693    canonical character width is to be used.  X is a C integer.  Result
  1694    is a Lisp float if X is not a multiple of the canon width,
  1695    otherwise it's a Lisp integer.  */
  1696 #define FRAME_CANON_X_FROM_PIXEL_X(F, X)                        \
  1697   ((X) % FRAME_COLUMN_WIDTH (F) != 0                            \
  1698    ? make_float ((double) (X) / FRAME_COLUMN_WIDTH (F))         \
  1699    : make_fixnum ((X) / FRAME_COLUMN_WIDTH (F)))
  1700 
  1701 /* Convert pixel-value Y to canonical units.  F is the frame whose
  1702    canonical character height is to be used.  Y is a C integer.
  1703    Result is a Lisp float if Y is not a multiple of the canon width,
  1704    otherwise it's a Lisp integer.  */
  1705 #define FRAME_CANON_Y_FROM_PIXEL_Y(F, Y)                        \
  1706   ((Y) % FRAME_LINE_HEIGHT (F)                                  \
  1707    ? make_float ((double) (Y) / FRAME_LINE_HEIGHT (F))          \
  1708    : make_fixnum ((Y) / FRAME_LINE_HEIGHT (F)))
  1709 
  1710 
  1711 
  1712 /* Manipulating pixel sizes and character sizes.
  1713    Knowledge of which factors affect the overall size of the window should
  1714    be hidden in these macros, if that's possible.
  1715 
  1716    Return the upper/left pixel position of the character cell on frame F
  1717    at ROW/COL.  */
  1718 #define FRAME_LINE_TO_PIXEL_Y(f, row)                                   \
  1719   (((row) < FRAME_TOP_MARGIN (f) ? 0 : FRAME_INTERNAL_BORDER_WIDTH (f)) \
  1720    + (row) * FRAME_LINE_HEIGHT (f))
  1721 
  1722 #define FRAME_COL_TO_PIXEL_X(f, col)            \
  1723   (FRAME_INTERNAL_BORDER_WIDTH (f)              \
  1724    + (col) * FRAME_COLUMN_WIDTH (f))
  1725 
  1726 /* Return the pixel width/height of frame F if it has
  1727    COLS columns/LINES rows.  */
  1728 #define FRAME_TEXT_COLS_TO_PIXEL_WIDTH(f, cols) \
  1729   ((cols) * FRAME_COLUMN_WIDTH (f)              \
  1730    + FRAME_SCROLL_BAR_AREA_WIDTH (f)            \
  1731    + FRAME_TOTAL_FRINGE_WIDTH (f)               \
  1732    + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
  1733 
  1734 #define FRAME_TEXT_LINES_TO_PIXEL_HEIGHT(f, lines) \
  1735   ((lines) * FRAME_LINE_HEIGHT (f)                 \
  1736    + FRAME_TOP_MARGIN_HEIGHT (f)                   \
  1737    + FRAME_SCROLL_BAR_AREA_HEIGHT (f)              \
  1738    + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
  1739 
  1740 /* Return the row/column (zero-based) of the character cell containing
  1741    the pixel on FRAME at Y/X.  */
  1742 #define FRAME_PIXEL_Y_TO_LINE(f, y)                                     \
  1743   (((y) < FRAME_TOP_MARGIN_HEIGHT (f)                                   \
  1744     ? (y)                                                               \
  1745     : ((y) < (FRAME_TOP_MARGIN_HEIGHT (f)                               \
  1746               + FRAME_INTERNAL_BORDER_WIDTH (f))                        \
  1747        ? (y) - (FRAME_TOP_MARGIN_HEIGHT (f)                             \
  1748                 + FRAME_INTERNAL_BORDER_WIDTH (f)                       \
  1749                 /* Arrange for the division to round down.  */          \
  1750                 + FRAME_LINE_HEIGHT (f) - 1)                            \
  1751        : (y) - FRAME_INTERNAL_BORDER_WIDTH (f)))                        \
  1752    / FRAME_LINE_HEIGHT (f))
  1753 
  1754 #define FRAME_PIXEL_X_TO_COL(f, x)              \
  1755   (((x) - FRAME_INTERNAL_BORDER_WIDTH (f))      \
  1756    / FRAME_COLUMN_WIDTH (f))
  1757 
  1758 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
  1759    frame F (so we round down)?  */
  1760 #define FRAME_PIXEL_WIDTH_TO_TEXT_COLS(f, width)                        \
  1761   (((width)                                                             \
  1762     - FRAME_TOTAL_FRINGE_WIDTH (f)                                      \
  1763     - FRAME_SCROLL_BAR_AREA_WIDTH (f)                                   \
  1764     - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))                              \
  1765    / FRAME_COLUMN_WIDTH (f))
  1766 
  1767 #define FRAME_PIXEL_HEIGHT_TO_TEXT_LINES(f, height)                     \
  1768   (((height)                                                            \
  1769     - FRAME_MARGIN_HEIGHT (f)                                           \
  1770     - FRAME_SCROLL_BAR_AREA_HEIGHT (f)                                  \
  1771     - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))                              \
  1772    / FRAME_LINE_HEIGHT (f))
  1773 
  1774 /* Return the pixel width/height of frame F with a text size of
  1775    width/height.  */
  1776 #define FRAME_TEXT_TO_PIXEL_WIDTH(f, width)       \
  1777   ((width)                                        \
  1778    + FRAME_SCROLL_BAR_AREA_WIDTH (f)              \
  1779    + FRAME_TOTAL_FRINGE_WIDTH (f)                 \
  1780    + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
  1781 
  1782 #define FRAME_TEXT_TO_PIXEL_HEIGHT(f, height)        \
  1783   ((height)                                          \
  1784    + FRAME_MARGIN_HEIGHT (f)                         \
  1785    + FRAME_SCROLL_BAR_AREA_HEIGHT (f)                \
  1786    + 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
  1787 
  1788 /* Return the text width/height of frame F with a pixel size of
  1789    width/height.  */
  1790 #define FRAME_PIXEL_TO_TEXT_WIDTH(f, width)       \
  1791   ((width)                                        \
  1792    - FRAME_SCROLL_BAR_AREA_WIDTH (f)              \
  1793    - FRAME_TOTAL_FRINGE_WIDTH (f)                 \
  1794    - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
  1795 
  1796 #define FRAME_PIXEL_TO_TEXT_HEIGHT(f, height)           \
  1797   ((height)                                             \
  1798    - FRAME_MARGIN_HEIGHT (f)                            \
  1799    - FRAME_SCROLL_BAR_AREA_HEIGHT (f)                   \
  1800    - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
  1801 
  1802 #define FRAME_INNER_WIDTH(f)                    \
  1803   (FRAME_PIXEL_WIDTH (f)                        \
  1804    - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
  1805 
  1806 #define FRAME_INNER_HEIGHT(f)                   \
  1807   (FRAME_PIXEL_HEIGHT (f)                       \
  1808    - FRAME_MARGIN_HEIGHT (f)                    \
  1809    - 2 * FRAME_INTERNAL_BORDER_WIDTH (f))
  1810 
  1811 /* Value is the smallest width of any character in any font on frame F.  */
  1812 #define FRAME_SMALLEST_CHAR_WIDTH(f)            \
  1813   FRAME_DISPLAY_INFO (f)->smallest_char_width
  1814 
  1815 /* Value is the smallest height of any font on frame F.  */
  1816 #define FRAME_SMALLEST_FONT_HEIGHT(f)           \
  1817   FRAME_DISPLAY_INFO (f)->smallest_font_height
  1818 
  1819 /***********************************************************************
  1820                                 Frame Parameters
  1821  ***********************************************************************/
  1822 
  1823 #ifdef HAVE_WINDOW_SYSTEM
  1824 
  1825 /* The class of this X application.  */
  1826 #define EMACS_CLASS "Emacs"
  1827 
  1828 extern void gui_set_frame_parameters_1 (struct frame *, Lisp_Object, bool);
  1829 extern void gui_set_frame_parameters (struct frame *, Lisp_Object);
  1830 extern void gui_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
  1831 extern void gui_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
  1832 extern void gui_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
  1833 extern void gui_set_font (struct frame *, Lisp_Object, Lisp_Object);
  1834 extern void gui_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
  1835 extern void gui_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
  1836 extern void gui_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
  1837 extern void gui_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
  1838 extern void gui_set_right_divider_width (struct frame *, Lisp_Object,
  1839                                          Lisp_Object);
  1840 extern void gui_set_bottom_divider_width (struct frame *, Lisp_Object,
  1841                                           Lisp_Object);
  1842 extern void gui_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
  1843 extern void gui_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
  1844 extern void gui_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
  1845 extern void gui_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
  1846 extern void gui_set_vertical_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
  1847 extern void gui_set_horizontal_scroll_bars (struct frame *, Lisp_Object, Lisp_Object);
  1848 extern void gui_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
  1849 extern void gui_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
  1850 
  1851 extern long gui_figure_window_size (struct frame *, Lisp_Object, bool, bool);
  1852 
  1853 extern void gui_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
  1854 extern void gui_set_alpha_background (struct frame *, Lisp_Object, Lisp_Object);
  1855 extern void gui_set_no_special_glyphs (struct frame *, Lisp_Object, Lisp_Object);
  1856 
  1857 extern void validate_x_resource_name (void);
  1858 
  1859 extern Lisp_Object gui_display_get_resource (Display_Info *,
  1860                                              Lisp_Object attribute,
  1861                                              Lisp_Object class,
  1862                                              Lisp_Object component,
  1863                                              Lisp_Object subclass);
  1864 
  1865 extern void set_frame_menubar (struct frame *f, bool deep_p);
  1866 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
  1867 extern void free_frame_menubar (struct frame *);
  1868 extern bool frame_ancestor_p (struct frame *af, struct frame *df);
  1869 extern enum internal_border_part frame_internal_border_part (struct frame *f, int x, int y);
  1870 
  1871 #if defined HAVE_X_WINDOWS
  1872 extern void x_wm_set_icon_position (struct frame *, int, int);
  1873 #if !defined USE_X_TOOLKIT
  1874 extern const char *x_get_resource_string (const char *, const char *);
  1875 #endif
  1876 #endif /* HAVE_X_WINDOWS */
  1877 
  1878 #if !defined (HAVE_NS) && !defined (HAVE_PGTK)
  1879 
  1880 /* Set F's bitmap icon, if specified among F's parameters.  */
  1881 
  1882 INLINE void
  1883 gui_set_bitmap_icon (struct frame *f)
  1884 {
  1885   Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
  1886 
  1887   if (CONSP (obj) && !NILP (XCDR (obj))
  1888       && FRAME_TERMINAL (f)->set_bitmap_icon_hook)
  1889     FRAME_TERMINAL (f)->set_bitmap_icon_hook (f, XCDR (obj));
  1890 }
  1891 
  1892 #endif /* !HAVE_NS */
  1893 #endif /* HAVE_WINDOW_SYSTEM */
  1894 
  1895 INLINE void
  1896 flush_frame (struct frame *f)
  1897 {
  1898   struct redisplay_interface *rif = FRAME_RIF (f);
  1899 
  1900   if (rif && rif->flush_display)
  1901     rif->flush_display (f);
  1902 }
  1903 
  1904 /***********************************************************************
  1905                         Multimonitor data
  1906  ***********************************************************************/
  1907 
  1908 #ifdef HAVE_WINDOW_SYSTEM
  1909 
  1910 struct MonitorInfo {
  1911   Emacs_Rectangle geom, work;
  1912   int mm_width, mm_height;
  1913   char *name;
  1914 #ifdef HAVE_PGTK
  1915   double scale_factor;
  1916 #endif
  1917 };
  1918 
  1919 extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
  1920 extern Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors,
  1921                                                 int n_monitors,
  1922                                                 int primary_monitor,
  1923                                                 Lisp_Object monitor_frames,
  1924                                                 const char *source);
  1925 
  1926 #endif /* HAVE_WINDOW_SYSTEM */
  1927 
  1928 
  1929 INLINE_HEADER_END
  1930 
  1931 /* Suppress -Wsuggest-attribute=const if there are no scroll bars.
  1932    This is for functions like x_set_horizontal_scroll_bars that have
  1933    no effect in this case.  */
  1934 #if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
  1935 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
  1936 #endif
  1937 
  1938 #endif /* not EMACS_FRAME_H */

/* [<][>][^][v][top][bottom][index][help] */