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

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