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

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