root/src/xwidget.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. syms_of_xwidget
  2. valid_xwidget_spec_p
  3. xwidget_view_delete_all_in_window
  4. x_draw_xwidget_glyph_string
  5. lookup_xwidget
  6. xwidget_end_redisplay
  7. kill_buffer_xwidgets

     1 /* Support for embedding graphical components in a buffer.
     2 
     3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
     4 
     5 This file is part of GNU Emacs.
     6 
     7 GNU Emacs is free software: you can redistribute it and/or modify
     8 it under the terms of the GNU General Public License as published by
     9 the Free Software Foundation, either version 3 of the License, or (at
    10 your option) any later version.
    11 
    12 GNU Emacs is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    19 
    20 #ifndef XWIDGET_H_INCLUDED
    21 #define XWIDGET_H_INCLUDED
    22 
    23 #include "lisp.h"
    24 
    25 struct glyph_matrix;
    26 struct glyph_string;
    27 struct xwidget;
    28 struct xwidget_view;
    29 struct window;
    30 
    31 #ifdef HAVE_XWIDGETS
    32 
    33 #if defined (USE_GTK)
    34 #include <gtk/gtk.h>
    35 #ifndef HAVE_PGTK
    36 #include <X11/Xlib.h>
    37 #include "xterm.h"
    38 #else
    39 #include "pgtkterm.h"
    40 #endif
    41 #elif defined (NS_IMPL_COCOA) && defined (__OBJC__)
    42 #import <AppKit/NSView.h>
    43 #import "nsxwidget.h"
    44 #endif
    45 
    46 #ifdef HAVE_XINPUT2
    47 #include <X11/extensions/XInput2.h>
    48 #endif
    49 
    50 struct xwidget
    51 {
    52   union vectorlike_header header;
    53 
    54   /* Auxiliary data.  */
    55   Lisp_Object plist;
    56 
    57   /* The widget type.  */
    58   Lisp_Object type;
    59 
    60   /* The buffer where the xwidget lives.  */
    61   Lisp_Object buffer;
    62 
    63   /* A title used for button labels, for instance.  */
    64   Lisp_Object title;
    65 
    66   /* Vector of currently executing scripts with callbacks.  */
    67   Lisp_Object script_callbacks;
    68   /* Here ends the Lisp part.  script_callbacks is the marker field.  */
    69 
    70   int height;
    71   int width;
    72   uint32_t xwidget_id;
    73   char *find_text;
    74 
    75 #if defined (USE_GTK)
    76   /* For offscreen widgets, unused if not osr.  */
    77   GtkWidget *widget_osr;
    78   GtkWidget *widgetwindow_osr;
    79   struct frame *embedder;
    80   struct xwidget_view *embedder_view;
    81   guint hit_result;
    82 #elif defined (NS_IMPL_COCOA)
    83 # ifdef __OBJC__
    84   /* For offscreen widgets, unused if not osr.  */
    85   NSView *xwWidget;
    86   XwWindow *xwWindow;
    87 
    88   /* Used only for xwidget types (such as webkit2) enforcing 1 to 1
    89      relationship between model and view.  */
    90   struct xwidget_view *xv;
    91 # else
    92   void *xwWidget;
    93   void *xwWindow;
    94   struct xwidget_view *xv;
    95 # endif
    96 #endif
    97 
    98   /* Kill silently if Emacs is exited.  */
    99   bool_bf kill_without_query : 1;
   100 } GCALIGNED_STRUCT;
   101 
   102 struct xwidget_view
   103 {
   104   union vectorlike_header header;
   105   Lisp_Object model;
   106   Lisp_Object w;
   107   /* Here ends the lisp part.  "w" is the marker field.  */
   108 
   109   /* If touched by redisplay.  */
   110   bool redisplayed;
   111 
   112   /* The "live" instance isn't drawn.  */
   113   bool hidden;
   114 
   115   enum glyph_row_area area;
   116 
   117 #if defined (USE_GTK)
   118 #ifndef HAVE_PGTK
   119   Display *dpy;
   120   Window wdesc;
   121 
   122   GdkWindow *last_crossing_window;
   123   guint last_crossing_cursor_signal;
   124   GtkWidget *passive_grab;
   125   guint passive_grab_destruction_signal;
   126   guint passive_grab_drag_signal;
   127 #else
   128   struct pgtk_display_info *dpyinfo;
   129   GtkWidget *widget;
   130 #endif
   131   Emacs_Cursor cursor;
   132   struct frame *frame;
   133 
   134   cairo_surface_t *cr_surface;
   135   cairo_t *cr_context;
   136   int just_resized;
   137 #elif defined (NS_IMPL_COCOA)
   138 # ifdef __OBJC__
   139   XvWindow *xvWindow;
   140   NSView *emacswindow;
   141 # else
   142   void *xvWindow;
   143   void *emacswindow;
   144 # endif
   145 #endif
   146 
   147   int x;
   148   int y;
   149   int clip_right;
   150   int clip_bottom;
   151   int clip_top;
   152   int clip_left;
   153 
   154   long handler_id;
   155 } GCALIGNED_STRUCT;
   156 #endif
   157 
   158 /* Test for xwidget pseudovector.  */
   159 #define XWIDGETP(x) PSEUDOVECTORP (x, PVEC_XWIDGET)
   160 #define XXWIDGET(a) (eassert (XWIDGETP (a)), \
   161                      XUNTAG (a, Lisp_Vectorlike, struct xwidget))
   162 
   163 #define XWIDGET_LIVE_P(w) (!NILP ((w)->buffer))
   164 
   165 #define CHECK_XWIDGET(x) \
   166   CHECK_TYPE (XWIDGETP (x), Qxwidgetp, x)
   167 
   168 #define CHECK_LIVE_XWIDGET(x)                           \
   169   CHECK_TYPE ((XWIDGETP (x)                             \
   170                && XWIDGET_LIVE_P (XXWIDGET (x))),       \
   171               Qxwidget_live_p, x)
   172 
   173 /* Test for xwidget_view pseudovector.  */
   174 #define XWIDGET_VIEW_P(x) PSEUDOVECTORP (x, PVEC_XWIDGET_VIEW)
   175 #define XXWIDGET_VIEW(a) (eassert (XWIDGET_VIEW_P (a)), \
   176                           XUNTAG (a, Lisp_Vectorlike, struct xwidget_view))
   177 
   178 #define CHECK_XWIDGET_VIEW(x) \
   179   CHECK_TYPE (XWIDGET_VIEW_P (x), Qxwidget_view_p, x)
   180 
   181 #define XG_XWIDGET "emacs_xwidget"
   182 #define XG_XWIDGET_VIEW "emacs_xwidget_view"
   183 
   184 #ifdef HAVE_XWIDGETS
   185 void syms_of_xwidget (void);
   186 bool valid_xwidget_spec_p (Lisp_Object);
   187 void xwidget_view_delete_all_in_window (struct window *);
   188 void x_draw_xwidget_glyph_string (struct glyph_string *);
   189 struct xwidget *lookup_xwidget (Lisp_Object spec);
   190 void xwidget_end_redisplay (struct window *, struct glyph_matrix *);
   191 void kill_buffer_xwidgets (Lisp_Object);
   192 /* Defined in 'xwidget.c'.  */
   193 void store_xwidget_event_string (struct xwidget *xw,
   194                                  const char *eventname,
   195                                  const char *eventstr);
   196 
   197 void store_xwidget_download_callback_event (struct xwidget *xw,
   198                                             const char *url,
   199                                             const char *mimetype,
   200                                             const char *filename);
   201 
   202 void store_xwidget_js_callback_event (struct xwidget *xw,
   203                                       Lisp_Object proc,
   204                                       Lisp_Object argument);
   205 
   206 extern struct xwidget *xwidget_from_id (uint32_t id);
   207 
   208 #ifdef HAVE_X_WINDOWS
   209 struct xwidget_view *xwidget_view_from_window (Window wdesc);
   210 void xwidget_expose (struct xwidget_view *xv);
   211 extern void lower_frame_xwidget_views (struct frame *f);
   212 #endif
   213 #ifndef NS_IMPL_COCOA
   214 extern void kill_frame_xwidget_views (struct frame *f);
   215 #endif
   216 #ifdef HAVE_X_WINDOWS
   217 extern void xwidget_button (struct xwidget_view *, bool, int,
   218                             int, int, int, Time);
   219 extern void xwidget_motion_or_crossing (struct xwidget_view *,
   220                                         const XEvent *);
   221 #ifdef HAVE_XINPUT2
   222 extern void xwidget_motion_notify (struct xwidget_view *, double,
   223                                    double, double, double, uint, Time);
   224 extern void xwidget_scroll (struct xwidget_view *, double, double,
   225                             double, double, uint, Time, bool);
   226 #ifdef HAVE_XINPUT2_4
   227 extern void xwidget_pinch (struct xwidget_view *, XIGesturePinchEvent *);
   228 #endif
   229 #endif
   230 #endif
   231 #else
   232 INLINE_HEADER_BEGIN
   233 INLINE void syms_of_xwidget (void) {}
   234 INLINE bool valid_xwidget_spec_p (Lisp_Object obj) { return false; }
   235 INLINE void xwidget_view_delete_all_in_window (struct window *w) {}
   236 INLINE void x_draw_xwidget_glyph_string (struct glyph_string *s) { eassume (0); }
   237 INLINE struct xwidget *lookup_xwidget (Lisp_Object obj) { eassume (0); }
   238 INLINE void xwidget_end_redisplay (struct window *w, struct glyph_matrix *m) {}
   239 INLINE void kill_buffer_xwidgets (Lisp_Object buf) {}
   240 INLINE_HEADER_END
   241 #endif
   242 
   243 #endif /* XWIDGET_H_INCLUDED */

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