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.
5 This file is part of SXEmacs
7 SXEmacs 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
10 (at your option) any later version.
12 SXEmacs 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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* Synched up with: Not in FSF. */
25 Ultimately based on FSF, then later on JWZ work for Lemacs.
26 Rewritten over time by Ben Wing and Chuck Thompson (original
27 multi-device work by Chuck Thompson).
30 #ifndef _XEMACS_CONSOLE_GTK_H_
31 #define _XEMACS_CONSOLE_GTK_H_
35 #include "ui/console.h"
38 #define GDK_DRAWABLE(x) (GdkDrawable *) (x)
39 #define GET_GTK_WIDGET_WINDOW(x) (GTK_WIDGET (x)->window)
40 #define GET_GTK_WIDGET_PARENT(x) (GTK_WIDGET (x)->parent)
42 DECLARE_CONSOLE_TYPE(gtk);
45 /* Gtk application info. */
46 GtkWidget *gtk_app_shell;
48 /* Cache of GC's for frame's on this device. */
49 struct gc_cache *gc_cache;
51 /* Selected visual, depth and colormap for this device */
54 GdkColormap *device_cmap;
56 /* Used by x_bevel_modeline in redisplay-x.c */
57 GdkBitmap *gray_pixmap;
59 /* frame that holds the WM_COMMAND property; there should be exactly
60 one of these per device. */
61 Lisp_Object WM_COMMAND_frame;
63 /* The following items are all used exclusively in event-gtk.c. */
64 int MetaMask, HyperMask, SuperMask, AltMask, ModeMask;
65 guint lock_interpretation;
67 void *x_modifier_keymap; /* Really an (XModifierKeymap *) */
70 int x_keysym_map_min_code;
71 int x_keysym_map_max_code;
72 int x_keysym_map_keysyms_per_code;
73 Lisp_Object x_keysym_map_hashtable;
75 /* #### It's not clear that there is much distinction anymore
76 between mouse_timestamp and global_mouse_timestamp, now that
77 Emacs doesn't see most (all?) events not destined for it. */
79 /* The timestamp of the last button or key event used by emacs itself.
80 This is used for asserting selections and input focus. */
81 guint32 mouse_timestamp;
83 /* This is the timestamp the last button or key event whether it was
84 dispatched to emacs or widgets. */
85 guint32 global_mouse_timestamp;
87 /* This is the last known timestamp received from the server. It is
88 maintained by x_event_to_emacs_event and used to patch bogus
89 WM_TAKE_FOCUS messages sent by Mwm. */
90 guint32 last_server_timestamp;
92 GdkAtom atom_WM_PROTOCOLS;
93 GdkAtom atom_WM_TAKE_FOCUS;
94 GdkAtom atom_WM_STATE;
98 /* stuff for sticky modifiers: */
99 unsigned int need_to_add_mask, down_mask;
100 KeyCode last_downkey;
101 guint32 release_time;
105 #define DEVICE_GTK_DATA(d) DEVICE_TYPE_DATA (d, gtk)
107 #define DEVICE_GTK_VISUAL(d) (DEVICE_GTK_DATA (d)->visual)
108 #define DEVICE_GTK_DEPTH(d) (DEVICE_GTK_DATA (d)->depth)
109 #define DEVICE_GTK_COLORMAP(d) (DEVICE_GTK_DATA (d)->device_cmap)
110 #define DEVICE_GTK_APP_SHELL(d) (DEVICE_GTK_DATA (d)->gtk_app_shell)
111 #define DEVICE_GTK_GC_CACHE(d) (DEVICE_GTK_DATA (d)->gc_cache)
112 #define DEVICE_GTK_GRAY_PIXMAP(d) (DEVICE_GTK_DATA (d)->gray_pixmap)
113 #define DEVICE_GTK_WM_COMMAND_FRAME(d) (DEVICE_GTK_DATA (d)->WM_COMMAND_frame)
114 #define DEVICE_GTK_MOUSE_TIMESTAMP(d) (DEVICE_GTK_DATA (d)->mouse_timestamp)
115 #define DEVICE_GTK_GLOBAL_MOUSE_TIMESTAMP(d) (DEVICE_GTK_DATA (d)->global_mouse_timestamp)
116 #define DEVICE_GTK_LAST_SERVER_TIMESTAMP(d) (DEVICE_GTK_DATA (d)->last_server_timestamp)
118 /* The maximum number of widgets that can be displayed above the text
119 area at one time. Currently no more than 3 will ever actually be
120 displayed (menubar, psheet, debugger panel). */
121 #define MAX_CONCURRENT_TOP_WIDGETS 8
124 /* The widget of this frame. */
125 GtkWidget *widget; /* This is really a GtkWindow */
127 /* The layout manager */
128 GtkWidget *container; /* actually a GtkVBox. */
130 /* The widget of the menubar */
131 GtkWidget *menubar_widget;
133 /* The widget of the edit portion of this frame; this is a GtkDrawingArea,
134 and the window of this widget is what the redisplay code draws on. */
135 GtkWidget *edit_widget;
137 /* Lists the widgets above the text area, in the proper order. */
138 GtkWidget *top_widgets[MAX_CONCURRENT_TOP_WIDGETS];
141 /* Our container widget as a Lisp_Object */
142 Lisp_Object lisp_visible_widgets[10];
144 /*************************** Miscellaneous **************************/
146 /* The icon pixmaps; these are Lisp_Image_Instance objects, or Qnil. */
147 Lisp_Object icon_pixmap;
148 Lisp_Object icon_pixmap_mask;
150 /* geometry string that ought to be freed. */
151 char *geom_free_me_please;
153 /* 1 if the frame is completely visible on the display, 0 otherwise.
154 if 0 the frame may have been iconified or may be totally
155 or partially hidden by another X window */
156 unsigned int totally_visible_p:1;
158 /* Is it visible at all? */
159 unsigned int visible_p:1;
161 /* Are we a top-level frame? This means that our shell is a
162 TopLevelShell, and we should do certain things to interact with
163 the window manager. */
164 unsigned int top_level_frame_p:1;
166 /* Are we iconfied right now? */
167 unsigned int iconified_p:1;
169 /* Data for widget callbacks. It is impossible to pass all the necessary
170 data through the GTK signal API so instead it is registered here and the
171 hash key is passed instead. */
172 Lisp_Object widget_instance_hash_table;
173 Lisp_Object widget_callback_hash_table;
174 Lisp_Object widget_callback_ex_hash_table;
177 #define FRAME_GTK_DATA(f) FRAME_TYPE_DATA (f, gtk)
179 #define FRAME_GTK_SHELL_WIDGET(f) (FRAME_GTK_DATA (f)->widget)
180 #define FRAME_GTK_CONTAINER_WIDGET(f) (FRAME_GTK_DATA (f)->container)
181 #define FRAME_GTK_MENUBAR_WIDGET(f) (FRAME_GTK_DATA (f)->menubar_widget)
182 #define FRAME_GTK_TEXT_WIDGET(f) (FRAME_GTK_DATA (f)->edit_widget)
183 #define FRAME_GTK_TOP_WIDGETS(f) (FRAME_GTK_DATA (f)->top_widgets)
184 #define FRAME_GTK_NUM_TOP_WIDGETS(f) (FRAME_GTK_DATA (f)->num_top_widgets)
185 #define FRAME_GTK_ICONIFIED_P(f) (FRAME_GTK_DATA (f)->iconfigied_p)
187 #define FRAME_GTK_LISP_WIDGETS(f) (FRAME_GTK_DATA (f)->lisp_visible_widgets)
188 #define FRAME_GTK_ICON_PIXMAP(f) (FRAME_GTK_DATA (f)->icon_pixmap)
189 #define FRAME_GTK_ICON_PIXMAP_MASK(f) (FRAME_GTK_DATA (f)->icon_pixmap_mask)
191 #define FRAME_GTK_GEOM_FREE_ME_PLEASE(f) (FRAME_GTK_DATA (f)->geom_free_me_please)
193 #define FRAME_GTK_TOTALLY_VISIBLE_P(f) (FRAME_GTK_DATA (f)->totally_visible_p)
194 #define FRAME_GTK_VISIBLE_P(f) (FRAME_GTK_DATA (f)->visible_p)
195 #define FRAME_GTK_TOP_LEVEL_FRAME_P(f) (FRAME_GTK_DATA (f)->top_level_frame_p)
196 #define FRAME_GTK_WIDGET_INSTANCE_HASH_TABLE(f) (FRAME_GTK_DATA (f)->widget_instance_hash_table)
197 #define FRAME_GTK_WIDGET_CALLBACK_HASH_TABLE(f) (FRAME_GTK_DATA (f)->widget_callback_hash_table)
198 #define FRAME_GTK_WIDGET_CALLBACK_EX_HASH_TABLE(f) (FRAME_GTK_DATA (f)->widget_callback_ex_hash_table)
200 /* Special data used to quickly identify the frame that contains a widget. */
201 #define GTK_DATA_FRAME_IDENTIFIER "xemacs::frame"
203 /* The hashcode in the frame hash table of a tab_control tab's callback data. */
204 #define GTK_DATA_TAB_HASHCODE_IDENTIFIER "xemacs::tab_hashcode"
206 #define GTK_DATA_GUI_IDENTIFIER "xemacs::gui_id"
208 /* Variables associated with the X display frame this emacs is using. */
210 extern Lisp_Object Vx_gc_pointer_shape;
211 extern Lisp_Object Vx_scrollbar_pointer_shape;
213 extern struct console_type *gtk_console_type;
214 extern Lisp_Object Vdefault_gtk_device;
216 /* Number of pixels below each line. */
217 extern int gtk_interline_space;
219 extern int gtk_selection_timeout;
221 struct frame *gtk_widget_to_frame(GtkWidget *);
222 struct frame *gtk_any_window_to_frame(struct device *d, GdkWindow *);
223 struct frame *gtk_window_to_frame(struct device *d, GdkWindow *);
224 struct frame *gtk_any_widget_or_parent_to_frame(struct device *d,
226 struct frame *decode_gtk_frame(Lisp_Object);
227 struct device *gtk_any_window_to_device(GdkWindow *);
228 struct device *decode_gtk_device(Lisp_Object);
229 void gtk_handle_property_notify(GdkEventProperty * event);
231 void signal_special_gtk_user_event(Lisp_Object channel, Lisp_Object function,
233 void gtk_redraw_exposed_area(struct frame *f, int x, int y,
234 int width, int height);
235 void gtk_output_string(struct window *w, struct display_line *dl,
236 Emchar_dynarr * buf, int xpos, int xoffset,
237 int start_pixpos, int width, face_index findex,
238 int cursor, int cursor_start, int cursor_width,
240 void gtk_output_gdk_pixmap(struct frame *f, struct Lisp_Image_Instance *p,
241 int x, int y, int clip_x, int clip_y,
242 int clip_width, int clip_height, int width,
243 int height, int pixmap_offset,
244 GdkColor * fg, GdkColor * bg, GdkGC * override_gc);
245 void gtk_output_shadows(struct frame *f, int x, int y, int width,
246 int height, int shadow_thickness);
248 int gtk_initialize_frame_menubar(struct frame *f);
249 void gtk_init_modifier_mapping(struct device *d);
251 void Initialize_Locale(void);
253 extern Lisp_Object Vgtk_initial_argv_list; /* #### ugh! */
255 const char *gtk_event_name(GdkEventType event_type);
256 #endif /* HAVE_GTK */
257 #endif /* _XEMACS_DEVICE_X_H_ */