root/src/xterm.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. SELECTION_EVENT_DISPLAY
  2. x_make_truecolor_pixel
  3. x_mutable_colormap

     1 /* Definitions and headers for communication with X protocol.
     2    Copyright (C) 1989, 1993-1994, 1998-2023 Free Software Foundation,
     3    Inc.
     4 
     5 This file is part of GNU Emacs.
     6 
     7 GNU Emacs is free software: you can redistribute it and/or modify
     8 it under the terms of the GNU General Public License as published by
     9 the Free Software Foundation, either version 3 of the License, or (at
    10 your option) any later version.
    11 
    12 GNU Emacs is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    19 
    20 #ifndef XTERM_H
    21 #define XTERM_H
    22 
    23 #include <X11/Xlib.h>
    24 #include <X11/cursorfont.h>
    25 
    26 /* Include Xutil.h after keysym.h to work around a bug that prevents
    27    correct recognition of AltGr key in some X versions.  */
    28 
    29 #include <X11/keysym.h>
    30 #include <X11/Xutil.h>
    31 
    32 #include <X11/Xatom.h>
    33 #include <X11/Xresource.h>
    34 
    35 #ifdef HAVE_XINPUT2
    36 #include <X11/extensions/XInput2.h>
    37 #endif
    38 
    39 #ifdef USE_X_TOOLKIT
    40 #include <X11/StringDefs.h>
    41 #include <X11/IntrinsicP.h>     /* CoreP.h needs this */
    42 #include <X11/CoreP.h>          /* foul, but we need this to use our own
    43                                    window inside a widget instead of one
    44                                    that Xt creates... */
    45 #ifdef X_TOOLKIT_EDITRES
    46 #include <X11/Xmu/Editres.h>
    47 #endif
    48 
    49 typedef Widget xt_or_gtk_widget;
    50 #endif
    51 
    52 #ifdef USE_GTK
    53 #include <gtk/gtk.h>
    54 #include <gdk/gdkx.h>
    55 #endif /* USE_GTK */
    56 
    57 #ifndef USE_GTK
    58 #define GTK_CHECK_VERSION(i, j, k) false
    59 #endif
    60 
    61 #ifdef HAVE_XRENDER
    62 #include <X11/extensions/Xrender.h>
    63 #endif
    64 
    65 #ifdef USE_GTK
    66 /* Some definitions to reduce conditionals.  */
    67 typedef GtkWidget *xt_or_gtk_widget;
    68 #undef XSync
    69 /* gdk_window_process_all_updates is deprecated in GDK 3.22.  */
    70 #if GTK_CHECK_VERSION (3, 22, 0)
    71 #define XSync(d, b) do { XSync ((d), (b)); } while (false)
    72 #else
    73 #define XSync(d, b) do { gdk_window_process_all_updates (); \
    74                          XSync (d, b);  } while (false)
    75 #endif
    76 #endif /* USE_GTK */
    77 
    78 /* Number of "failable requests" to store.  */
    79 #define N_FAILABLE_REQUESTS 128
    80 
    81 #ifdef USE_CAIRO
    82 #include <cairo-xlib.h>
    83 #ifdef CAIRO_HAS_PDF_SURFACE
    84 #include <cairo-pdf.h>
    85 #endif
    86 #ifdef CAIRO_HAS_PS_SURFACE
    87 #include <cairo-ps.h>
    88 #endif
    89 #ifdef CAIRO_HAS_SVG_SURFACE
    90 #include <cairo-svg.h>
    91 #endif
    92 #ifdef USE_CAIRO_XCB
    93 #include <cairo-xcb.h>
    94 #endif
    95 #endif
    96 
    97 #ifdef HAVE_X_I18N
    98 #include <X11/Xlocale.h>
    99 #endif
   100 
   101 #ifdef USE_XCB
   102 #include <X11/Xlib-xcb.h>
   103 #endif
   104 
   105 #ifdef HAVE_XKB
   106 #include <X11/XKBlib.h>
   107 #endif
   108 
   109 #ifdef HAVE_XSYNC
   110 #include <X11/extensions/sync.h>
   111 #endif
   112 
   113 #include "dispextern.h"
   114 #include "termhooks.h"
   115 
   116 INLINE_HEADER_BEGIN
   117 
   118 /* Black and white pixel values for the screen which frame F is on.  */
   119 #define BLACK_PIX_DEFAULT(f)                                    \
   120   BlackPixel (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))
   121 #define WHITE_PIX_DEFAULT(f)                                    \
   122   WhitePixel (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))
   123 
   124 /* The mask of events that text windows always want to receive.  This
   125    includes mouse movement events, since handling the mouse-font text property
   126    means that we must track mouse motion all the time.  */
   127 
   128 #define STANDARD_EVENT_SET      \
   129   (KeyPressMask                 \
   130    | ExposureMask               \
   131    | ButtonPressMask            \
   132    | ButtonReleaseMask          \
   133    | PointerMotionMask          \
   134    | StructureNotifyMask        \
   135    | FocusChangeMask            \
   136    | LeaveWindowMask            \
   137    | EnterWindowMask            \
   138    | PropertyChangeMask         \
   139    | VisibilityChangeMask)
   140 
   141 #ifdef HAVE_X11R6_XIM
   142 /* Data structure passed to xim_instantiate_callback.  */
   143 struct xim_inst_t
   144 {
   145   struct x_display_info *dpyinfo;
   146   char *resource_name;
   147 };
   148 #endif /* HAVE_X11R6_XIM */
   149 
   150 #ifdef HAVE_XINPUT2
   151 #if HAVE_XISCROLLCLASSINFO_TYPE && defined XIScrollClass
   152 #define HAVE_XINPUT2_1
   153 #endif
   154 #if HAVE_XITOUCHCLASSINFO_TYPE && defined XITouchClass
   155 #define HAVE_XINPUT2_2
   156 #endif
   157 #if HAVE_XIBARRIERRELEASEPOINTERINFO_DEVICEID && defined XIBarrierPointerReleased
   158 #define HAVE_XINPUT2_3
   159 #endif
   160 #if HAVE_XIGESTURECLASSINFO_TYPE && defined XIGestureClass
   161 #define HAVE_XINPUT2_4
   162 #endif
   163 #endif
   164 
   165 /* Structure recording X pixmap and reference count.
   166    If REFCOUNT is 0 then this record is free to be reused.  */
   167 
   168 struct x_bitmap_record
   169 {
   170 #ifdef USE_CAIRO
   171   cairo_pattern_t *stipple;
   172 #endif
   173   Pixmap pixmap;
   174   bool have_mask;
   175   Pixmap mask;
   176   char *file;
   177   int refcount;
   178   /* Record some info about this pixmap.  */
   179   int height, width, depth;
   180 };
   181 
   182 #if defined USE_CAIRO || defined HAVE_XRENDER
   183 struct x_gc_ext_data
   184 {
   185 #define MAX_CLIP_RECTS 2
   186   /* Number of clipping rectangles.  */
   187   int n_clip_rects;
   188 
   189   /* Clipping rectangles.  */
   190   XRectangle clip_rects[MAX_CLIP_RECTS];
   191 };
   192 #endif
   193 
   194 #ifdef USE_CAIRO
   195 extern cairo_pattern_t *x_bitmap_stipple (struct frame *, Pixmap);
   196 #endif
   197 
   198 
   199 struct color_name_cache_entry
   200 {
   201   struct color_name_cache_entry *next;
   202 
   203   /* The color values of the cached color entry.  */
   204   XColor rgb;
   205 
   206   /* The name of the cached color.  */
   207   char *name;
   208 
   209   /* Whether or not RGB is valid (i.e. the color actually exists).  */
   210   bool_bf valid : 1;
   211 };
   212 
   213 #ifdef HAVE_XINPUT2
   214 
   215 #ifdef HAVE_XINPUT2_1
   216 
   217 struct xi_scroll_valuator_t
   218 {
   219   /* The ID of the valuator.  */
   220   int number;
   221 
   222   /* Whether or not it represents X axis movement.  */
   223   bool_bf horizontal : 1;
   224 
   225   /* Whether or not the value is currently invalid.  */
   226   bool_bf invalid_p : 1;
   227 
   228   /* The current value.  */
   229   double current_value;
   230 
   231   /* Value used to tally up deltas until a threshold is met.  */
   232   double emacs_value;
   233 
   234   /* The scroll increment.  */
   235   double increment;
   236 };
   237 
   238 #endif
   239 
   240 #ifdef HAVE_XINPUT2_2
   241 
   242 struct xi_touch_point_t
   243 {
   244   struct xi_touch_point_t *next;
   245 
   246   int number;
   247   double x, y;
   248 };
   249 
   250 #endif
   251 
   252 struct xi_device_t
   253 {
   254   /* The numerical ID of this device.  */
   255   int device_id;
   256 
   257 #ifdef HAVE_XINPUT2_1
   258   /* The number of scroll valuators in `valuators'.  */
   259   int scroll_valuator_count;
   260 #endif
   261 
   262   /* Whether or not the device is grabbed and its use.  */
   263   int grab, use;
   264 
   265   /* The attached device.  Only valid if USE is some kind of master
   266      device.  */
   267   int attachment;
   268 
   269 #ifdef HAVE_XINPUT2_2
   270   /* Whether or not this device is a direct touch device.  */
   271   bool direct_p;
   272 #endif
   273 
   274 #ifdef HAVE_XINPUT2_1
   275   /* An array of scroll valuators Emacs knows about.  */
   276   struct xi_scroll_valuator_t *valuators;
   277 #endif
   278 
   279 #ifdef HAVE_XINPUT2_2
   280   /* An array of in-progress touchscreen events.  */
   281   struct xi_touch_point_t *touchpoints;
   282 #endif
   283 
   284   /* The name of this device.  */
   285   Lisp_Object name;
   286 
   287   /* The time at which `focus_frame' became the keyboard focus (only
   288      applies to master devices).  */
   289   Time focus_frame_time;
   290 
   291   /* The frame that is currently this device's keyboard focus, or
   292      NULL.  */
   293   struct frame *focus_frame;
   294 
   295   /* The time at which `focus_frame' became the implicit keyboard
   296      focus.  */
   297   Time focus_implicit_time;
   298 
   299   /* The frame that is currently this device's implicit keyboard
   300      focus, or NULL.  */
   301   struct frame *focus_implicit_frame;
   302 
   303   /* The window on which the last motion event happened.  */
   304   Window last_motion_window;
   305 
   306   /* The rounded integer coordinates of the last motion event.  */
   307   int last_motion_x, last_motion_y;
   308 };
   309 #endif
   310 
   311 extern Status x_parse_color (struct frame *, const char *, XColor *);
   312 
   313 struct x_failable_request
   314 {
   315   /* The first request making up this sequence.  */
   316   unsigned long start;
   317 
   318   /* If this is zero, then the request has not yet been made.
   319      Otherwise, this is the request that ends this sequence.  */
   320   unsigned long end;
   321 };
   322 
   323 #ifdef HAVE_XFIXES
   324 
   325 struct x_monitored_selection
   326 {
   327   /* The name of the selection.  */
   328   Atom name;
   329 
   330   /* The current owner of the selection.  */
   331   Window owner;
   332 };
   333 
   334 /* An invalid window.  */
   335 #define X_INVALID_WINDOW 0xffffffff
   336 
   337 #endif
   338 
   339 
   340 /* For each X display, we have a structure that records
   341    information about it.  */
   342 
   343 struct x_display_info
   344 {
   345   /* Chain of all x_display_info structures.  */
   346   struct x_display_info *next;
   347 
   348   /* The generic display parameters corresponding to this X display. */
   349   struct terminal *terminal;
   350 
   351   /* This says how to access this display in Xlib.  */
   352   Display *display;
   353 
   354   /* A connection number (file descriptor) for the display.  */
   355   int connection;
   356 
   357   /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).  */
   358   Lisp_Object name_list_element;
   359 
   360   /* Number of frames that are on this display.  */
   361   int reference_count;
   362 
   363   /* The Screen this connection is connected to.  */
   364   Screen *screen;
   365 
   366   /* Dots per inch of the screen.  */
   367   double resx, resy;
   368 
   369   /* The Visual being used for this display.  */
   370   Visual *visual;
   371 
   372   /* The visual information corresponding to VISUAL.  */
   373   XVisualInfo visual_info;
   374 
   375 #ifdef HAVE_XRENDER
   376   /* The picture format for this display.  */
   377   XRenderPictFormat *pict_format;
   378 #endif
   379 
   380   /* The colormap being used.  */
   381   Colormap cmap;
   382 
   383   /* Number of planes on this screen.  */
   384   int n_planes;
   385 
   386   /* Mask of things that cause the mouse to be grabbed.  */
   387   int grabbed;
   388 
   389   /* Emacs bitmap-id of the default icon bitmap for this frame.
   390      Or -1 if none has been allocated yet.  */
   391   ptrdiff_t icon_bitmap_id;
   392 
   393   /* The root window of this screen.  */
   394   Window root_window;
   395 
   396   /* Client leader window.  */
   397   Window client_leader_window;
   398 
   399   /* The cursor to use for vertical scroll bars.  */
   400   Cursor vertical_scroll_bar_cursor;
   401 
   402   /* The cursor to use for horizontal scroll bars.  */
   403   Cursor horizontal_scroll_bar_cursor;
   404 
   405   /* The invisible cursor used for pointer blanking.
   406      Unused if this display supports Xfixes extension.  */
   407   Cursor invisible_cursor;
   408 
   409 #ifdef HAVE_XFIXES
   410   /* Whether or not to use Xfixes for pointer blanking.  */
   411   bool fixes_pointer_blanking;
   412 #endif
   413 
   414 #ifdef USE_GTK
   415   /* The GDK cursor for scroll bars and popup menus.  */
   416   GdkCursor *xg_cursor;
   417 #endif
   418 
   419   /* X Resource data base */
   420   XrmDatabase rdb;
   421 
   422   /* Minimum width over all characters in all fonts in font_table.  */
   423   int smallest_char_width;
   424 
   425   /* Minimum font height over all fonts in font_table.  */
   426   int smallest_font_height;
   427 
   428   /* Reusable Graphics Context for drawing a cursor in a non-default face. */
   429   GC scratch_cursor_gc;
   430 
   431   /* Information about the range of text currently shown in
   432      mouse-face.  */
   433   Mouse_HLInfo mouse_highlight;
   434 
   435   /* Logical identifier of this display.  */
   436   unsigned x_id;
   437 
   438   /* Default name for all frames on this display.  */
   439   char *x_id_name;
   440 
   441   /* The number of fonts opened for this display.  */
   442   int n_fonts;
   443 
   444   /* Pointer to bitmap records.  */
   445   struct x_bitmap_record *bitmaps;
   446 
   447   /* Allocated size of bitmaps field.  */
   448   ptrdiff_t bitmaps_size;
   449 
   450   /* Last used bitmap index.  */
   451   ptrdiff_t bitmaps_last;
   452 
   453   /* Which modifier keys are on which modifier bits?
   454 
   455      With each keystroke, X returns eight bits indicating which modifier
   456      keys were held down when the key was pressed.  The interpretation
   457      of the top five modifier bits depends on what keys are attached
   458      to them.  If the Meta_L and Meta_R keysyms are on mod5, then mod5
   459      is the meta bit.
   460 
   461      meta_mod_mask is a mask containing the bits used for the meta key.
   462      It may have more than one bit set, if more than one modifier bit
   463      has meta keys on it.  Basically, if EVENT is a KeyPress event,
   464      the meta key is pressed if (EVENT.state & meta_mod_mask) != 0.
   465 
   466      shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the
   467      lock modifier bit, or zero otherwise.  Non-alphabetic keys should
   468      only be affected by the lock modifier bit if XK_Shift_Lock is in
   469      use; XK_Caps_Lock should only affect alphabetic keys.  With this
   470      arrangement, the lock modifier should shift the character if
   471      (EVENT.state & shift_lock_mask) != 0.  */
   472   unsigned int meta_mod_mask, shift_lock_mask;
   473 
   474   /* These are like meta_mod_mask, but for different modifiers.  */
   475   unsigned alt_mod_mask, super_mod_mask, hyper_mod_mask;
   476 
   477   /* Communication with window managers.  */
   478   Atom Xatom_wm_protocols;
   479 
   480   /* Kinds of protocol things we may receive.  */
   481   Atom Xatom_wm_take_focus;
   482   Atom Xatom_wm_save_yourself;
   483   Atom Xatom_wm_delete_window;
   484 
   485   /* Atom for indicating window state to the window manager.  */
   486   Atom Xatom_wm_change_state;
   487   Atom Xatom_wm_state;
   488 
   489   /* Other WM communication */
   490   Atom Xatom_wm_configure_denied; /* When our config request is denied */
   491   Atom Xatom_wm_window_moved;     /* When the WM moves us.  */
   492   Atom Xatom_wm_client_leader;    /* Id of client leader window.  */
   493   Atom Xatom_wm_transient_for;    /* Id of whatever window we are
   494                                      transient for. */
   495 
   496   /* EditRes protocol */
   497   Atom Xatom_editres;
   498 
   499   /* More atoms, which are selection types.  */
   500   Atom Xatom_CLIPBOARD, Xatom_TIMESTAMP, Xatom_TEXT, Xatom_DELETE,
   501     Xatom_COMPOUND_TEXT, Xatom_UTF8_STRING,
   502     Xatom_MULTIPLE, Xatom_INCR, Xatom_EMACS_TMP, Xatom_TARGETS, Xatom_NULL,
   503     Xatom_ATOM, Xatom_ATOM_PAIR, Xatom_CLIPBOARD_MANAGER,
   504     Xatom_EMACS_SERVER_TIME_PROP;
   505 
   506   /* More atoms for font properties.  The last three are private
   507      properties, see the comments in src/fontset.h.  */
   508   Atom Xatom_PIXEL_SIZE, Xatom_AVERAGE_WIDTH,
   509     Xatom_MULE_BASELINE_OFFSET, Xatom_MULE_RELATIVE_COMPOSE,
   510     Xatom_MULE_DEFAULT_ASCENT;
   511 
   512   /* More atoms for Ghostscript support.  */
   513   Atom Xatom_DONE, Xatom_PAGE;
   514 
   515   /* Atoms used in toolkit scroll bar client messages.  */
   516   Atom Xatom_Scrollbar, Xatom_Horizontal_Scrollbar;
   517 
   518   /* Atom used in XEmbed client messages.  */
   519   Atom Xatom_XEMBED, Xatom_XEMBED_INFO;
   520 
   521   /* Atom used to determine whether or not the screen is composited.  */
   522   Atom Xatom_NET_WM_CM_Sn;
   523 
   524   /* Atoms used by the Motif drag and drop protocols.  */
   525   Atom Xatom_MOTIF_WM_HINTS, Xatom_MOTIF_DRAG_WINDOW,
   526     Xatom_MOTIF_DRAG_TARGETS, Xatom_MOTIF_DRAG_AND_DROP_MESSAGE,
   527     Xatom_MOTIF_DRAG_INITIATOR_INFO, Xatom_MOTIF_DRAG_RECEIVER_INFO;
   528 
   529   /* Atoms used by Emacs internally.  */
   530   Atom Xatom_EMACS_DRAG_ATOM;
   531 
   532   /* Special selections used by the Motif drop protocol to indicate
   533      success or failure.  */
   534   Atom Xatom_XmTRANSFER_SUCCESS, Xatom_XmTRANSFER_FAILURE;
   535 
   536   /* Atoms used by both versions of the OffiX DND protocol (the "old
   537      KDE" protocol in x-dnd.el). */
   538   Atom Xatom_DndProtocol, Xatom_DND_PROTOCOL;
   539 
   540   /* The frame (if any) which has the X window that has keyboard focus.
   541      Zero if none.  This is examined by Ffocus_frame in xfns.c.  Note
   542      that a mere EnterNotify event can set this; if you need to know the
   543      last frame specified in a FocusIn or FocusOut event, use
   544      x_focus_event_frame.  */
   545   struct frame *x_focus_frame;
   546 
   547   /* The last frame mentioned in a FocusIn or FocusOut event.  This is
   548      separate from x_focus_frame, because whether or not LeaveNotify
   549      events cause us to lose focus depends on whether or not we have
   550      received a FocusIn event for it.
   551 
   552      This field is not used when the input extension is being
   553      utilized.  */
   554   struct frame *x_focus_event_frame;
   555 
   556   /* The frame which currently has the visual highlight, and should get
   557      keyboard input (other sorts of input have the frame encoded in the
   558      event).  It points to the X focus frame's selected window's
   559      frame.  It differs from x_focus_frame when we're using a global
   560      minibuffer.  */
   561   struct frame *highlight_frame;
   562 
   563   /* The frame waiting to be auto-raised in XTread_socket.  */
   564   struct frame *x_pending_autoraise_frame;
   565 
   566   /* The frame where the mouse was last time we reported a ButtonPress event.  */
   567   struct frame *last_mouse_frame;
   568 
   569   /* The frame where the mouse was last time we reported a mouse position.  */
   570   struct frame *last_mouse_glyph_frame;
   571 
   572   /* The frame where the mouse was last time we reported a mouse motion.  */
   573   struct frame *last_mouse_motion_frame;
   574 
   575   /* The scroll bar in which the last X motion event occurred.  */
   576   struct scroll_bar *last_mouse_scroll_bar;
   577 
   578   /* Time of last user interaction as returned in X events on this
   579      display.  */
   580   Time last_user_time;
   581 
   582   /* Position where the mouse was last time we reported a motion.
   583      This is a position on last_mouse_motion_frame.  It is used in
   584      some situations to report the mouse position as well: see
   585      XTmouse_position.  */
   586   int last_mouse_motion_x;
   587   int last_mouse_motion_y;
   588 
   589   /* Where the mouse was last time we reported a mouse position.
   590      This is a rectangle on last_mouse_glyph_frame.  */
   591   XRectangle last_mouse_glyph;
   592 
   593   /* Time of last mouse movement on this display.  This is a hack because
   594      we would really prefer that XTmouse_position would return the time
   595      associated with the position it returns, but there doesn't seem to be
   596      any way to wrest the time-stamp from the server along with the position
   597      query.  So, we just keep track of the time of the last movement we
   598      received, and return that in hopes that it's somewhat accurate.  */
   599   Time last_mouse_movement_time;
   600 
   601   /* Whether or not the last mouse motion was synthetic.  */
   602   bool last_mouse_movement_time_send_event;
   603 
   604   /* The gray pixmap.  */
   605   Pixmap gray;
   606 
   607 #ifdef HAVE_X_I18N
   608   /* XIM (X Input method).  */
   609   XIM xim;
   610   XIMStyles *xim_styles;
   611   struct xim_inst_t *xim_callback_data;
   612   XIMStyle preferred_xim_style;
   613 
   614   /* The named coding system to use for this input method.  */
   615   Lisp_Object xim_coding;
   616 #endif
   617 
   618   /* A cache mapping color names to RGB values.  */
   619   struct color_name_cache_entry **color_names;
   620 
   621   /* The number of buckets for each hash in that hash table.  */
   622   ptrdiff_t *color_names_length;
   623 
   624   /* The size of that hash table.  */
   625   int color_names_size;
   626 
   627   /* If non-null, a cache of the colors in the color map.  Don't
   628      use this directly, call x_color_cells instead.  */
   629   XColor *color_cells;
   630   int ncolor_cells;
   631 
   632   /* Bits and shifts to use to compose pixel values on TrueColor visuals.  */
   633   int red_bits, blue_bits, green_bits, alpha_bits;
   634   int red_offset, blue_offset, green_offset, alpha_offset;
   635   unsigned long alpha_mask;
   636 
   637   /* The type of window manager we have.  If we move FRAME_OUTER_WINDOW
   638      to x/y 0/0, some window managers (type A) puts the window manager
   639      decorations outside the screen and FRAME_OUTER_WINDOW exactly at 0/0.
   640      Other window managers (type B) puts the window including decorations
   641      at 0/0, so FRAME_OUTER_WINDOW is a bit below 0/0.
   642      Record the type of WM in use so we can compensate for type A WMs.  */
   643   enum
   644     {
   645       X_WMTYPE_UNKNOWN,
   646       X_WMTYPE_A,
   647       X_WMTYPE_B
   648     } wm_type;
   649 
   650 
   651   /* Atoms that are drag and drop atoms */
   652   Atom *x_dnd_atoms;
   653   ptrdiff_t x_dnd_atoms_size;
   654   ptrdiff_t x_dnd_atoms_length;
   655 
   656   /* The unique drag and drop atom used on Motif.  None if it was not
   657      already computed.  */
   658   Atom motif_drag_atom;
   659 
   660   /* Its name.  */
   661   char motif_drag_atom_name[sizeof "_EMACS_ATOM_%lu" - 3
   662                             + INT_STRLEN_BOUND (unsigned long)];
   663 
   664   /* When it was owned.  */
   665   Time motif_drag_atom_time;
   666 
   667   /* The frame that currently owns `motif_drag_atom'.  */
   668   struct frame *motif_drag_atom_owner;
   669 
   670   /* The drag window for this display.  */
   671   Window motif_drag_window;
   672 
   673   /* Extended window manager hints, Atoms supported by the window manager and
   674      atoms for setting the window type.  */
   675   Atom Xatom_net_supported, Xatom_net_supporting_wm_check;
   676   Atom *net_supported_atoms;
   677   int nr_net_supported_atoms;
   678   Window net_supported_window;
   679   Atom Xatom_net_window_type, Xatom_net_window_type_tooltip;
   680   Atom Xatom_net_active_window;
   681 
   682   /* Atoms dealing with EWMH (i.e. _NET_...) */
   683   Atom Xatom_net_wm_state, Xatom_net_wm_state_fullscreen,
   684     Xatom_net_wm_state_maximized_horz, Xatom_net_wm_state_maximized_vert,
   685     Xatom_net_wm_state_sticky, Xatom_net_wm_state_above, Xatom_net_wm_state_below,
   686     Xatom_net_wm_state_hidden, Xatom_net_wm_state_skip_taskbar,
   687     Xatom_net_wm_state_shaded, Xatom_net_frame_extents, Xatom_net_current_desktop,
   688     Xatom_net_workarea, Xatom_net_wm_opaque_region, Xatom_net_wm_ping,
   689     Xatom_net_wm_sync_request, Xatom_net_wm_sync_request_counter,
   690     Xatom_net_wm_sync_fences, Xatom_net_wm_frame_drawn, Xatom_net_wm_frame_timings,
   691     Xatom_net_wm_user_time, Xatom_net_wm_user_time_window,
   692     Xatom_net_client_list_stacking, Xatom_net_wm_pid,
   693     Xatom_net_wm_bypass_compositor;
   694 
   695   /* XSettings atoms and windows.  */
   696   Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr;
   697   Window xsettings_window;
   698 
   699   /* Frame name and icon name */
   700   Atom Xatom_net_wm_name, Xatom_net_wm_icon_name;
   701   /* Frame opacity */
   702   Atom Xatom_net_wm_window_opacity;
   703 
   704   /* SM */
   705   Atom Xatom_SM_CLIENT_ID;
   706 
   707   /* DND source.  */
   708   Atom Xatom_XdndAware, Xatom_XdndSelection, Xatom_XdndTypeList,
   709     Xatom_XdndActionCopy, Xatom_XdndActionMove, Xatom_XdndActionLink,
   710     Xatom_XdndActionAsk, Xatom_XdndActionPrivate, Xatom_XdndActionList,
   711     Xatom_XdndActionDescription, Xatom_XdndProxy, Xatom_XdndEnter,
   712     Xatom_XdndPosition, Xatom_XdndStatus, Xatom_XdndLeave, Xatom_XdndDrop,
   713     Xatom_XdndFinished;
   714 
   715   /* XDS source and target.  */
   716   Atom Xatom_XdndDirectSave0, Xatom_XdndActionDirectSave, Xatom_text_plain;
   717 
   718 #ifdef HAVE_XKB
   719   /* Virtual modifiers */
   720   Atom Xatom_Meta, Xatom_Super, Xatom_Hyper, Xatom_ShiftLock, Xatom_Alt;
   721 #endif
   722 
   723   /* Core modifier map when XKB is not present.  */
   724   XModifierKeymap *modmap;
   725 
   726 #ifdef HAVE_XRANDR
   727   bool xrandr_supported_p;
   728   int xrandr_event_base;
   729   int xrandr_error_base;
   730   int xrandr_major_version;
   731   int xrandr_minor_version;
   732 #endif
   733 
   734 #if defined HAVE_XRANDR || defined USE_GTK
   735   /* This is used to determine if the monitor configuration really
   736      changed upon receiving a monitor change event.  */
   737   Lisp_Object last_monitor_attributes_list;
   738 #endif
   739 
   740 #if defined USE_CAIRO || defined HAVE_XRENDER
   741   XExtCodes *ext_codes;
   742 #endif
   743 
   744 #ifdef USE_XCB
   745   xcb_connection_t *xcb_connection;
   746   xcb_visualtype_t *xcb_visual;
   747 #endif
   748 
   749 #ifdef HAVE_XDBE
   750   bool supports_xdbe;
   751 #endif
   752 
   753 #ifdef HAVE_XINPUT2
   754   bool supports_xi2;
   755 
   756   /* The minor version of the input extension.  (Major is always
   757      2.x.) */
   758   int xi2_version;
   759 
   760   /* The generic event opcode of XI2 events.  */
   761   int xi2_opcode;
   762 
   763   /* The number of devices on this display known to Emacs.  */
   764   int num_devices;
   765 
   766   /* Array of all input extension devices on this display known to
   767      Emacs.  */
   768   struct xi_device_t *devices;
   769 
   770   /* Pending keystroke time.  */
   771   Time pending_keystroke_time;
   772 
   773   /* Pending keystroke source.  If a core KeyPress event arrives with
   774      the same timestamp as pending_keystroke_time, it will be treated
   775      as originating from this device.  */
   776   int pending_keystroke_source;
   777 
   778 #if defined USE_GTK && !defined HAVE_GTK3
   779   /* This means the two variables above shouldn't be reset the first
   780      time a KeyPress event arrives, since they were set from a raw key
   781      press event that was sent before the first (real, not sent by an
   782      input method) core key event.  */
   783   bool pending_keystroke_time_special_p;
   784 #endif
   785 
   786   /* The client pointer.  We keep a record client-side to avoid
   787      calling XISetClientPointer all the time.  */
   788   int client_pointer_device;
   789 #endif
   790 
   791 #ifdef HAVE_XKB
   792   bool supports_xkb;
   793   int xkb_event_type;
   794   XkbDescPtr xkb_desc;
   795 #endif
   796 
   797 #ifdef USE_GTK
   798   bool prefer_native_input;
   799 #endif
   800 
   801 #ifdef HAVE_XRENDER
   802   bool xrender_supported_p;
   803   int xrender_major;
   804   int xrender_minor;
   805 #endif
   806 
   807 #ifdef HAVE_XFIXES
   808   bool xfixes_supported_p;
   809   int xfixes_major;
   810   int xfixes_minor;
   811   int xfixes_event_base;
   812 #endif
   813 
   814 #ifdef HAVE_XSYNC
   815   bool xsync_supported_p;
   816   int xsync_major;
   817   int xsync_minor;
   818 #endif
   819 
   820 #ifdef HAVE_XINERAMA
   821   bool xinerama_supported_p;
   822 #endif
   823 
   824 #ifdef HAVE_XCOMPOSITE
   825   bool composite_supported_p;
   826   int composite_major;
   827   int composite_minor;
   828 #endif
   829 
   830 #ifdef HAVE_XSHAPE
   831   bool xshape_supported_p;
   832   int xshape_major;
   833   int xshape_minor;
   834   int xshape_event_base;
   835   int xshape_error_base;
   836 #endif
   837 
   838 #ifdef USE_TOOLKIT_SCROLL_BARS
   839   Lisp_Object *protected_windows;
   840   int n_protected_windows;
   841   int protected_windows_max;
   842 #endif
   843 
   844   /* The current dimensions of the screen.  This is updated when a
   845      ConfigureNotify is received for the root window, and is zero if
   846      that didn't happen.  */
   847   int screen_width;
   848   int screen_height;
   849 
   850   /* The mm width and height of the screen.  Updated on
   851      RRScreenChangeNotify.  */
   852   int screen_mm_width;
   853   int screen_mm_height;
   854 
   855   /* Circular buffer of request serial ranges to ignore inside an
   856      error handler in increasing order.  */
   857   struct x_failable_request failable_requests[N_FAILABLE_REQUESTS];
   858 
   859   /* Pointer to the next request in `failable_requests'.  */
   860   struct x_failable_request *next_failable_request;
   861 
   862 #ifdef HAVE_XFIXES
   863   /* Array of selections being monitored and their owners.  */
   864   struct x_monitored_selection *monitored_selections;
   865 
   866   /* Window used to monitor those selections.  */
   867   Window selection_tracking_window;
   868 
   869   /* The number of those selections.  */
   870   int n_monitored_selections;
   871 #endif
   872 
   873   /* The pending drag-and-drop time for middle-click based
   874      drag-and-drop emulation.  */
   875   Time pending_dnd_time;
   876 
   877 #if defined HAVE_XSYNC && !defined USE_GTK && defined HAVE_CLOCK_GETTIME
   878   /* Whether or not the server time is probably the same as
   879      "clock_gettime (CLOCK_MONOTONIC, ...)".  */
   880   bool server_time_monotonic_p;
   881 
   882   /* The time difference between the X server clock and the monotonic
   883      clock, or 0 if unknown (if the difference is legitimately 0,
   884      server_time_monotonic_p will be true).  */
   885   int_fast64_t server_time_offset;
   886 #endif
   887 };
   888 
   889 #ifdef HAVE_X_I18N
   890 /* Whether or not to use XIM if we have it.  */
   891 extern bool use_xim;
   892 #endif
   893 
   894 #ifdef HAVE_XINPUT2
   895 /* Defined in xmenu.c. */
   896 extern int popup_activated_flag;
   897 #endif
   898 
   899 /* This is a chain of structures for all the X displays currently in use.  */
   900 extern struct x_display_info *x_display_list;
   901 
   902 extern struct x_display_info *x_display_info_for_display (Display *);
   903 extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
   904 extern struct x_display_info *x_term_init (Lisp_Object, char *, char *);
   905 extern bool x_display_ok (const char *);
   906 
   907 extern void select_visual (struct x_display_info *);
   908 
   909 extern Window tip_window;
   910 extern Lisp_Object tip_dx;
   911 extern Lisp_Object tip_dy;
   912 extern Lisp_Object tip_frame;
   913 
   914 /* Each X frame object points to its own struct x_output object
   915    in the output_data.x field.  The x_output structure contains
   916    the information that is specific to X windows.  */
   917 
   918 struct x_output
   919 {
   920 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
   921   /* Height of menu bar widget, in pixels.  This value
   922      is not meaningful if the menubar is turned off.  */
   923   int menubar_height;
   924 #endif
   925 
   926   /* Height of tool bar widget, in pixels.  top_height is used if tool bar
   927      at top, bottom_height if tool bar is at the bottom.
   928      Zero if not using an external tool bar or if tool bar is vertical.  */
   929   int toolbar_top_height, toolbar_bottom_height;
   930 
   931   /* Width of tool bar widget, in pixels.  left_width is used if tool bar
   932      at left, right_width if tool bar is at the right.
   933      Zero if not using an external tool bar or if tool bar is horizontal.  */
   934   int toolbar_left_width, toolbar_right_width;
   935 
   936   /* The tiled border used when the mouse is out of the frame.  */
   937   Pixmap border_tile;
   938 
   939   /* Here are the Graphics Contexts for the default font.  */
   940   GC normal_gc;                         /* Normal video */
   941   GC reverse_gc;                        /* Reverse video */
   942   GC cursor_gc;                         /* cursor drawing */
   943 
   944   /* The X window used for this frame.
   945      May be zero while the frame object is being created
   946      and the X window has not yet been created.  */
   947   Window window_desc;
   948 
   949   /* The drawable to which we're rendering.  In the single-buffered
   950      base, the window itself.  In the double-buffered case, the
   951      window's back buffer.  */
   952   Drawable draw_desc;
   953 
   954 #ifdef HAVE_XRENDER
   955   /* The Xrender picture that corresponds to this drawable.  None
   956      means no picture format was found, or the Xrender extension is
   957      not present.  */
   958   Picture picture;
   959 #endif
   960 
   961   /* The X window used for the bitmap icon;
   962      or 0 if we don't have a bitmap icon.  */
   963   Window icon_desc;
   964 
   965   /* The X window that is the parent of this X window.
   966      Usually this is a window that was made by the window manager,
   967      but it can be the root window, and it can be explicitly specified
   968      (see the explicit_parent field, below).  */
   969   Window parent_desc;
   970 
   971 #ifdef USE_X_TOOLKIT
   972   /* The widget of this screen.  This is the window of a "shell" widget.  */
   973   Widget widget;
   974   /* The XmPanedWindows...  */
   975   Widget column_widget;
   976   /* The widget of the edit portion of this screen; the window in
   977      "window_desc" is inside of this.  */
   978   Widget edit_widget;
   979 
   980   Widget menubar_widget;
   981 #endif
   982 
   983 #ifndef USE_GTK
   984   /* A window used to store the user time property.  May be None or
   985      the frame's outer window.  */
   986   Window user_time_window;
   987 #endif
   988 
   989 #ifdef USE_GTK
   990   /* The widget of this screen.  This is the window of a top widget.  */
   991   GtkWidget *widget;
   992   /* The widget of the edit portion of this screen; the window in
   993      "window_desc" is inside of this.  */
   994   GtkWidget *edit_widget;
   995   /* The widget used for laying out widgets vertically.  */
   996   GtkWidget *vbox_widget;
   997   /* The widget used for laying out widgets horizontally.  */
   998   GtkWidget *hbox_widget;
   999   /* The menubar in this frame.  */
  1000   GtkWidget *menubar_widget;
  1001   /* The tool bar in this frame  */
  1002   GtkWidget *toolbar_widget;
  1003   /* True if tool bar is packed into the hbox widget (i.e. vertical).  */
  1004   bool_bf toolbar_in_hbox : 1;
  1005   bool_bf toolbar_is_packed : 1;
  1006 
  1007   /* The last size hints set.  */
  1008   GdkGeometry size_hints;
  1009   long hint_flags;
  1010 
  1011   GtkTooltip *ttip_widget;
  1012   GtkWidget *ttip_lbl;
  1013   GtkWindow *ttip_window;
  1014 
  1015   GtkIMContext *im_context;
  1016 
  1017 #ifdef HAVE_GTK3
  1018   /* The CSS providers used for scroll bar foreground and background
  1019      colors.  */
  1020   GtkCssProvider *scrollbar_foreground_css_provider;
  1021   GtkCssProvider *scrollbar_background_css_provider;
  1022 #endif
  1023 #endif /* USE_GTK */
  1024 
  1025   /* If >=0, a bitmap index.  The indicated bitmap is used for the
  1026      icon. */
  1027   ptrdiff_t icon_bitmap;
  1028 
  1029   /* Default ASCII font of this frame.  */
  1030   struct font *font;
  1031 
  1032   /* The baseline offset of the default ASCII font.  */
  1033   int baseline_offset;
  1034 
  1035   /* If a fontset is specified for this frame instead of font, this
  1036      value contains an ID of the fontset, else -1.  */
  1037   int fontset;
  1038 
  1039   unsigned long cursor_pixel;
  1040   unsigned long border_pixel;
  1041   unsigned long mouse_pixel;
  1042   unsigned long cursor_foreground_pixel;
  1043 
  1044   /* Foreground color for scroll bars.  A value of -1 means use the
  1045      default (black for non-toolkit scroll bars).  */
  1046   unsigned long scroll_bar_foreground_pixel;
  1047 
  1048   /* Background color for scroll bars.  A value of -1 means use the
  1049      default (background color of the frame for non-toolkit scroll
  1050      bars).  */
  1051   unsigned long scroll_bar_background_pixel;
  1052 
  1053 #if defined (USE_LUCID) && defined (USE_TOOLKIT_SCROLL_BARS)
  1054   /* Top and bottom shadow colors for 3D Lucid scrollbars.
  1055      -1 means let the scroll compute them itself.  */
  1056   unsigned long scroll_bar_top_shadow_pixel;
  1057   unsigned long scroll_bar_bottom_shadow_pixel;
  1058 #endif
  1059 
  1060   /* Descriptor for the cursor in use for this window.  */
  1061   Cursor text_cursor;
  1062   Cursor nontext_cursor;
  1063   Cursor modeline_cursor;
  1064   Cursor hand_cursor;
  1065   Cursor hourglass_cursor;
  1066   Cursor horizontal_drag_cursor;
  1067   Cursor vertical_drag_cursor;
  1068   Cursor current_cursor;
  1069   Cursor left_edge_cursor;
  1070   Cursor top_left_corner_cursor;
  1071   Cursor top_edge_cursor;
  1072   Cursor top_right_corner_cursor;
  1073   Cursor right_edge_cursor;
  1074   Cursor bottom_right_corner_cursor;
  1075   Cursor bottom_edge_cursor;
  1076   Cursor bottom_left_corner_cursor;
  1077 
  1078   /* Window whose cursor is hourglass_cursor.  This window is temporarily
  1079      mapped to display an hourglass cursor.  */
  1080   Window hourglass_window;
  1081 
  1082   /* These are the current window manager hints.  It seems that
  1083      XSetWMHints, when presented with an unset bit in the `flags'
  1084      member of the hints structure, does not leave the corresponding
  1085      attribute unchanged; rather, it resets that attribute to its
  1086      default value.  For example, unless you set the `icon_pixmap'
  1087      field and the `IconPixmapHint' bit, XSetWMHints will forget what
  1088      your icon pixmap was.  This is rather troublesome, since some of
  1089      the members (for example, `input' and `icon_pixmap') want to stay
  1090      the same throughout the execution of Emacs.  So, we keep this
  1091      structure around, just leaving values in it and adding new bits
  1092      to the mask as we go.  */
  1093   XWMHints wm_hints;
  1094 
  1095   /* This is the Emacs structure for the X display this frame is on.  */
  1096   struct x_display_info *display_info;
  1097 
  1098   /* This is a button event that wants to activate the menubar.
  1099      We save it here until the command loop gets to think about it.  */
  1100   XEvent *saved_menu_event;
  1101 
  1102   /* This is the widget id used for this frame's menubar in lwlib.  */
  1103 #ifdef USE_X_TOOLKIT
  1104   int id;
  1105 #endif
  1106 
  1107   /* True means hourglass cursor is currently displayed.  */
  1108   bool_bf hourglass_p : 1;
  1109 
  1110   /* True means our parent is another application's window
  1111      and was explicitly specified.  */
  1112   bool_bf explicit_parent : 1;
  1113 
  1114   /* True means tried already to make this frame visible.  */
  1115   bool_bf asked_for_visible : 1;
  1116 
  1117   /* True if this frame was ever previously visible.  */
  1118   bool_bf has_been_visible : 1;
  1119 
  1120   /* Xt waits for a ConfigureNotify event from the window manager in
  1121      EmacsFrameSetCharSize when the shell widget is resized.  For some
  1122      window managers like fvwm2 2.2.5 and KDE 2.1 this event doesn't
  1123      arrive for an unknown reason and Emacs hangs in Xt.  If this is
  1124      false, tell Xt not to wait.  */
  1125   bool_bf wait_for_wm : 1;
  1126 
  1127   /* True if this frame's alpha value is the same for both the active
  1128      and inactive states.  */
  1129   bool_bf alpha_identical_p : 1;
  1130 
  1131 #ifdef HAVE_XDBE
  1132   /* Flag that indicates whether we've modified the back buffer and
  1133      need to publish our modifications to the front buffer at a
  1134      convenient time.  */
  1135   bool_bf need_buffer_flip : 1;
  1136 
  1137   /* Flag that indicates whether or not the frame contents are
  1138      complete and can be safely flushed while handling async
  1139      input.  */
  1140   bool_bf complete : 1;
  1141 #endif
  1142 
  1143 #ifdef HAVE_X_I18N
  1144   /* Input context (currently, this means Compose key handler setup).  */
  1145   XIC xic;
  1146   XIMStyle xic_style;
  1147   XFontSet xic_xfs;
  1148 #endif
  1149 
  1150 #ifdef HAVE_XSYNC
  1151   /* The "basic frame counter" used for resize synchronization.  */
  1152   XSyncCounter basic_frame_counter;
  1153 
  1154   /* The "extended frame counter" used for frame synchronization.  */
  1155   XSyncCounter extended_frame_counter;
  1156 
  1157   /* The pending value of the basic counter.  */
  1158   XSyncValue pending_basic_counter_value;
  1159 
  1160   /* The current value of the extended counter.  */
  1161   XSyncValue current_extended_counter_value;
  1162 
  1163   /* The configure event value of the extended counter.  */
  1164   XSyncValue resize_counter_value;
  1165 
  1166   /* Whether or not basic resize synchronization is in progress.  */
  1167   bool_bf sync_end_pending_p : 1;
  1168 
  1169   /* Whether or not extended resize synchronization is in
  1170      progress.  */
  1171   bool_bf ext_sync_end_pending_p : 1;
  1172 
  1173 #ifdef HAVE_GTK3
  1174   /* Whether or not GDK resize synchronization is in progress.  */
  1175   bool_bf xg_sync_end_pending_p : 1;
  1176 #endif
  1177 
  1178   /* Whether or Emacs is waiting for the compositing manager to draw a
  1179      frame.  */
  1180   bool_bf waiting_for_frame_p : 1;
  1181 
  1182   /* Whether or not Emacs just skipped waiting for a frame due to a
  1183      timeout.  */
  1184   bool_bf draw_just_hung_p : 1;
  1185 
  1186 #if !defined USE_GTK && defined HAVE_CLOCK_GETTIME
  1187   /* Whether or not Emacs should wait for the compositing manager to
  1188      draw frames before starting a new frame.  */
  1189   bool_bf use_vsync_p : 1;
  1190 
  1191   /* The time (in microseconds) it took to draw the last frame.  */
  1192   uint_fast64_t last_frame_time;
  1193 
  1194   /* A temporary time used to calculate that value.  */
  1195   uint_fast64_t temp_frame_time;
  1196 
  1197 #ifdef HAVE_XSYNCTRIGGERFENCE
  1198   /* An array of two sync fences that are triggered in order after a
  1199      frame completes.  Not initialized if the XSync extension is too
  1200      old to support sync fences.  */
  1201   XSyncFence sync_fences[2];
  1202 #endif
  1203 #endif
  1204 #endif
  1205 
  1206   /* Relief GCs, colors etc.  */
  1207   struct relief
  1208   {
  1209     GC gc;
  1210     unsigned long pixel;
  1211   }
  1212   black_relief, white_relief;
  1213 
  1214   /* The background for which the above relief GCs were set up.
  1215      They are changed only when a different background is involved.  */
  1216   unsigned long relief_background;
  1217 
  1218   /* Keep track of focus.  May be EXPLICIT if we received a FocusIn for this
  1219      frame, or IMPLICIT if we received an EnterNotify.
  1220      FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT.
  1221 
  1222      Not used when the input extension is being utilized.  */
  1223   int focus_state;
  1224 
  1225   /* The offset we need to add to compensate for type A WMs.  */
  1226   int move_offset_top;
  1227   int move_offset_left;
  1228 
  1229 /* Extreme 'short' and 'long' values suitable for libX11.  */
  1230 #define X_SHRT_MAX 0x7fff
  1231 #define X_SHRT_MIN (-1 - X_SHRT_MAX)
  1232 #define X_LONG_MAX 0x7fffffff
  1233 #define X_LONG_MIN (-1 - X_LONG_MAX)
  1234 #define X_ULONG_MAX 0xffffffffUL
  1235 
  1236 #ifdef USE_CAIRO
  1237   /* Cairo drawing context.  */
  1238   cairo_t *cr_context;
  1239   /* Width and height reported by the last ConfigureNotify event.
  1240      They are used when creating the cairo surface next time.  */
  1241   int cr_surface_desired_width, cr_surface_desired_height;
  1242 #endif
  1243 
  1244 #ifdef HAVE_X_I18N
  1245   ptrdiff_t preedit_size;
  1246   char *preedit_chars;
  1247   bool preedit_active;
  1248   int preedit_caret;
  1249 #endif
  1250 
  1251 #ifdef HAVE_XINPUT2
  1252   XIEventMask *xi_masks;
  1253   int num_xi_masks;
  1254 #endif
  1255 
  1256   /* Whether or not we are certain we know the offset from the root
  1257      window to this frame.  */
  1258   bool window_offset_certain_p;
  1259 
  1260   /* The offset of the edit window from the root window.  This is
  1261      strictly an optimization to avoid extraneous synchronizing in
  1262      some cases.  */
  1263   int root_x, root_y;
  1264 };
  1265 
  1266 enum
  1267 {
  1268   /* Values for focus_state, used as bit mask.
  1269      EXPLICIT means we received a FocusIn for the frame and know it has
  1270      the focus.  IMPLICIT means we received an EnterNotify and the frame
  1271      may have the focus if no window manager is running.
  1272      FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
  1273   FOCUS_NONE     = 0,
  1274   FOCUS_IMPLICIT = 1,
  1275   FOCUS_EXPLICIT = 2
  1276 };
  1277 
  1278 /* Return the X output data for frame F.  */
  1279 #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
  1280 #define FRAME_OUTPUT_DATA(f) FRAME_X_OUTPUT (f)
  1281 
  1282 /* Return the X window used for displaying data in frame F.  */
  1283 #define FRAME_X_WINDOW(f) ((f)->output_data.x->window_desc)
  1284 #define FRAME_NATIVE_WINDOW(f) FRAME_X_WINDOW (f)
  1285 
  1286 /* Return the drawable used for rendering to frame F.  */
  1287 #define FRAME_X_RAW_DRAWABLE(f) ((f)->output_data.x->draw_desc)
  1288 
  1289 extern void x_mark_frame_dirty (struct frame *f);
  1290 
  1291 /* Return the drawable used for rendering to frame F and mark the
  1292    frame as needing a buffer flip later.  There's no easy way to run
  1293    code after any drawing command, but we can run code whenever
  1294    someone asks for the handle necessary to draw.  */
  1295 #define FRAME_X_DRAWABLE(f)                             \
  1296   (x_mark_frame_dirty ((f)), FRAME_X_RAW_DRAWABLE ((f)))
  1297 
  1298 #ifdef HAVE_XDBE
  1299 #define FRAME_X_DOUBLE_BUFFERED_P(f)            \
  1300   (FRAME_X_WINDOW (f) != FRAME_X_RAW_DRAWABLE (f))
  1301 
  1302 /* Return the need-buffer-flip flag for frame F.  */
  1303 #define FRAME_X_NEED_BUFFER_FLIP(f) ((f)->output_data.x->need_buffer_flip)
  1304 
  1305 /* Return whether or not the frame F has been completely drawn.  Used
  1306    while handling async input.  */
  1307 #define FRAME_X_COMPLETE_P(f) ((f)->output_data.x->complete)
  1308 #endif
  1309 
  1310 /* Return the outermost X window associated with the frame F.  */
  1311 #ifdef USE_X_TOOLKIT
  1312 #define FRAME_OUTER_WINDOW(f) ((f)->output_data.x->widget ?             \
  1313                                XtWindow ((f)->output_data.x->widget) :  \
  1314                                FRAME_X_WINDOW (f))
  1315 #else
  1316 #ifdef USE_GTK
  1317 
  1318 #ifdef HAVE_GTK3
  1319 #define DEFAULT_GDK_DISPLAY() \
  1320   gdk_x11_display_get_xdisplay (gdk_display_get_default ())
  1321 #else
  1322 #undef GDK_WINDOW_XID
  1323 #define GDK_WINDOW_XID(w) GDK_WINDOW_XWINDOW (w)
  1324 #define DEFAULT_GDK_DISPLAY() GDK_DISPLAY ()
  1325 #define gtk_widget_get_preferred_size(a, ign, b) \
  1326   gtk_widget_size_request (a, b)
  1327 #endif
  1328 
  1329 #define GTK_WIDGET_TO_X_WIN(w) \
  1330   ((w) && gtk_widget_get_window (w) \
  1331    ? GDK_WINDOW_XID (gtk_widget_get_window (w)) : 0)
  1332 
  1333 #define FRAME_GTK_OUTER_WIDGET(f) ((f)->output_data.x->widget)
  1334 #define FRAME_GTK_WIDGET(f) ((f)->output_data.x->edit_widget)
  1335 #define FRAME_OUTER_WINDOW(f)                                   \
  1336        (FRAME_GTK_OUTER_WIDGET (f) ?                            \
  1337         GTK_WIDGET_TO_X_WIN (FRAME_GTK_OUTER_WIDGET (f)) :      \
  1338          FRAME_X_WINDOW (f))
  1339 
  1340 #else /* !USE_GTK */
  1341 #define FRAME_OUTER_WINDOW(f) (FRAME_X_WINDOW (f))
  1342 #endif /* !USE_GTK */
  1343 #endif
  1344 
  1345 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
  1346 #define FRAME_MENUBAR_HEIGHT(f) ((f)->output_data.x->menubar_height)
  1347 #else
  1348 #define FRAME_MENUBAR_HEIGHT(f) ((void) f, 0)
  1349 #endif /* USE_X_TOOLKIT || USE_GTK */
  1350 
  1351 #define FRAME_FONT(f) ((f)->output_data.x->font)
  1352 #define FRAME_FONTSET(f) ((f)->output_data.x->fontset)
  1353 #define FRAME_TOOLBAR_TOP_HEIGHT(f) ((f)->output_data.x->toolbar_top_height)
  1354 #define FRAME_TOOLBAR_BOTTOM_HEIGHT(f) \
  1355   ((f)->output_data.x->toolbar_bottom_height)
  1356 #define FRAME_TOOLBAR_HEIGHT(f) \
  1357   (FRAME_TOOLBAR_TOP_HEIGHT (f) + FRAME_TOOLBAR_BOTTOM_HEIGHT (f))
  1358 #define FRAME_TOOLBAR_LEFT_WIDTH(f) ((f)->output_data.x->toolbar_left_width)
  1359 #define FRAME_TOOLBAR_RIGHT_WIDTH(f) ((f)->output_data.x->toolbar_right_width)
  1360 #define FRAME_TOOLBAR_WIDTH(f) \
  1361   (FRAME_TOOLBAR_LEFT_WIDTH (f) + FRAME_TOOLBAR_RIGHT_WIDTH (f))
  1362 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.x->baseline_offset)
  1363 
  1364 /* This gives the x_display_info structure for the display F is on.  */
  1365 #define FRAME_DISPLAY_INFO(f) ((f)->output_data.x->display_info)
  1366 
  1367 /* This is the `Display *' which frame F is on.  */
  1368 #define FRAME_X_DISPLAY(f) (FRAME_DISPLAY_INFO (f)->display)
  1369 
  1370 /* This is the `Screen *' which frame F is on.  */
  1371 #define FRAME_X_SCREEN(f) (FRAME_DISPLAY_INFO (f)->screen)
  1372 
  1373 /* This is the screen index number of screen which frame F is on.  */
  1374 #define FRAME_X_SCREEN_NUMBER(f) XScreenNumberOfScreen (FRAME_X_SCREEN (f))
  1375 
  1376 /* This is the Visual which frame F is on.  */
  1377 #define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO (f)->visual
  1378 
  1379 /* And its corresponding visual info.  */
  1380 #define FRAME_X_VISUAL_INFO(f) (&FRAME_DISPLAY_INFO (f)->visual_info)
  1381 
  1382 #ifdef HAVE_XRENDER
  1383 #define FRAME_X_PICTURE_FORMAT(f) FRAME_DISPLAY_INFO (f)->pict_format
  1384 #define FRAME_X_PICTURE(f) ((f)->output_data.x->picture)
  1385 #define FRAME_CHECK_XR_VERSION(f, major, minor)                 \
  1386   (FRAME_DISPLAY_INFO (f)->xrender_supported_p                  \
  1387    && ((FRAME_DISPLAY_INFO (f)->xrender_major == (major)        \
  1388         && FRAME_DISPLAY_INFO (f)->xrender_minor >= (minor))    \
  1389        || (FRAME_DISPLAY_INFO (f)->xrender_major > (major))))
  1390 #endif
  1391 
  1392 #ifdef HAVE_XSYNC
  1393 #define FRAME_X_BASIC_COUNTER(f)                \
  1394   FRAME_X_OUTPUT (f)->basic_frame_counter
  1395 #define FRAME_X_EXTENDED_COUNTER(f)             \
  1396   FRAME_X_OUTPUT (f)->extended_frame_counter
  1397 #define FRAME_X_WAITING_FOR_DRAW(f)             \
  1398   FRAME_X_OUTPUT (f)->waiting_for_frame_p
  1399 #define FRAME_X_DRAW_JUST_HUNG(f)               \
  1400   FRAME_X_OUTPUT (f)->draw_just_hung_p
  1401 #define FRAME_X_COUNTER_VALUE(f)                \
  1402   FRAME_X_OUTPUT (f)->current_extended_counter_value
  1403 #endif
  1404 
  1405 /* This is the Colormap which frame F uses.  */
  1406 #define FRAME_X_COLORMAP(f) FRAME_DISPLAY_INFO (f)->cmap
  1407 
  1408 #define FRAME_XIC(f) ((f)->output_data.x->xic)
  1409 #define FRAME_X_XIM(f) (FRAME_DISPLAY_INFO (f)->xim)
  1410 #define FRAME_X_XIM_STYLES(f) (FRAME_DISPLAY_INFO (f)->xim_styles)
  1411 #define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style)
  1412 #define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs)
  1413 #define FRAME_X_XIM_CODING(f)                           \
  1414   (SYMBOLP (Vx_input_coding_system)                     \
  1415    ? Vx_input_coding_system                             \
  1416    : (!NILP (FRAME_DISPLAY_INFO (f)->xim_coding)        \
  1417       ? FRAME_DISPLAY_INFO(f)->xim_coding               \
  1418       : Vlocale_coding_system))
  1419 
  1420 /* X-specific scroll bar stuff.  */
  1421 
  1422 /* We represent scroll bars as lisp vectors.  This allows us to place
  1423    references to them in windows without worrying about whether we'll
  1424    end up with windows referring to dead scroll bars; the garbage
  1425    collector will free it when its time comes.
  1426 
  1427    We use struct scroll_bar as a template for accessing fields of the
  1428    vector.  */
  1429 
  1430 struct scroll_bar
  1431 {
  1432   /* These fields are shared by all vectors.  */
  1433   union vectorlike_header header;
  1434 
  1435   /* The window we're a scroll bar for.  */
  1436   Lisp_Object window;
  1437 
  1438   /* The next and previous in the chain of scroll bars in this frame.  */
  1439   Lisp_Object next, prev;
  1440 
  1441   /* Fields after 'prev' are not traced by the GC.  */
  1442 
  1443   /* The X window representing this scroll bar.  */
  1444   Window x_window;
  1445 
  1446   /* The position and size of the scroll bar in pixels, relative to the
  1447      frame.  */
  1448   int top, left, width, height;
  1449 
  1450   /* The starting and ending positions of the handle, relative to the
  1451      handle area (i.e. zero is the top position, not
  1452      SCROLL_BAR_TOP_BORDER).  If they're equal, that means the handle
  1453      hasn't been drawn yet.
  1454 
  1455      These are not actually the locations where the beginning and end
  1456      are drawn; in order to keep handles from becoming invisible when
  1457      editing large files, we establish a minimum height by always
  1458      drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
  1459      where they would be normally; the bottom and top are in a
  1460      different coordinate system.  */
  1461   int start, end;
  1462 
  1463   /* If the scroll bar handle is currently being dragged by the user,
  1464      this is the number of pixels from the top of the handle to the
  1465      place where the user grabbed it.  If the handle isn't currently
  1466      being dragged, this is -1.  */
  1467   int dragging;
  1468 
  1469 #if defined (USE_TOOLKIT_SCROLL_BARS) && defined (USE_LUCID)
  1470   /* Last scroll bar part seen in xaw_jump_callback and xaw_scroll_callback.  */
  1471   enum scroll_bar_part last_seen_part;
  1472 #endif
  1473 
  1474 #if defined (USE_TOOLKIT_SCROLL_BARS) && !defined (USE_GTK)
  1475   /* Last value of whole for horizontal scrollbars.  */
  1476   int whole;
  1477 #endif
  1478 
  1479   /* True if the scroll bar is horizontal.  */
  1480   bool horizontal;
  1481 } GCALIGNED_STRUCT;
  1482 
  1483 /* Turning a lisp vector value into a pointer to a struct scroll_bar.  */
  1484 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
  1485 
  1486 #ifdef USE_X_TOOLKIT
  1487 
  1488 /* Extract the X widget of the scroll bar from a struct scroll_bar.
  1489    XtWindowToWidget should be fast enough since Xt uses a hash table
  1490    to map windows to widgets.  */
  1491 
  1492 #define SCROLL_BAR_X_WIDGET(dpy, ptr) \
  1493   XtWindowToWidget (dpy, ptr->x_window)
  1494 
  1495 /* Store a widget id in a struct scroll_bar.  */
  1496 
  1497 #define SET_SCROLL_BAR_X_WIDGET(ptr, w)         \
  1498   do {                                          \
  1499     Window window = XtWindow (w);               \
  1500     ptr->x_window = window;                     \
  1501   } while (false)
  1502 
  1503 #endif /* USE_X_TOOLKIT */
  1504 
  1505 /* Return the inside width of a vertical scroll bar, given the outside
  1506    width.  */
  1507 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
  1508   ((width) \
  1509    - VERTICAL_SCROLL_BAR_LEFT_BORDER \
  1510    - VERTICAL_SCROLL_BAR_RIGHT_BORDER)
  1511 
  1512 /* Return the length of the rectangle within which the top of the
  1513    handle must stay.  This isn't equivalent to the inside height,
  1514    because the scroll bar handle has a minimum height.
  1515 
  1516    This is the real range of motion for the scroll bar, so when we're
  1517    scaling buffer positions to scroll bar positions, we use this, not
  1518    VERTICAL_SCROLL_BAR_INSIDE_HEIGHT.  */
  1519 #define VERTICAL_SCROLL_BAR_TOP_RANGE(f, height) \
  1520   (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
  1521 
  1522 /* Return the inside height of vertical scroll bar, given the outside
  1523    height.  See VERTICAL_SCROLL_BAR_TOP_RANGE too.  */
  1524 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f, height) \
  1525   ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
  1526 
  1527 /* Return the inside height of a horizontal scroll bar, given the outside
  1528    height.  */
  1529 #define HORIZONTAL_SCROLL_BAR_INSIDE_HEIGHT(f, height)  \
  1530   ((height) \
  1531    - HORIZONTAL_SCROLL_BAR_TOP_BORDER \
  1532    - HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER)
  1533 
  1534 /* Return the length of the rectangle within which the left part of the
  1535    handle must stay.  This isn't equivalent to the inside width, because
  1536    the scroll bar handle has a minimum width.
  1537 
  1538    This is the real range of motion for the scroll bar, so when we're
  1539    scaling buffer positions to scroll bar positions, we use this, not
  1540    HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH.  */
  1541 #define HORIZONTAL_SCROLL_BAR_LEFT_RANGE(f, width) \
  1542   (HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH (f, width) - HORIZONTAL_SCROLL_BAR_MIN_HANDLE)
  1543 
  1544 /* Return the inside width of horizontal scroll bar, given the outside
  1545    width.  See HORIZONTAL_SCROLL_BAR_LEFT_RANGE too.  */
  1546 #define HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
  1547   ((width) - HORIZONTAL_SCROLL_BAR_LEFT_BORDER - HORIZONTAL_SCROLL_BAR_LEFT_BORDER)
  1548 
  1549 
  1550 /* Border widths for scroll bars.
  1551 
  1552    Scroll bar windows don't have any X borders; their border width is
  1553    set to zero, and we redraw borders ourselves.  This makes the code
  1554    a bit cleaner, since we don't have to convert between outside width
  1555    (used when relating to the rest of the screen) and inside width
  1556    (used when sizing and drawing the scroll bar window itself).
  1557 
  1558    The handle moves up and down/back and forth in a rectangle inset
  1559    from the edges of the scroll bar.  These are widths by which we
  1560    inset the handle boundaries from the scroll bar edges.  */
  1561 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (2)
  1562 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (2)
  1563 #define VERTICAL_SCROLL_BAR_TOP_BORDER (2)
  1564 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (2)
  1565 
  1566 #define HORIZONTAL_SCROLL_BAR_LEFT_BORDER (2)
  1567 #define HORIZONTAL_SCROLL_BAR_RIGHT_BORDER (2)
  1568 #define HORIZONTAL_SCROLL_BAR_TOP_BORDER (2)
  1569 #define HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER (2)
  1570 
  1571 /* Minimum lengths for scroll bar handles, in pixels.  */
  1572 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (5)
  1573 #define HORIZONTAL_SCROLL_BAR_MIN_HANDLE (5)
  1574 
  1575 /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT
  1576    or SELECTION_CLEAR_EVENT, then its contents are really described
  1577    by this structure.  */
  1578 
  1579 /* For an event of kind SELECTION_REQUEST_EVENT,
  1580    this structure really describes the contents.  */
  1581 
  1582 struct selection_input_event
  1583 {
  1584   ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH;
  1585   struct x_display_info *dpyinfo;
  1586   /* We spell it with an "o" here because X does.  */
  1587   Window requestor;
  1588   Atom selection, target, property;
  1589   Time time;
  1590 };
  1591 
  1592 /* Unlike macros below, this can't be used as an lvalue.  */
  1593 INLINE Display *
  1594 SELECTION_EVENT_DISPLAY (struct selection_input_event *ev)
  1595 {
  1596   return ev->dpyinfo->display;
  1597 }
  1598 #define SELECTION_EVENT_DPYINFO(eventp) \
  1599   ((eventp)->dpyinfo)
  1600 /* We spell it with an "o" here because X does.  */
  1601 #define SELECTION_EVENT_REQUESTOR(eventp)       \
  1602   ((eventp)->requestor)
  1603 #define SELECTION_EVENT_SELECTION(eventp)       \
  1604   ((eventp)->selection)
  1605 #define SELECTION_EVENT_TARGET(eventp)  \
  1606   ((eventp)->target)
  1607 #define SELECTION_EVENT_PROPERTY(eventp)        \
  1608   ((eventp)->property)
  1609 #define SELECTION_EVENT_TIME(eventp)    \
  1610   ((eventp)->time)
  1611 
  1612 /* From xfns.c.  */
  1613 
  1614 extern void x_free_gcs (struct frame *);
  1615 extern void x_relative_mouse_position (struct frame *, int *, int *);
  1616 extern void x_real_pos_and_offsets (struct frame *, int *, int *, int *,
  1617                                     int *, int *, int *, int *, int *,
  1618                                     int *);
  1619 extern void x_default_font_parameter (struct frame *, Lisp_Object);
  1620 
  1621 /* From xrdb.c.  */
  1622 
  1623 extern XrmDatabase x_load_resources (Display *, const char *, const char *,
  1624                                      const char *);
  1625 extern const char *x_get_string_resource (void *, const char *, const char *);
  1626 
  1627 /* Defined in xterm.c */
  1628 
  1629 typedef void (*x_special_error_handler) (Display *, XErrorEvent *, char *,
  1630                                          void *);
  1631 
  1632 extern bool x_text_icon (struct frame *, const char *);
  1633 extern void x_catch_errors (Display *);
  1634 extern void x_catch_errors_with_handler (Display *, x_special_error_handler,
  1635                                          void *);
  1636 extern void x_catch_errors_for_lisp (struct x_display_info *);
  1637 extern void x_uncatch_errors_for_lisp (struct x_display_info *);
  1638 extern void x_check_errors_for_lisp (struct x_display_info *,
  1639                                      const char *)
  1640   ATTRIBUTE_FORMAT_PRINTF (2, 0);
  1641 extern void x_check_errors (Display *, const char *)
  1642   ATTRIBUTE_FORMAT_PRINTF (2, 0);
  1643 extern bool x_had_errors_p (Display *);
  1644 extern void x_unwind_errors_to (int);
  1645 extern void x_uncatch_errors (void);
  1646 extern void x_uncatch_errors_after_check (void);
  1647 extern void x_ignore_errors_for_next_request (struct x_display_info *);
  1648 extern void x_stop_ignoring_errors (struct x_display_info *);
  1649 extern void x_clear_errors (Display *);
  1650 extern void x_set_window_size (struct frame *, bool, int, int);
  1651 extern void x_set_last_user_time_from_lisp (struct x_display_info *, Time);
  1652 extern void x_make_frame_visible (struct frame *);
  1653 extern void x_make_frame_invisible (struct frame *);
  1654 extern void x_iconify_frame (struct frame *);
  1655 extern void x_free_frame_resources (struct frame *);
  1656 extern void x_wm_set_size_hint (struct frame *, long, bool);
  1657 #if defined HAVE_XSYNCTRIGGERFENCE && !defined USE_GTK \
  1658   && defined HAVE_CLOCK_GETTIME
  1659 extern void x_sync_init_fences (struct frame *);
  1660 #endif
  1661 extern bool x_embed_frame (struct x_display_info *, struct frame *);
  1662 
  1663 extern void x_delete_terminal (struct terminal *);
  1664 extern Cursor x_create_font_cursor (struct x_display_info *, int);
  1665 extern unsigned long x_copy_color (struct frame *, unsigned long);
  1666 #ifdef USE_X_TOOLKIT
  1667 extern XtAppContext Xt_app_con;
  1668 extern void x_activate_timeout_atimer (void);
  1669 #endif
  1670 #ifdef USE_LUCID
  1671 extern bool x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
  1672                                               unsigned long *,
  1673                                               double, int);
  1674 #endif
  1675 extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *);
  1676 extern void x_query_colors (struct frame *f, XColor *, int);
  1677 extern void x_clear_area (struct frame *f, int, int, int, int);
  1678 #if (defined USE_LUCID && defined HAVE_XINPUT2) \
  1679   || (!defined USE_X_TOOLKIT && !defined USE_GTK)
  1680 extern void x_mouse_leave (struct x_display_info *);
  1681 #endif
  1682 extern void x_wait_for_cell_change (Lisp_Object, struct timespec);
  1683 
  1684 #ifndef USE_GTK
  1685 extern int x_dispatch_event (XEvent *, Display *);
  1686 #endif
  1687 extern int x_x_to_emacs_modifiers (struct x_display_info *, int);
  1688 extern int x_emacs_to_x_modifiers (struct x_display_info *, intmax_t);
  1689 #ifdef USE_CAIRO
  1690 extern void x_cr_destroy_frame_context (struct frame *);
  1691 extern void x_cr_update_surface_desired_size (struct frame *, int, int);
  1692 extern cairo_t *x_begin_cr_clip (struct frame *, GC);
  1693 extern void x_end_cr_clip (struct frame *);
  1694 extern void x_set_cr_source_with_gc_foreground (struct frame *, GC, bool);
  1695 extern void x_set_cr_source_with_gc_background (struct frame *, GC, bool);
  1696 extern void x_cr_draw_frame (cairo_t *, struct frame *);
  1697 extern Lisp_Object x_cr_export_frames (Lisp_Object, cairo_surface_type_t);
  1698 #endif
  1699 
  1700 #ifdef HAVE_XFIXES
  1701 extern Window x_find_selection_owner (struct x_display_info *, Atom);
  1702 #endif
  1703 
  1704 #ifdef HAVE_XRENDER
  1705 extern void x_xrender_color_from_gc_background (struct frame *, GC,
  1706                                                 XRenderColor *, bool);
  1707 extern void x_xr_ensure_picture (struct frame *);
  1708 extern void x_xr_apply_ext_clip (struct frame *, GC);
  1709 extern void x_xr_reset_ext_clip (struct frame *);
  1710 #endif
  1711 
  1712 extern void x_translate_coordinates (struct frame *, int, int, int *, int *);
  1713 extern void x_translate_coordinates_to_root (struct frame *, int, int,
  1714                                              int *, int *);
  1715 extern Lisp_Object x_handle_translate_coordinates (struct frame *, Lisp_Object,
  1716                                                    int, int);
  1717 
  1718 extern Bool x_query_pointer (Display *, Window, Window *, Window *, int *,
  1719                              int *, int *, int *, unsigned int *);
  1720 
  1721 #ifdef HAVE_GTK3
  1722 extern void x_scroll_bar_configure (GdkEvent *);
  1723 #endif
  1724 
  1725 #define DEFER_SELECTIONS                                                \
  1726   x_defer_selection_requests ();                                        \
  1727   record_unwind_protect_void (x_release_selection_requests_and_flush)
  1728 
  1729 extern void x_defer_selection_requests (void);
  1730 extern void x_release_selection_requests_and_flush (void);
  1731 extern void x_handle_pending_selection_requests (void);
  1732 extern bool x_detect_pending_selection_requests (void);
  1733 extern Lisp_Object x_dnd_begin_drag_and_drop (struct frame *, Time, Atom,
  1734                                               Lisp_Object, Atom *, const char **,
  1735                                               size_t, bool, Atom *, int,
  1736                                               Lisp_Object, bool);
  1737 extern void x_dnd_do_unsupported_drop (struct x_display_info *, Lisp_Object,
  1738                                        Lisp_Object, Lisp_Object, Window, int,
  1739                                        int, Time);
  1740 
  1741 extern int x_display_pixel_height (struct x_display_info *);
  1742 extern int x_display_pixel_width (struct x_display_info *);
  1743 
  1744 INLINE unsigned long
  1745 x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b)
  1746 {
  1747   unsigned long pr, pg, pb, pa = dpyinfo->alpha_mask;
  1748 
  1749   /* Scale down RGB values to the visual's bits per RGB, and shift
  1750      them to the right position in the pixel color.  Note that the
  1751      original RGB values are 16-bit values, as usual in X.  */
  1752   pr = (r >> (16 - dpyinfo->red_bits))   << dpyinfo->red_offset;
  1753   pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset;
  1754   pb = (b >> (16 - dpyinfo->blue_bits))  << dpyinfo->blue_offset;
  1755 
  1756   /* Assemble the pixel color.  */
  1757   return pr | pg | pb | pa;
  1758 }
  1759 
  1760 /* If display has an immutable color map, freeing colors is not
  1761    necessary and some servers don't allow it, so we won't do it.  That
  1762    also allows us to make other optimizations relating to server-side
  1763    reference counts.  */
  1764 INLINE bool
  1765 x_mutable_colormap (XVisualInfo *visual)
  1766 {
  1767   int class = visual->class;
  1768   return (class != StaticColor && class != StaticGray && class != TrueColor);
  1769 }
  1770 
  1771 extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object);
  1772 extern void x_set_shaded (struct frame *, Lisp_Object, Lisp_Object);
  1773 extern void x_set_skip_taskbar (struct frame *, Lisp_Object, Lisp_Object);
  1774 extern void x_set_z_group (struct frame *, Lisp_Object, Lisp_Object);
  1775 extern bool x_wm_supports (struct frame *, Atom);
  1776 extern bool x_wm_supports_1 (struct x_display_info *, Atom);
  1777 extern void x_wait_for_event (struct frame *, int);
  1778 extern void x_clear_under_internal_border (struct frame *f);
  1779 
  1780 extern void tear_down_x_back_buffer (struct frame *f);
  1781 extern void initial_set_up_x_back_buffer (struct frame *f);
  1782 
  1783 /* Defined in xfns.c.  */
  1784 extern void x_real_positions (struct frame *, int *, int *);
  1785 extern void x_change_tab_bar_height (struct frame *, int);
  1786 extern void x_change_tool_bar_height (struct frame *, int);
  1787 extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
  1788 extern void x_set_scroll_bar_default_width (struct frame *);
  1789 extern void x_set_scroll_bar_default_height (struct frame *);
  1790 #ifdef USE_LUCID
  1791 extern void xlw_monitor_dimensions_at_pos (Display *, Screen *, int, int,
  1792                                            int *, int *, int *, int *);
  1793 #endif
  1794 
  1795 /* Defined in xselect.c.  */
  1796 
  1797 extern void x_handle_property_notify (const XPropertyEvent *);
  1798 extern void x_handle_selection_notify (const XSelectionEvent *);
  1799 extern void x_handle_selection_event (struct selection_input_event *);
  1800 extern void x_clear_frame_selections (struct frame *);
  1801 extern Lisp_Object x_atom_to_symbol (struct x_display_info *, Atom);
  1802 extern Atom symbol_to_x_atom (struct x_display_info *, Lisp_Object);
  1803 
  1804 extern bool x_handle_dnd_message (struct frame *,
  1805                                   const XClientMessageEvent *,
  1806                                   struct x_display_info *,
  1807                                   struct input_event *,
  1808                                   bool, int, int);
  1809 extern int x_check_property_data (Lisp_Object);
  1810 extern void x_fill_property_data (Display *,
  1811                                   Lisp_Object,
  1812                                   void *,
  1813                                   int,
  1814                                   int);
  1815 extern Lisp_Object x_property_data_to_lisp (struct frame *,
  1816                                             const unsigned char *,
  1817                                             Atom,
  1818                                             int,
  1819                                             unsigned long);
  1820 extern void x_clipboard_manager_save_frame (Lisp_Object);
  1821 extern void x_clipboard_manager_save_all (void);
  1822 
  1823 extern Lisp_Object x_timestamp_for_selection (struct x_display_info *,
  1824                                               Lisp_Object);
  1825 extern void x_own_selection (Lisp_Object, Lisp_Object, Lisp_Object,
  1826                              Lisp_Object, Time);
  1827 extern Atom x_intern_cached_atom (struct x_display_info *, const char *,
  1828                                   bool);
  1829 extern char *x_get_atom_name (struct x_display_info *, Atom, bool *)
  1830   ATTRIBUTE_MALLOC ATTRIBUTE_DEALLOC_FREE;
  1831 
  1832 #ifdef USE_GTK
  1833 extern bool xg_set_icon (struct frame *, Lisp_Object);
  1834 extern bool xg_set_icon_from_xpm_data (struct frame *, const char **);
  1835 #endif /* USE_GTK */
  1836 
  1837 extern void xic_free_xfontset (struct frame *);
  1838 extern void create_frame_xic (struct frame *);
  1839 extern void destroy_frame_xic (struct frame *);
  1840 extern void xic_set_preeditarea (struct window *, int, int);
  1841 extern void xic_set_statusarea (struct frame *);
  1842 extern void xic_set_xfontset (struct frame *, const char *);
  1843 extern bool x_defined_color (struct frame *, const char *, Emacs_Color *,
  1844                              bool, bool);
  1845 extern void x_preserve_selections (struct x_display_info *, Lisp_Object,
  1846                                    Lisp_Object);
  1847 extern Lisp_Object x_get_keyboard_modifiers (struct x_display_info *);
  1848 #ifdef HAVE_X_I18N
  1849 extern void free_frame_xic (struct frame *);
  1850 # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT
  1851 extern char *xic_create_fontsetname (const char *, bool);
  1852 # endif
  1853 #endif
  1854 
  1855 /* Defined in xfaces.c */
  1856 
  1857 #ifdef USE_X_TOOLKIT
  1858 extern void x_free_dpy_colors (Display *, Screen *, Colormap,
  1859                                unsigned long *, int);
  1860 #endif /* USE_X_TOOLKIT */
  1861 
  1862 /* Defined in xmenu.c */
  1863 
  1864 #if defined USE_X_TOOLKIT || defined USE_GTK
  1865 extern Lisp_Object xw_popup_dialog (struct frame *, Lisp_Object, Lisp_Object);
  1866 #endif
  1867 
  1868 #if defined USE_GTK || defined USE_MOTIF
  1869 extern void x_menu_set_in_use (bool);
  1870 #endif
  1871 extern void x_menu_wait_for_event (void *data);
  1872 extern void initialize_frame_menubar (struct frame *);
  1873 
  1874 /* Defined in xsmfns.c */
  1875 #ifdef HAVE_X_SM
  1876 extern void x_session_initialize (struct x_display_info *dpyinfo);
  1877 extern bool x_session_have_connection (void);
  1878 extern void x_session_close (void);
  1879 #endif
  1880 
  1881 #ifdef HAVE_X_I18N
  1882 #define STYLE_OFFTHESPOT (XIMPreeditArea | XIMStatusArea)
  1883 #define STYLE_OVERTHESPOT (XIMPreeditPosition | XIMStatusNothing)
  1884 #define STYLE_ROOT (XIMPreeditNothing | XIMStatusNothing)
  1885 #define STYLE_CALLBACK (XIMPreeditCallbacks | XIMStatusNothing)
  1886 #define STYLE_NONE (XIMPreeditNothing | XIMStatusNothing)
  1887 #endif
  1888 
  1889 #ifdef USE_GTK
  1890 extern struct input_event xg_pending_quit_event;
  1891 #endif
  1892 
  1893 extern bool x_dnd_in_progress;
  1894 extern bool x_dnd_waiting_for_finish;
  1895 extern struct frame *x_dnd_frame;
  1896 extern struct frame *x_dnd_finish_frame;
  1897 extern int x_error_message_count;
  1898 
  1899 #ifdef HAVE_XINPUT2
  1900 extern struct xi_device_t *xi_device_from_id (struct x_display_info *, int);
  1901 extern bool xi_frame_selected_for (struct frame *, unsigned long);
  1902 #ifndef USE_GTK
  1903 extern unsigned int xi_convert_event_state (XIDeviceEvent *);
  1904 #endif
  1905 #endif
  1906 
  1907 extern void mark_xterm (void);
  1908 
  1909 /* Is the frame embedded into another application? */
  1910 
  1911 #define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT (f)->explicit_parent != 0)
  1912 
  1913 #define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight)      \
  1914   ((nr).x = (rx),                                       \
  1915    (nr).y = (ry),                                       \
  1916    (nr).width = (rwidth),                               \
  1917    (nr).height = (rheight))
  1918 
  1919 INLINE_HEADER_END
  1920 
  1921 #endif /* XTERM_H */

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