(coded-charset-entity-reference-alist): Add setting for
[chise/xemacs-chise.git.1] / src / console-gtk.h
1 /* Define X specific console, device, and frame object for XEmacs.
2    Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
3    Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
4
5 This file is part of XEmacs.
6
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING.  If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* Synched up with: Not in FSF. */
23
24
25 /* Authorship:
26
27    Ultimately based on FSF, then later on JWZ work for Lemacs.
28    Rewritten over time by Ben Wing and Chuck Thompson (original
29       multi-device work by Chuck Thompson).
30  */
31
32 #ifndef _XEMACS_CONSOLE_GTK_H_
33 #define _XEMACS_CONSOLE_GTK_H_
34
35 #ifdef HAVE_GTK
36
37 #include "console.h"
38 #include <gtk/gtk.h>
39
40 #define GDK_DRAWABLE(x) (GdkDrawable *) (x)
41 #define GET_GTK_WIDGET_WINDOW(x) (GTK_WIDGET (x)->window)
42 #define GET_GTK_WIDGET_PARENT(x) (GTK_WIDGET (x)->parent)
43
44 DECLARE_CONSOLE_TYPE (gtk);
45
46 struct gtk_device
47 {
48   /* Gtk application info. */
49   GtkWidget *gtk_app_shell;
50
51   /* Cache of GC's for frame's on this device. */
52   struct gc_cache *gc_cache;
53
54   /* Selected visual, depth and colormap for this device */
55   GdkVisual *visual;
56   int depth;
57   GdkColormap *device_cmap;
58
59   /* Used by x_bevel_modeline in redisplay-x.c */
60   GdkBitmap *gray_pixmap;
61
62   /* frame that holds the WM_COMMAND property; there should be exactly
63      one of these per device. */
64   Lisp_Object WM_COMMAND_frame;
65
66   /* The following items are all used exclusively in event-gtk.c. */
67   int MetaMask, HyperMask, SuperMask, AltMask, ModeMask;
68   guint lock_interpretation;
69
70   void *x_modifier_keymap; /* Really an (XModifierKeymap *)*/
71
72   guint *x_keysym_map;
73   int x_keysym_map_min_code;
74   int x_keysym_map_max_code;
75   int x_keysym_map_keysyms_per_code;
76   Lisp_Object x_keysym_map_hashtable;
77
78   /* #### It's not clear that there is much distinction anymore
79      between mouse_timestamp and global_mouse_timestamp, now that
80      Emacs doesn't see most (all?) events not destined for it. */
81
82   /* The timestamp of the last button or key event used by emacs itself.
83      This is used for asserting selections and input focus. */
84   guint32 mouse_timestamp;
85
86   /* This is the timestamp the last button or key event whether it was
87      dispatched to emacs or widgets. */
88   guint32 global_mouse_timestamp;
89
90   /* This is the last known timestamp received from the server.  It is
91      maintained by x_event_to_emacs_event and used to patch bogus
92      WM_TAKE_FOCUS messages sent by Mwm. */
93   guint32 last_server_timestamp;
94
95   GdkAtom atom_WM_PROTOCOLS;
96   GdkAtom atom_WM_TAKE_FOCUS;
97   GdkAtom atom_WM_STATE;
98
99 #if 0
100         /* #### BILL!!! */
101   /* stuff for sticky modifiers: */
102   unsigned int need_to_add_mask, down_mask;
103   KeyCode last_downkey;
104   guint32 release_time;
105 #endif
106 };
107
108 #define DEVICE_GTK_DATA(d) DEVICE_TYPE_DATA (d, gtk)
109
110 #define DEVICE_GTK_VISUAL(d)    (DEVICE_GTK_DATA (d)->visual)
111 #define DEVICE_GTK_DEPTH(d)     (DEVICE_GTK_DATA (d)->depth)
112 #define DEVICE_GTK_COLORMAP(d)  (DEVICE_GTK_DATA (d)->device_cmap)
113 #define DEVICE_GTK_APP_SHELL(d)         (DEVICE_GTK_DATA (d)->gtk_app_shell)
114 #define DEVICE_GTK_GC_CACHE(d)  (DEVICE_GTK_DATA (d)->gc_cache)
115 #define DEVICE_GTK_GRAY_PIXMAP(d) (DEVICE_GTK_DATA (d)->gray_pixmap)
116 #define DEVICE_GTK_WM_COMMAND_FRAME(d) (DEVICE_GTK_DATA (d)->WM_COMMAND_frame)
117 #define DEVICE_GTK_MOUSE_TIMESTAMP(d)  (DEVICE_GTK_DATA (d)->mouse_timestamp)
118 #define DEVICE_GTK_GLOBAL_MOUSE_TIMESTAMP(d) (DEVICE_GTK_DATA (d)->global_mouse_timestamp)
119 #define DEVICE_GTK_LAST_SERVER_TIMESTAMP(d)  (DEVICE_GTK_DATA (d)->last_server_timestamp)
120
121 /* The maximum number of widgets that can be displayed above the text
122    area at one time.  Currently no more than 3 will ever actually be
123    displayed (menubar, psheet, debugger panel). */
124 #define MAX_CONCURRENT_TOP_WIDGETS 8
125
126 struct gtk_frame
127 {
128   /* The widget of this frame. */
129   GtkWidget *widget;            /* This is really a GtkWindow */
130
131   /* The layout manager */
132   GtkWidget *container;         /* actually a GtkVBox. */
133
134   /* The widget of the menubar */
135   GtkWidget *menubar_widget;
136
137   /* The widget of the edit portion of this frame; this is a GtkDrawingArea,
138      and the window of this widget is what the redisplay code draws on. */
139   GtkWidget *edit_widget;
140
141   /* Lists the widgets above the text area, in the proper order. */
142   GtkWidget *top_widgets[MAX_CONCURRENT_TOP_WIDGETS];
143   int num_top_widgets;
144
145   /* Our container widget as a Lisp_Object */
146   Lisp_Object lisp_visible_widgets[10];
147
148   /*************************** Miscellaneous **************************/
149
150   /* The icon pixmaps; these are Lisp_Image_Instance objects, or Qnil. */
151   Lisp_Object icon_pixmap;
152   Lisp_Object icon_pixmap_mask;
153
154   /* geometry string that ought to be freed. */
155   char *geom_free_me_please;
156
157   /* 1 if the frame is completely visible on the display, 0 otherwise.
158      if 0 the frame may have been iconified or may be totally
159      or partially hidden by another X window */
160   unsigned int totally_visible_p :1;
161
162     /* Is it visible at all? */
163   unsigned int visible_p :1;
164
165   /* Are we a top-level frame?  This means that our shell is a
166      TopLevelShell, and we should do certain things to interact with
167      the window manager. */
168   unsigned int top_level_frame_p :1;
169
170   /* Are we iconfied right now? */
171   unsigned int iconified_p :1;
172
173   /* Data for widget callbacks.  It is impossible to pass all the necessary
174      data through the GTK signal API so instead it is registered here and the
175      hash key is passed instead. */
176   Lisp_Object widget_instance_hash_table;
177   Lisp_Object widget_callback_hash_table;
178   Lisp_Object widget_callback_ex_hash_table;
179 };
180
181 #define FRAME_GTK_DATA(f) FRAME_TYPE_DATA (f, gtk)
182
183 #define FRAME_GTK_SHELL_WIDGET(f)           (FRAME_GTK_DATA (f)->widget)
184 #define FRAME_GTK_CONTAINER_WIDGET(f) (FRAME_GTK_DATA (f)->container)
185 #define FRAME_GTK_MENUBAR_WIDGET(f)   (FRAME_GTK_DATA (f)->menubar_widget)
186 #define FRAME_GTK_TEXT_WIDGET(f)            (FRAME_GTK_DATA (f)->edit_widget)
187 #define FRAME_GTK_TOP_WIDGETS(f)            (FRAME_GTK_DATA (f)->top_widgets)
188 #define FRAME_GTK_NUM_TOP_WIDGETS(f)      (FRAME_GTK_DATA (f)->num_top_widgets)
189 #define FRAME_GTK_ICONIFIED_P(f)          (FRAME_GTK_DATA (f)->iconfigied_p)
190
191 #define FRAME_GTK_LISP_WIDGETS(f)      (FRAME_GTK_DATA (f)->lisp_visible_widgets)
192 #define FRAME_GTK_ICON_PIXMAP(f)            (FRAME_GTK_DATA (f)->icon_pixmap)
193 #define FRAME_GTK_ICON_PIXMAP_MASK(f) (FRAME_GTK_DATA (f)->icon_pixmap_mask)
194
195 #define FRAME_GTK_GEOM_FREE_ME_PLEASE(f) (FRAME_GTK_DATA (f)->geom_free_me_please)
196
197 #define FRAME_GTK_TOTALLY_VISIBLE_P(f) (FRAME_GTK_DATA (f)->totally_visible_p)
198 #define FRAME_GTK_VISIBLE_P(f) (FRAME_GTK_DATA (f)->visible_p)
199 #define FRAME_GTK_TOP_LEVEL_FRAME_P(f) (FRAME_GTK_DATA (f)->top_level_frame_p)
200 #define FRAME_GTK_WIDGET_INSTANCE_HASH_TABLE(f) (FRAME_GTK_DATA (f)->widget_instance_hash_table)
201 #define FRAME_GTK_WIDGET_CALLBACK_HASH_TABLE(f) (FRAME_GTK_DATA (f)->widget_callback_hash_table)
202 #define FRAME_GTK_WIDGET_CALLBACK_EX_HASH_TABLE(f) (FRAME_GTK_DATA (f)->widget_callback_ex_hash_table)
203
204 /* Special data used to quickly identify the frame that contains a widget. */
205 #define GTK_DATA_FRAME_IDENTIFIER "xemacs::frame"
206
207 /* The hashcode in the frame hash table of a tab_control tab's callback data. */
208 #define GTK_DATA_TAB_HASHCODE_IDENTIFIER "xemacs::tab_hashcode"
209
210 #define GTK_DATA_GUI_IDENTIFIER "xemacs::gui_id"
211
212 /* Variables associated with the X display frame this emacs is using. */
213
214 extern Lisp_Object Vx_gc_pointer_shape;
215 extern Lisp_Object Vx_scrollbar_pointer_shape;
216
217 extern struct console_type *gtk_console_type;
218 extern Lisp_Object Vdefault_gtk_device;
219
220 /* Number of pixels below each line. */
221 extern int gtk_interline_space;
222
223 extern int gtk_selection_timeout;
224
225 struct frame *gtk_widget_to_frame (GtkWidget *);
226 struct frame *gtk_any_window_to_frame (struct device *d, GdkWindow *);
227 struct frame *gtk_window_to_frame (struct device *d, GdkWindow *);
228 struct frame *gtk_any_widget_or_parent_to_frame (struct device *d, GtkWidget *widget);
229 struct frame *decode_gtk_frame (Lisp_Object);
230 struct device *gtk_any_window_to_device (GdkWindow *);
231 struct device *decode_gtk_device (Lisp_Object);
232 void gtk_handle_property_notify (GdkEventProperty *event);
233
234 void signal_special_gtk_user_event (Lisp_Object channel, Lisp_Object function,
235                                     Lisp_Object object);
236 void gtk_redraw_exposed_area (struct frame *f, int x, int y,
237                             int width, int height);
238 void gtk_output_string (struct window *w, struct display_line *dl,
239                       Emchar_dynarr *buf, int xpos, int xoffset,
240                       int start_pixpos, int width, face_index findex,
241                       int cursor, int cursor_start, int cursor_width,
242                       int cursor_height);
243 void gtk_output_gdk_pixmap (struct frame *f, struct Lisp_Image_Instance *p,
244                             int x, int y, int clip_x, int clip_y,
245                             int clip_width, int clip_height, int width,
246                             int height, int pixmap_offset,
247                             GdkColor *fg, GdkColor *bg,
248                             GdkGC *override_gc);
249 void gtk_output_shadows (struct frame *f, int x, int y, int width,
250                        int height, int shadow_thickness);
251
252 int gtk_initialize_frame_menubar (struct frame *f);
253 void gtk_init_modifier_mapping (struct device *d);
254
255 void Initialize_Locale (void);
256
257 extern Lisp_Object Vgtk_initial_argv_list; /* #### ugh! */
258
259 const char *gtk_event_name (GdkEventType event_type);
260 #endif /* HAVE_GTK */
261 #endif /* _XEMACS_DEVICE_X_H_ */