root/src/termhooks.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. TERMINALP
  2. XTERMINAL
  3. tset_charset_list
  4. tset_selection_alist

     1 /* Parameters and display hooks for terminal devices.
     2 
     3 Copyright (C) 1985-1986, 1993-1994, 2001-2023 Free Software Foundation,
     4 Inc.
     5 
     6 This file is part of GNU Emacs.
     7 
     8 GNU Emacs is free software: you can redistribute it and/or modify
     9 it under the terms of the GNU General Public License as published by
    10 the Free Software Foundation, either version 3 of the License, or (at
    11 your option) any later version.
    12 
    13 GNU Emacs is distributed in the hope that it will be useful,
    14 but WITHOUT ANY WARRANTY; without even the implied warranty of
    15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 GNU General Public License for more details.
    17 
    18 You should have received a copy of the GNU General Public License
    19 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    20 
    21 #ifndef EMACS_TERMHOOKS_H
    22 #define EMACS_TERMHOOKS_H
    23 
    24 /* Miscellanea.   */
    25 
    26 #include "lisp.h"
    27 #include "dispextern.h"
    28 #include "systime.h" /* for Time */
    29 
    30 struct glyph;
    31 
    32 INLINE_HEADER_BEGIN
    33 
    34 enum scroll_bar_part
    35 {
    36   scroll_bar_nowhere,
    37   scroll_bar_above_handle,
    38   scroll_bar_handle,
    39   scroll_bar_below_handle,
    40   scroll_bar_up_arrow,
    41   scroll_bar_down_arrow,
    42   scroll_bar_to_top,
    43   scroll_bar_to_bottom,
    44   scroll_bar_end_scroll,
    45   scroll_bar_move_ratio,
    46   scroll_bar_before_handle,
    47   scroll_bar_horizontal_handle,
    48   scroll_bar_after_handle,
    49   scroll_bar_left_arrow,
    50   scroll_bar_right_arrow,
    51   scroll_bar_to_leftmost,
    52   scroll_bar_to_rightmost
    53 };
    54 
    55 /* Output method of a terminal (and frames on this terminal, respectively).  */
    56 
    57 enum output_method
    58 {
    59   output_initial,
    60   output_termcap,
    61   output_x_window,
    62   output_msdos_raw,
    63   output_w32,
    64   output_ns,
    65   output_pgtk,
    66   output_haiku,
    67   output_android,
    68 };
    69 
    70 /* Input queue declarations and hooks.  */
    71 
    72 enum event_kind
    73 {
    74   NO_EVENT,                     /* nothing happened.  This should never
    75                                    actually appear in the event queue.  */
    76 
    77   ASCII_KEYSTROKE_EVENT,        /* The ASCII code is in .code, perhaps
    78                                    with modifiers applied.
    79                                    .modifiers holds the state of the
    80                                    modifier keys.
    81                                    .frame_or_window is the frame in
    82                                    which the key was typed.
    83                                    .timestamp gives a timestamp (in
    84                                    milliseconds) for the keystroke.  */
    85   MULTIBYTE_CHAR_KEYSTROKE_EVENT,       /* The multibyte char code is
    86                                            in .code, perhaps with
    87                                            modifiers applied.  The
    88                                            others are the same as
    89                                            ASCII_KEYSTROKE_EVENT,
    90                                            except when ARG is a
    91                                            string, which will be
    92                                            decoded and the decoded
    93                                            string's characters will be
    94                                            used as .code
    95                                            individually.
    96 
    97                                            The string can have a
    98                                            property `coding', which
    99                                            should be a symbol
   100                                            describing a coding system
   101                                            to use to decode the string.
   102 
   103                                            If it is nil, then the
   104                                            locale coding system will
   105                                            be used.  If it is t, then
   106                                            no decoding will take
   107                                            place.  */
   108   NON_ASCII_KEYSTROKE_EVENT,    /* .code is a number identifying the
   109                                    function key.  A code N represents
   110                                    a key whose name is
   111                                    function_key_names[N]; function_key_names
   112                                    is a table in keyboard.c to which you
   113                                    should feel free to add missing keys.
   114                                    .modifiers holds the state of the
   115                                    modifier keys.
   116                                    .frame_or_window is the frame in
   117                                    which the key was typed.
   118                                    .timestamp gives a timestamp (in
   119                                    milliseconds) for the keystroke.  */
   120   TIMER_EVENT,                  /* A timer fired.  */
   121   MOUSE_CLICK_EVENT,            /* The button number is in .code; it must
   122                                    be >= 0 and < NUM_MOUSE_BUTTONS, defined
   123                                    below.
   124                                    .modifiers holds the state of the
   125                                    modifier keys.
   126                                    .x and .y give the mouse position,
   127                                    in characters, within the window.
   128                                    .frame_or_window gives the frame
   129                                    the mouse click occurred in.
   130                                    .timestamp gives a timestamp (in
   131                                    milliseconds) for the click.  */
   132   WHEEL_EVENT,                  /* A wheel event is generated by a
   133                                    wheel on a mouse (e.g., MS
   134                                    Intellimouse).
   135                                    .modifiers holds the rotate
   136                                    direction (up or down), and the
   137                                    state of the modifier keys.
   138                                    .x and .y give the mouse position,
   139                                    in characters, within the window.
   140                                    .frame_or_window gives the frame
   141                                    the wheel event occurred in.
   142                                    .timestamp gives a timestamp (in
   143                                    milliseconds) for the event.
   144                                    .arg may contain the number of
   145                                    lines to scroll, or a list of
   146                                    the form (NUMBER-OF-LINES . (X Y)) where
   147                                    X and Y are the number of pixels
   148                                    on each axis to scroll by.  */
   149   HORIZ_WHEEL_EVENT,            /* A wheel event generated by a second
   150                                    horizontal wheel that is present on some
   151                                    mice. See WHEEL_EVENT.  */
   152 #ifdef HAVE_NTGUI
   153   LANGUAGE_CHANGE_EVENT,        /* A LANGUAGE_CHANGE_EVENT is
   154                                    generated when HAVE_NTGUI or on Mac OS
   155                                    when the keyboard layout or input
   156                                    language is changed by the
   157                                    user.  */
   158 #endif
   159   SCROLL_BAR_CLICK_EVENT,       /* .code gives the number of the mouse button
   160                                    that was clicked.
   161                                    .modifiers holds the state of the modifier
   162                                    keys.
   163                                    .part is a lisp symbol indicating which
   164                                    part of the scroll bar got clicked.
   165                                    .x gives the distance from the start of the
   166                                    scroll bar of the click; .y gives the total
   167                                    length of the scroll bar.
   168                                    .frame_or_window gives the window
   169                                    whose scroll bar was clicked in.
   170                                    .timestamp gives a timestamp (in
   171                                    milliseconds) for the click.  */
   172   HORIZONTAL_SCROLL_BAR_CLICK_EVENT,    /* .code gives the number of the mouse button
   173                                    that was clicked.
   174                                    .modifiers holds the state of the modifier
   175                                    keys.
   176                                    .part is a lisp symbol indicating which
   177                                    part of the scroll bar got clicked.
   178                                    .x gives the distance from the start of the
   179                                    scroll bar of the click; .y gives the total
   180                                    length of the scroll bar.
   181                                    .frame_or_window gives the window
   182                                    whose scroll bar was clicked in.
   183                                    .timestamp gives a timestamp (in
   184                                    milliseconds) for the click.  */
   185   SELECTION_REQUEST_EVENT,      /* Another X client wants a selection from us.
   186                                    See `struct selection_input_event'.  */
   187   SELECTION_CLEAR_EVENT,        /* Another X client cleared our selection.  */
   188   DELETE_WINDOW_EVENT,          /* An X client said "delete this window".  */
   189 #ifdef HAVE_NTGUI
   190   END_SESSION_EVENT,            /* The user is logging out or shutting down.  */
   191 #endif
   192   MENU_BAR_EVENT,               /* An event generated by the menu bar.
   193                                    The frame_or_window field's cdr holds the
   194                                    Lisp-level event value.
   195                                    (Only the toolkit version uses these.)  */
   196   ICONIFY_EVENT,                /* An X client iconified this window.  */
   197   DEICONIFY_EVENT,              /* An X client deiconified this window.  */
   198   MENU_BAR_ACTIVATE_EVENT,      /* A button press in the menu bar
   199                                    (toolkit version only).  */
   200   DRAG_N_DROP_EVENT,            /* A drag-n-drop event is generated when
   201                                    files selected outside of Emacs are dropped
   202                                    onto an Emacs window.
   203                                    .modifiers holds the state of the
   204                                    modifier keys.
   205                                    .x and .y give the mouse position,
   206                                    in characters, within the window.
   207                                    .frame_or_window is the frame in
   208                                    which the drop was made.
   209                                    .arg is a platform-dependent
   210                                    representation of the dropped items.
   211                                    .timestamp gives a timestamp (in
   212                                    milliseconds) for the click.  */
   213   USER_SIGNAL_EVENT,            /* A user signal.
   214                                    code is a number identifying it,
   215                                    index into lispy_user_signals.  */
   216 
   217   /* Help events.  Member `frame_or_window' of the input_event is the
   218      frame on which the event occurred, and member `arg' contains
   219      the help to show.  */
   220   HELP_EVENT,
   221 
   222   /* An event from a tab-bar.  Member `arg' of the input event
   223      contains the tab-bar item selected.  If `frame_or_window'
   224      and `arg' are equal, this is a prefix event.  */
   225   TAB_BAR_EVENT,
   226 
   227   /* An event from a tool-bar.  Member `arg' of the input event
   228      contains the tool-bar item selected.  If `frame_or_window'
   229      and `arg' are equal, this is a prefix event.  */
   230   TOOL_BAR_EVENT,
   231 
   232   /* Queued from XTread_socket on FocusIn events.  Translated into
   233      `switch-frame' events in kbd_buffer_get_event, if necessary.  */
   234   FOCUS_IN_EVENT,
   235 
   236   FOCUS_OUT_EVENT,
   237 
   238   /* Generated when a frame is moved.  */
   239   MOVE_FRAME_EVENT,
   240 
   241   /* Generated when mouse moves over window not currently selected.  */
   242   SELECT_WINDOW_EVENT,
   243 
   244   /* Queued from XTread_socket when session manager sends
   245      save yourself before shutdown. */
   246   SAVE_SESSION_EVENT
   247 
   248 #ifdef HAVE_DBUS
   249   , DBUS_EVENT
   250 #endif
   251 
   252 #ifdef THREADS_ENABLED
   253   , THREAD_EVENT
   254 #endif
   255 
   256   , CONFIG_CHANGED_EVENT
   257 
   258 #ifdef HAVE_NTGUI
   259   /* Generated when an APPCOMMAND event is received, in response to
   260      Multimedia or Internet buttons on some keyboards.
   261      Such keys are available as normal function keys on X through the
   262      Xkeyboard extension.
   263      On Windows, some of them get mapped to normal function key events,
   264      but others need to be handled by APPCOMMAND. Handling them all as
   265      APPCOMMAND events means they can be disabled
   266      (w32-pass-multimedia-buttons-to-system), important on Windows since
   267      the system never sees these keys if Emacs claims to handle them.
   268      On X, the window manager seems to grab the keys it wants
   269      first, so this is not a problem there.  */
   270   , MULTIMEDIA_KEY_EVENT
   271 #endif
   272 
   273 #ifdef HAVE_NS
   274   /* Generated when native multi-keystroke input method is used to modify
   275      tentative or indicative text display. */
   276   , NS_TEXT_EVENT
   277   /* Non-key system events (e.g. application menu events) */
   278   , NS_NONKEY_EVENT
   279 #endif
   280 
   281 #ifdef HAVE_XWIDGETS
   282   /* An event generated by an xwidget to tell us something.  */
   283    , XWIDGET_EVENT
   284 
   285    /* Event generated when WebKit asks us to display another widget.  */
   286    , XWIDGET_DISPLAY_EVENT
   287 #endif
   288 
   289 #ifdef USE_FILE_NOTIFY
   290   /* File or directory was changed.  */
   291   , FILE_NOTIFY_EVENT
   292 #endif
   293 
   294   /* Pre-edit text was changed. */
   295   , PREEDIT_TEXT_EVENT
   296 
   297   /* Either the mouse wheel has been released without it being
   298      clicked, or the user has lifted his finger from a touchpad.
   299 
   300      In the future, this may take into account other multi-touch
   301      events generated from touchscreens and such.  */
   302   , TOUCH_END_EVENT
   303 
   304   /* In a TOUCHSCREEN_UPDATE_EVENT, ARG is a list of elements of the
   305      form (X Y ID), where X and Y are the coordinates of the
   306      touchpoint relative to the top-left corner of the frame, and ID
   307      is a unique number identifying the touchpoint.
   308 
   309      In TOUCHSCREEN_BEGIN_EVENT and TOUCHSCREEN_END_EVENT, ARG is the
   310      unique ID of the touchpoint, and X and Y are the frame-relative
   311      positions of the touchpoint.
   312 
   313      In TOUCHSCREEN_END_EVENT, non-0 modifiers means that the
   314      touchpoint has been canceled.  (See (elisp)Touchscreen
   315      Events.)  */
   316 
   317   , TOUCHSCREEN_UPDATE_EVENT
   318   , TOUCHSCREEN_BEGIN_EVENT
   319   , TOUCHSCREEN_END_EVENT
   320 
   321   /* In a PINCH_EVENT, X and Y are the position of the pointer
   322      relative to the top-left corner of the frame, and arg is a list
   323      of (DX DY SCALE ANGLE), in which:
   324 
   325        - DX and DY are the difference between the positions of the
   326          fingers comprising the current gesture and the last such
   327          gesture in the same sequence.
   328        - SCALE is the division of the current distance between the
   329          fingers and the distance at the start of the gesture.
   330        - DELTA-ANGLE is the delta between the angle of the current
   331          event and the last event in the same sequence, in degrees.  A
   332          positive delta represents a change clockwise, and a negative
   333          delta represents a change counter-clockwise.  */
   334   , PINCH_EVENT
   335 
   336   /* In a MONITORS_CHANGED_EVENT, .arg gives the terminal on which the
   337      monitor configuration changed.  .timestamp gives the time on
   338      which the monitors changed.  */
   339   , MONITORS_CHANGED_EVENT
   340 };
   341 
   342 /* Bit width of an enum event_kind tag at the start of structs and unions.  */
   343 enum { EVENT_KIND_WIDTH = 16 };
   344 
   345 /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT
   346    or SELECTION_CLEAR_EVENT, then its contents are really described
   347    by `struct selection_input_event'; see xterm.h.  */
   348 
   349 /* The keyboard input buffer is an array of these structures.  Each one
   350    represents some sort of input event - a keystroke, a mouse click, or
   351    a window system event.  These get turned into their lispy forms when
   352    they are removed from the event queue.  */
   353 
   354 struct input_event
   355 {
   356   /* What kind of event was this?  */
   357   ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH;
   358 
   359   /* Used in scroll back click events.  */
   360   ENUM_BF (scroll_bar_part) part : 16;
   361 
   362   /* For an ASCII_KEYSTROKE_EVENT and MULTIBYTE_CHAR_KEYSTROKE_EVENT,
   363      this is the character.
   364      For a NON_ASCII_KEYSTROKE_EVENT, this is the keysym code.
   365      For a mouse event, this is the button number.  */
   366   unsigned code;
   367 
   368   /* See enum below for interpretation.  */
   369   unsigned modifiers;
   370 
   371   /* One would prefer C integers, but HELP_EVENT uses these to
   372      record frame or window object and a help form, respectively.  */
   373   Lisp_Object x, y;
   374 
   375   /* Usually a time as reported by window system-specific event loop.
   376      For a HELP_EVENT, this is the position within the object (stored
   377      in ARG below) where the help was found.  */
   378   Time timestamp;
   379 
   380   /* This field is copied into a vector while the event is in
   381      the queue, so that garbage collections won't kill it.  */
   382   Lisp_Object frame_or_window;
   383 
   384   /* This additional argument is used in attempt to avoid extra consing
   385      when building events.  Unfortunately some events have to pass much
   386      more data than it's reasonable to pack directly into this structure.  */
   387   Lisp_Object arg;
   388 
   389   /* The name of the device from which this event originated.
   390 
   391      It can either be a string, or Qt, which means to use the name
   392      "Virtual core pointer" for all events other than keystroke
   393      events, and "Virtual core keyboard" for those.  */
   394   Lisp_Object device;
   395 };
   396 
   397 #define EVENT_INIT(event) (memset (&(event), 0, sizeof (struct input_event)), \
   398                            (event).device = Qt)
   399 
   400 /* Bits in the modifiers member of the input_event structure.
   401    Note that reorder_modifiers assumes that the bits are in canonical
   402    order.
   403 
   404    The modifiers applied to mouse clicks are rather ornate.  The
   405    window-system-specific code should store mouse clicks with
   406    up_modifier or down_modifier set.  Having an explicit down modifier
   407    simplifies some of window-system-independent code; without it, the
   408    code would have to recognize down events by checking if the event
   409    is a mouse click lacking the click and drag modifiers.
   410 
   411    The window-system independent code turns all up_modifier events
   412    bits into drag_modifier, click_modifier, double_modifier, or
   413    triple_modifier events.  The click_modifier has no written
   414    representation in the names of the symbols used as event heads,
   415    but it does appear in the Qevent_symbol_components property of the
   416    event heads.  */
   417 enum {
   418   up_modifier   =   1,          /* Only used on mouse buttons - always
   419                                    turned into a click or a drag modifier
   420                                    before lisp code sees the event.  */
   421   down_modifier =   2,          /* Only used on mouse buttons.  */
   422   drag_modifier =   4,          /* This is never used in the event
   423                                    queue; it's only used internally by
   424                                    the window-system-independent code.  */
   425   click_modifier=   8,          /* See drag_modifier.  */
   426   double_modifier= 16,          /* See drag_modifier.  */
   427   triple_modifier= 32,          /* See drag_modifier.  */
   428 
   429   /* The next four modifier bits are used also in keyboard events at
   430      the Lisp level.
   431 
   432      It's probably not the greatest idea to use the 2^28 bit for any
   433      modifier.  It may or may not be the sign bit, depending on
   434      FIXNUM_BITS, so using it to represent a modifier key means that
   435      characters thus modified have different integer equivalents
   436      depending on the architecture they're running on.  Oh, and
   437      applying XFIXNUM to a character whose 2^28 bit is set might sign-extend
   438      it, so you get a bunch of bits in the mask you didn't want.
   439 
   440      The CHAR_ macros are defined in lisp.h.  */
   441   alt_modifier  =  CHAR_ALT,    /* Under X, the XK_Alt_[LR] keysyms.  */
   442   super_modifier=  CHAR_SUPER,  /* Under X, the XK_Super_[LR] keysyms.  */
   443   hyper_modifier=  CHAR_HYPER,  /* Under X, the XK_Hyper_[LR] keysyms.  */
   444   shift_modifier=  CHAR_SHIFT,
   445   ctrl_modifier =  CHAR_CTL,
   446   meta_modifier =  CHAR_META    /* Under X, the XK_Meta_[LR] keysyms.  */
   447 };
   448 
   449 #ifdef HAVE_GPM
   450 #include <gpm.h>
   451 extern int handle_one_term_event (struct tty_display_info *, Gpm_Event *);
   452 extern void term_mouse_moveto (int, int);
   453 
   454 /* The device for which we have enabled gpm support.  */
   455 extern struct tty_display_info *gpm_tty;
   456 #endif
   457 
   458 /* Terminal-local parameters. */
   459 struct terminal
   460 {
   461   /* This is for Lisp; the terminal code does not refer to it.  */
   462   union vectorlike_header header;
   463 
   464   /* Parameter alist of this terminal.  */
   465   Lisp_Object param_alist;
   466 
   467   /* List of charsets supported by the terminal.  It is set by
   468      Fset_terminal_coding_system_internal along with
   469      the member terminal_coding.  */
   470   Lisp_Object charset_list;
   471 
   472   /* This is an association list containing the X selections that
   473      Emacs might own on this terminal.  Each element has the form
   474        (SELECTION-NAME SELECTION-VALUE SELECTION-TIMESTAMP FRAME)
   475      SELECTION-NAME is a lisp symbol, whose name is the name of an X Atom.
   476      SELECTION-VALUE is the value that emacs owns for that selection.
   477       It may be any kind of Lisp object.
   478      SELECTION-TIMESTAMP is the time at which emacs began owning this
   479       selection, as a cons of two 16-bit numbers (making a 32 bit
   480       time.)
   481      FRAME is the frame for which we made the selection.  If there is
   482       an entry in this alist, then it can be assumed that Emacs owns
   483       that selection.
   484      The only (eq) parts of this list that are visible from Lisp are
   485     the selection-values.  */
   486   Lisp_Object Vselection_alist;
   487 
   488   /* If a char-table, this maps characters to terminal glyph codes.
   489      If t, the mapping is not available.  If nil, it is not known
   490      whether the mapping is available.  */
   491   Lisp_Object glyph_code_table;
   492 
   493   /* All earlier fields should be Lisp_Objects and are traced
   494      by the GC.  All fields afterwards are ignored by the GC.  */
   495 
   496   /* Chain of all terminal devices. */
   497   struct terminal *next_terminal;
   498 
   499   /* Unique id for this terminal device. */
   500   int id;
   501 
   502   /* The number of frames that are on this terminal. */
   503   int reference_count;
   504 
   505   /* The type of the terminal device. */
   506   enum output_method type;
   507 
   508   /* The name of the terminal device.  Do not use this to uniquely
   509      identify a terminal; the same device may be opened multiple
   510      times. */
   511   char *name;
   512 
   513   /* The terminal's keyboard object. */
   514   struct kboard *kboard;
   515 
   516 #ifdef HAVE_WINDOW_SYSTEM
   517   /* Cache of images.  */
   518   struct image_cache *image_cache;
   519 #endif /* HAVE_WINDOW_SYSTEM */
   520 
   521   /* Device-type dependent data shared amongst all frames on this terminal.  */
   522   union display_info
   523   {
   524     struct tty_display_info *tty;               /* termchar.h */
   525     struct x_display_info *x;                   /* xterm.h */
   526     struct w32_display_info *w32;               /* w32term.h */
   527     struct ns_display_info *ns;                 /* nsterm.h */
   528     struct pgtk_display_info *pgtk;             /* pgtkterm.h */
   529     struct haiku_display_info *haiku;           /* haikuterm.h */
   530     struct android_display_info *android;       /* androidterm.h */
   531   } display_info;
   532 
   533 
   534   /* Coding-system to be used for encoding terminal output.  This
   535      structure contains information of a coding-system specified by
   536      the function `set-terminal-coding-system'.  Also see
   537      `safe_terminal_coding' in coding.h.  */
   538   struct coding_system *terminal_coding;
   539 
   540   /* Coding-system of what is sent from terminal keyboard.  This
   541      structure contains information of a coding-system specified by
   542      the function `set-keyboard-coding-system'.  */
   543   struct coding_system *keyboard_coding;
   544 
   545   /* Window-based redisplay interface for this device (0 for tty
   546      devices). */
   547   struct redisplay_interface *rif;
   548 
   549   /* Frame-based redisplay interface. */
   550 
   551   /* Text display hooks.  */
   552 
   553   void (*cursor_to_hook) (struct frame *f, int vpos, int hpos);
   554   void (*raw_cursor_to_hook) (struct frame *, int, int);
   555 
   556   void (*clear_to_end_hook) (struct frame *);
   557   void (*clear_frame_hook) (struct frame *);
   558   void (*clear_end_of_line_hook) (struct frame *, int);
   559 
   560   void (*ins_del_lines_hook) (struct frame *f, int, int);
   561 
   562   void (*insert_glyphs_hook) (struct frame *f, struct glyph *s, int n);
   563   void (*write_glyphs_hook) (struct frame *f, struct glyph *s, int n);
   564   void (*delete_glyphs_hook) (struct frame *, int);
   565 
   566   void (*ring_bell_hook) (struct frame *f);
   567   void (*toggle_invisible_pointer_hook) (struct frame *f, bool invisible);
   568 
   569   void (*reset_terminal_modes_hook) (struct terminal *);
   570   void (*set_terminal_modes_hook) (struct terminal *);
   571 
   572   void (*update_begin_hook) (struct frame *);
   573   void (*update_end_hook) (struct frame *);
   574   void (*set_terminal_window_hook) (struct frame *, int);
   575 
   576   /* Decide if color named COLOR_NAME is valid for the display
   577    associated with the frame F; if so, return the RGB values in
   578    COLOR_DEF.  If ALLOC (and MAKEINDEX for NS), allocate a new
   579    colormap cell.
   580 
   581    If MAKEINDEX (on NS), set COLOR_DEF pixel to ARGB.  */
   582   bool (*defined_color_hook) (struct frame *f, const char *color_name,
   583                               Emacs_Color *color_def,
   584                               bool alloc,
   585                               bool makeIndex);
   586 
   587   /* Multi-frame and mouse support hooks.  */
   588 
   589   /* Graphical window systems are expected to define all of the
   590      following hooks with the possible exception of:
   591 
   592    * query_colors
   593    * activate_menubar_hook
   594    * change_tool_bar_height_hook
   595    * set_bitmap_icon_hook
   596    * buffer_flipping_unblocked_hook
   597 
   598    */
   599 
   600   /* This hook is called to store the frame's background color into
   601      BGCOLOR.  */
   602   void (*query_frame_background_color) (struct frame *f, Emacs_Color *bgcolor);
   603 
   604 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (HAVE_PGTK) \
   605   || defined (HAVE_ANDROID)
   606   /* On frame F, translate pixel colors to RGB values for the NCOLORS
   607      colors in COLORS.  Use cached information, if available.  */
   608 
   609   void (*query_colors) (struct frame *f, Emacs_Color *colors, int ncolors);
   610 #endif
   611   /* Return the current position of the mouse.
   612 
   613      Set *f to the frame the mouse is in, or zero if the mouse is in no
   614      Emacs frame.  If it is set to zero, all the other arguments are
   615      garbage.
   616 
   617      If the motion started in a scroll bar, set *bar_window to the
   618      scroll bar's window, *part to the part the mouse is currently over,
   619      *x to the position of the mouse along the scroll bar, and *y to the
   620      overall length of the scroll bar.
   621 
   622      Otherwise, set *bar_window to Qnil, and *x and *y to the column and
   623      row of the character cell the mouse is over.
   624 
   625      Set *time to the time the mouse was at the returned position.  */
   626   void (*mouse_position_hook) (struct frame **f, int,
   627                                Lisp_Object *bar_window,
   628                                enum scroll_bar_part *part,
   629                                Lisp_Object *x,
   630                                Lisp_Object *y,
   631                                Time *);
   632 
   633   /* This hook is called to get the focus frame.  */
   634   Lisp_Object (*get_focus_frame) (struct frame *f);
   635 
   636   /* This hook is called to shift frame focus.  */
   637   void (*focus_frame_hook) (struct frame *f, bool noactivate);
   638 
   639   /* When a frame's focus redirection is changed, this hook tells the
   640      window system code to re-decide where to put the highlight.  Under
   641      X, this means that Emacs lies about where the focus is.  */
   642   void (*frame_rehighlight_hook) (struct frame *);
   643 
   644   /* If we're displaying frames using a window system that can stack
   645      frames on top of each other, this hook allows you to bring a frame
   646      to the front, or bury it behind all the other windows.  If this
   647      hook is zero, that means the terminal we're displaying on doesn't
   648      support overlapping frames, so there's no need to raise or lower
   649      anything.
   650 
   651      If RAISE_FLAG, F is brought to the front, before all other
   652      windows.  If !RAISE_FLAG, F is sent to the back, behind all other
   653      windows.  */
   654   void (*frame_raise_lower_hook) (struct frame *f, bool raise_flag);
   655 
   656   /* This hook is called to make the frame F visible if VISIBLE is
   657      true, or invisible otherwise. */
   658   void (*frame_visible_invisible_hook) (struct frame *f, bool visible);
   659 
   660   /* If the value of the frame parameter changed, this hook is called.
   661      For example, if going from fullscreen to not fullscreen this hook
   662      may do something OS dependent, like extended window manager hints on X11.  */
   663   void (*fullscreen_hook) (struct frame *f);
   664 
   665   /* This hook is called to iconify the frame.  */
   666   void (*iconify_frame_hook) (struct frame *f);
   667 
   668   /* This hook is called to change the size of frame F's native
   669    (underlying) window.  If CHANGE_GRAVITY, change to top-left-corner
   670    window gravity for this size change and subsequent size changes.
   671    Otherwise we leave the window gravity unchanged.  */
   672   void (*set_window_size_hook) (struct frame *f, bool change_gravity,
   673                                 int width, int height);
   674 
   675   /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
   676    to really change the position, and 0 when calling from
   677    *_make_frame_visible (in that case, XOFF and YOFF are the current
   678    position values).  It is -1 when calling from gui_set_frame_parameters,
   679    which means, do adjust for borders but don't change the gravity.  */
   680 
   681   void (*set_frame_offset_hook) (struct frame *f, register int xoff,
   682                                  register int yoff, int change_gravity);
   683 
   684   /* This hook is called to set the frame's transparency.  */
   685   void (*set_frame_alpha_hook) (struct frame *f);
   686 
   687   /* This hook is called to set a new font for the frame.  */
   688   Lisp_Object (*set_new_font_hook) (struct frame *f, Lisp_Object font_object,
   689                                     int fontset);
   690 
   691   /* This hook is called to set the GUI window icon of F using FILE.  */
   692   bool (*set_bitmap_icon_hook) (struct frame *f, Lisp_Object file);
   693 
   694   /* This hook is called to set the name of the GUI window of F by
   695      redisplay unless another name was explicitly requested.  */
   696   void (*implicit_set_name_hook) (struct frame *f, Lisp_Object arg,
   697                                   Lisp_Object oldval);
   698 
   699   /* This hook is called to display menus.  */
   700   Lisp_Object (*menu_show_hook) (struct frame *f, int x, int y, int menuflags,
   701                                  Lisp_Object title, const char **error_name);
   702 
   703 #ifdef HAVE_EXT_MENU_BAR
   704   /* This hook is called to activate the menu bar.  */
   705   void (*activate_menubar_hook) (struct frame *f);
   706 #endif
   707 
   708   /* This hook is called to display popup dialog.  */
   709   Lisp_Object (*popup_dialog_hook) (struct frame *f, Lisp_Object header,
   710                                     Lisp_Object contents);
   711 
   712   /* This hook is called to change the frame's (internal) tab-bar.  */
   713   void (*change_tab_bar_height_hook) (struct frame *f, int height);
   714 
   715   /* This hook is called to change the frame's (internal) tool-bar.  */
   716   void (*change_tool_bar_height_hook) (struct frame *f, int height);
   717 
   718   /* Scroll bar hooks.  */
   719 
   720   /* The representation of scroll bars is determined by the code which
   721      implements them, except for one thing: they must be represented by
   722      lisp objects.  This allows us to place references to them in
   723      Lisp_Windows without worrying about those references becoming
   724      dangling references when the scroll bar is destroyed.
   725 
   726      The window-system-independent portion of Emacs just refers to
   727      scroll bars via their windows, and never looks inside the scroll bar
   728      representation; it always uses hook functions to do all the
   729      scroll bar manipulation it needs.
   730 
   731      The `vertical_scroll_bar' field of a Lisp_Window refers to that
   732      window's scroll bar, or is nil if the window doesn't have a
   733      scroll bar.
   734 
   735      The `scroll_bars' and `condemned_scroll_bars' fields of a Lisp_Frame
   736      are free for use by the scroll bar implementation in any way it sees
   737      fit.  They are marked by the garbage collector.  */
   738 
   739 
   740   /* Set the vertical scroll bar for WINDOW to have its upper left corner
   741      at (TOP, LEFT), and be LENGTH rows high.  Set its handle to
   742      indicate that we are displaying PORTION characters out of a total
   743      of WHOLE characters, starting at POSITION.  If WINDOW doesn't yet
   744      have a scroll bar, create one for it.  */
   745   void (*set_vertical_scroll_bar_hook) (struct window *window,
   746                                         int portion, int whole,
   747                                         int position);
   748 
   749 
   750   /* Set the horizontal scroll bar for WINDOW to have its upper left
   751      corner at (TOP, LEFT), and be LENGTH rows high.  Set its handle to
   752      indicate that we are displaying PORTION characters out of a total
   753      of WHOLE characters, starting at POSITION.  If WINDOW doesn't yet
   754      have a scroll bar, create one for it.  */
   755   void (*set_horizontal_scroll_bar_hook) (struct window *window,
   756                                           int portion, int whole,
   757                                           int position);
   758 
   759   /* Set the default scroll bar width on FRAME.  */
   760   void (*set_scroll_bar_default_width_hook) (struct frame *frame);
   761 
   762   /* Set the default scroll bar height on FRAME.  */
   763   void (*set_scroll_bar_default_height_hook) (struct frame *frame);
   764 
   765   /* The following three hooks are used when we're doing a thorough
   766      redisplay of the frame.  We don't explicitly know which scroll bars
   767      are going to be deleted, because keeping track of when windows go
   768      away is a real pain - can you say set-window-configuration?
   769      Instead, we just assert at the beginning of redisplay that *all*
   770      scroll bars are to be removed, and then save scroll bars from the
   771      fiery pit when we actually redisplay their window.  */
   772 
   773   /* Arrange for all scroll bars on FRAME to be removed at the next call
   774      to `*judge_scroll_bars_hook'.  A scroll bar may be spared if
   775      `*redeem_scroll_bar_hook' is applied to its window before the judgment.
   776 
   777      This should be applied to each frame each time its window tree is
   778      redisplayed, even if it is not displaying scroll bars at the moment;
   779      if the HAS_SCROLL_BARS flag has just been turned off, only calling
   780      this and the judge_scroll_bars_hook will get rid of them.
   781 
   782      If non-zero, this hook should be safe to apply to any frame,
   783      whether or not it can support scroll bars, and whether or not it is
   784      currently displaying them.  */
   785   void (*condemn_scroll_bars_hook) (struct frame *frame);
   786 
   787   /* Unmark WINDOW's scroll bar for deletion in this judgment cycle.
   788      Note that it's okay to redeem a scroll bar that is not condemned.  */
   789   void (*redeem_scroll_bar_hook) (struct window *window);
   790 
   791   /* Remove all scroll bars on FRAME that haven't been saved since the
   792      last call to `*condemn_scroll_bars_hook'.
   793 
   794      This should be applied to each frame after each time its window
   795      tree is redisplayed, even if it is not displaying scroll bars at the
   796      moment; if the HAS_SCROLL_BARS flag has just been turned off, only
   797      calling this and condemn_scroll_bars_hook will get rid of them.
   798 
   799      If non-zero, this hook should be safe to apply to any frame,
   800      whether or not it can support scroll bars, and whether or not it is
   801      currently displaying them.  */
   802   void (*judge_scroll_bars_hook) (struct frame *FRAME);
   803 
   804 
   805   /* Called to read input events.
   806 
   807      TERMINAL indicates which terminal device to read from.  Input
   808      events should be read into HOLD_QUIT.
   809 
   810      A positive return value N indicates that N input events
   811      were read into BUF.
   812      Zero means no events were immediately available.
   813      A value of -1 means a transient read error, while -2 indicates
   814      that the device was closed (hangup), and it should be deleted.  */
   815   int (*read_socket_hook) (struct terminal *terminal,
   816                            struct input_event *hold_quit);
   817 
   818   /* Called when a frame's display becomes entirely up to date.  */
   819   void (*frame_up_to_date_hook) (struct frame *);
   820 
   821   /* Called when buffer flipping becomes unblocked after having
   822      previously been blocked.  Redisplay always blocks buffer flips
   823      while it runs.  */
   824   void (*buffer_flipping_unblocked_hook) (struct frame *);
   825 
   826   /* Retrieve the string resource specified by NAME with CLASS from
   827      database RDB. */
   828   const char * (*get_string_resource_hook) (void *rdb,
   829                                             const char *name,
   830                                             const char *class);
   831 
   832   /* Image hooks */
   833 #ifdef HAVE_WINDOW_SYSTEM
   834   /* Free the pixmap PIXMAP on F.  */
   835   void (*free_pixmap) (struct frame *f, Emacs_Pixmap pixmap);
   836 
   837 #endif
   838 
   839   /* Deletion hooks */
   840 
   841   /* Called to delete the device-specific portions of a frame that is
   842      on this terminal device. */
   843   void (*delete_frame_hook) (struct frame *);
   844 
   845   /* Called after the last frame on this terminal is deleted, or when
   846      the display device was closed (hangup).
   847 
   848      If this is NULL, then the generic delete_terminal is called
   849      instead.  Otherwise the hook must call delete_terminal itself.
   850 
   851      The hook must check for and close any live frames that are still
   852      on the terminal.  delete_frame ensures that there are no live
   853      frames on the terminal when it calls this hook, so infinite
   854      recursion is prevented.  */
   855   void (*delete_terminal_hook) (struct terminal *);
   856 
   857   /* Called to determine whether a position is on the toolkit tool bar
   858      or menu bar.  May be NULL.  It should accept five arguments
   859      FRAME, X, Y, MENU_BAR_P, TOOL_BAR_P, and store true into
   860      MENU_BAR_P if X and Y are in FRAME's toolkit menu bar, and true
   861      into TOOL_BAR_P if X and Y are in FRAME's toolkit tool bar.  */
   862   void (*toolkit_position_hook) (struct frame *, int, int, bool *, bool *);
   863 
   864 #ifdef HAVE_WINDOW_SYSTEM
   865   /* Called to determine if the mouse is grabbed on the given display.
   866      If either dpyinfo->grabbed or this returns true, then the display
   867      will be considered as grabbed.  */
   868   bool (*any_grab_hook) (Display_Info *);
   869 #endif
   870 } GCALIGNED_STRUCT;
   871 
   872 INLINE bool
   873 TERMINALP (Lisp_Object a)
   874 {
   875   return PSEUDOVECTORP (a, PVEC_TERMINAL);
   876 }
   877 
   878 INLINE struct terminal *
   879 XTERMINAL (Lisp_Object a)
   880 {
   881   eassert (TERMINALP (a));
   882   return XUNTAG (a, Lisp_Vectorlike, struct terminal);
   883 }
   884 
   885 /* Most code should use these functions to set Lisp fields in struct
   886    terminal.  */
   887 INLINE void
   888 tset_charset_list (struct terminal *t, Lisp_Object val)
   889 {
   890   t->charset_list = val;
   891 }
   892 INLINE void
   893 tset_selection_alist (struct terminal *t, Lisp_Object val)
   894 {
   895   t->Vselection_alist = val;
   896 }
   897 
   898 /* Chain of all terminal devices currently in use.  */
   899 extern struct terminal *terminal_list;
   900 
   901 #define FRAME_MUST_WRITE_SPACES(f) (FRAME_TTY (f)->must_write_spaces)
   902 #define FRAME_LINE_INS_DEL_OK(f) (FRAME_TTY (f)->line_ins_del_ok)
   903 #define FRAME_CHAR_INS_DEL_OK(f) (FRAME_TTY (f)->char_ins_del_ok)
   904 #define FRAME_SCROLL_REGION_OK(f) (FRAME_TTY (f)->scroll_region_ok)
   905 #define FRAME_SCROLL_REGION_COST(f) (FRAME_TTY (f)->scroll_region_cost)
   906 #define FRAME_MEMORY_BELOW_FRAME(f) (FRAME_TTY (f)->memory_below_frame)
   907 
   908 #define FRAME_TERMINAL_CODING(f) ((f)->terminal->terminal_coding)
   909 #define FRAME_KEYBOARD_CODING(f) ((f)->terminal->keyboard_coding)
   910 
   911 #define TERMINAL_TERMINAL_CODING(d) ((d)->terminal_coding)
   912 #define TERMINAL_KEYBOARD_CODING(d) ((d)->keyboard_coding)
   913 
   914 #define FRAME_RIF(f) ((f)->terminal->rif)
   915 
   916 #define FRAME_TERMINAL(f) ((f)->terminal)
   917 
   918 /* Return true if the terminal device is not suspended.  */
   919 #define TERMINAL_ACTIVE_P(d)                                            \
   920   (((d)->type != output_termcap && (d)->type != output_msdos_raw)       \
   921    || (d)->display_info.tty->input)
   922 
   923 /* Return font cache data for the specified terminal.  The historical
   924    name is grossly misleading, actually it is (NAME . FONT-LIST-CACHE).  */
   925 #if defined (HAVE_X_WINDOWS)
   926 #define TERMINAL_FONT_CACHE(t)                                          \
   927   (t->type == output_x_window ? t->display_info.x->name_list_element : Qnil)
   928 #elif defined (HAVE_NTGUI)
   929 #define TERMINAL_FONT_CACHE(t)                                          \
   930   (t->type == output_w32 ? t->display_info.w32->name_list_element : Qnil)
   931 #elif defined (HAVE_NS)
   932 #define TERMINAL_FONT_CACHE(t)                                          \
   933   (t->type == output_ns ? t->display_info.ns->name_list_element : Qnil)
   934 #elif defined (HAVE_PGTK)
   935 #define TERMINAL_FONT_CACHE(t)                                          \
   936   (t->type == output_pgtk ? t->display_info.pgtk->name_list_element : Qnil)
   937 #elif defined (HAVE_HAIKU)
   938 #define TERMINAL_FONT_CACHE(t)                                          \
   939   (t->type == output_haiku ? t->display_info.haiku->name_list_element : Qnil)
   940 #elif defined (HAVE_ANDROID)
   941 #define TERMINAL_FONT_CACHE(t)                                          \
   942   (t->type == output_android ? t->display_info.android->name_list_element : Qnil)
   943 #endif
   944 
   945 extern struct terminal *decode_live_terminal (Lisp_Object);
   946 extern struct terminal *decode_tty_terminal (Lisp_Object);
   947 extern struct terminal *get_named_terminal (const char *);
   948 extern struct terminal *create_terminal (enum output_method,
   949                                          struct redisplay_interface *);
   950 extern void delete_terminal (struct terminal *);
   951 extern void delete_terminal_internal (struct terminal *);
   952 extern Lisp_Object terminal_glyph_code (struct terminal *, int);
   953 
   954 /* The initial terminal device, created by initial_term_init.  */
   955 extern struct terminal *initial_terminal;
   956 
   957 extern unsigned char *encode_terminal_code (struct glyph *, int,
   958                                             struct coding_system *);
   959 
   960 #ifdef HAVE_GPM
   961 extern void close_gpm (int gpm_fd);
   962 #endif
   963 
   964 #ifdef WINDOWSNT
   965 extern int cursorX (struct tty_display_info *);
   966 extern int cursorY (struct tty_display_info *);
   967 #else
   968 #define cursorX(t)  curX(t)
   969 #define cursorY(t)  curY(t)
   970 #endif
   971 
   972 INLINE_HEADER_END
   973 
   974 #endif /* EMACS_TERMHOOKS_H */

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