1 /* Define X specific console, device, and frame object for SXEmacs.
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 INCLUDED_console_x_h_
31 #define INCLUDED_console_x_h_
35 #include "ui/console.h"
36 /* must come before Xutil.h, which is included indirectly from xintrinsic.h,
37 to avoid breakage in keysym-parsing macros from X11R6, at least X.org as
38 of 2005-01-17, and probably XFree86 too from reports on c.e.x */
39 #include <X11/keysym.h>
40 #include "xintrinsic.h"
42 #include <X11/cursorfont.h>
43 #include <X11/Xatom.h>
44 #include <X11/StringDefs.h>
50 /* R5 defines the XPointer type, but R4 doesn't.
51 R4 also doesn't define a version number, but R5 does. */
52 #if (XlibSpecificationRelease < 5)
53 # define XPointer char *
56 DECLARE_CONSOLE_TYPE(x);
59 /* The X connection of this device. */
62 /* Set by x_IO_error_handler(). */
65 /* Xt application info. */
68 /* Cache of GC's for frames on this device. */
69 struct gc_cache *gc_cache;
71 /* Selected visual, depth and colormap for this device */
76 /* Used by x_bevel_modeline in redisplay-x.c */
79 /* Atoms associated with this device. */
80 /* allocated in Xatoms_of_device_x */
81 Atom Xatom_WM_PROTOCOLS;
82 Atom Xatom_WM_DELETE_WINDOW;
83 Atom Xatom_WM_SAVE_YOURSELF;
84 Atom Xatom_WM_TAKE_FOCUS;
87 /* allocated in Xatoms_of_select_x */
98 Atom Xatom_COMPOUND_TEXT;
100 /* allocated in Xatoms_of_objects_x */
102 Atom Xatom_FAMILY_NAME;
103 Atom Xatom_WEIGHT_NAME;
105 Atom Xatom_SETWIDTH_NAME;
106 Atom Xatom_ADD_STYLE_NAME;
107 Atom Xatom_PIXEL_SIZE;
108 Atom Xatom_POINT_SIZE;
109 Atom Xatom_RESOLUTION_X;
110 Atom Xatom_RESOLUTION_Y;
112 Atom Xatom_AVERAGE_WIDTH;
113 Atom Xatom_CHARSET_REGISTRY;
114 Atom Xatom_CHARSET_ENCODING;
116 /* The following items are all used exclusively in event-Xt.c. */
117 int MetaMask, HyperMask, SuperMask, AltMask, ModeMask;
118 KeySym lock_interpretation;
120 XModifierKeymap *x_modifier_keymap;
122 KeySym *x_keysym_map;
123 int x_keysym_map_min_code;
124 int x_keysym_map_max_code;
125 int x_keysym_map_keysyms_per_code;
126 Lisp_Object x_keysym_map_hash_table;
128 /* frame that holds the WM_COMMAND property; there should be exactly
129 one of these per device. */
130 Lisp_Object WM_COMMAND_frame;
132 /* #### It's not clear that there is much distinction anymore
133 between mouse_timestamp and global_mouse_timestamp, now that
134 Emacs doesn't see most (all?) events not destined for it. */
136 /* The timestamp of the last button or key event used by emacs itself.
137 This is used for asserting selections and input focus. */
138 Time mouse_timestamp;
140 /* This is the timestamp the last button or key event whether it was
141 dispatched to emacs or widgets. */
142 Time global_mouse_timestamp;
144 /* This is the last known timestamp received from the server. It is
145 maintained by x_event_to_emacs_event and used to patch bogus
146 WM_TAKE_FOCUS messages sent by Mwm. */
147 Time last_server_timestamp;
149 /* Used by Xlib to preserve information across calls to
150 XLookupString(), to implement compose processing.
152 According to The X Window System, p. 467, "The creation of
153 XComposeStatus structures is implementation dependent;
154 a portable program must pass NULL for this argument."
155 But this means that a portable program cannot implement
156 compose processing! WTF?
158 So we just set it to all zeros. */
160 /* No X Server ever used this, AFAIK -- mrb */
161 /* XComposeStatus x_compose_status; */
165 XIMStyles *xim_styles;
166 #endif /* HAVE_XIM */
168 /* stuff for sticky modifiers: */
170 unsigned int need_to_add_mask, down_mask;
171 KeyCode last_downkey;
173 Time modifier_release_time;
176 #define DEVICE_X_DATA(d) DEVICE_TYPE_DATA (d, x)
178 #define FRAME_X_DISPLAY(f) (DEVICE_X_DISPLAY (XDEVICE (f->device)))
179 #define DEVICE_X_DISPLAY(d) (DEVICE_X_DATA (d)->display)
180 #define DEVICE_X_BEING_DELETED(d) (DEVICE_X_DATA (d)->being_deleted)
181 #define DEVICE_X_VISUAL(d) (DEVICE_X_DATA (d)->visual)
182 #define DEVICE_X_DEPTH(d) (DEVICE_X_DATA (d)->depth)
183 #define DEVICE_X_COLORMAP(d) (DEVICE_X_DATA (d)->device_cmap)
184 #define DEVICE_XT_APP_SHELL(d) (DEVICE_X_DATA (d)->Xt_app_shell)
185 #define DEVICE_X_GC_CACHE(d) (DEVICE_X_DATA (d)->gc_cache)
186 #define DEVICE_X_GRAY_PIXMAP(d) (DEVICE_X_DATA (d)->gray_pixmap)
187 #define DEVICE_X_WM_COMMAND_FRAME(d) (DEVICE_X_DATA (d)->WM_COMMAND_frame)
188 #define DEVICE_X_MOUSE_TIMESTAMP(d) (DEVICE_X_DATA (d)->mouse_timestamp)
189 #define DEVICE_X_GLOBAL_MOUSE_TIMESTAMP(d) (DEVICE_X_DATA (d)->global_mouse_timestamp)
190 #define DEVICE_X_LAST_SERVER_TIMESTAMP(d) (DEVICE_X_DATA (d)->last_server_timestamp)
191 #define DEVICE_X_KEYSYM_MAP_HASH_TABLE(d) (DEVICE_X_DATA (d)->x_keysym_map_hash_table)
192 /* #define DEVICE_X_X_COMPOSE_STATUS(d) (DEVICE_X_DATA (d)->x_compose_status) */
194 #define DEVICE_X_XIM(d) (DEVICE_X_DATA (d)->xim)
195 #define DEVICE_X_XIM_STYLES(d) (DEVICE_X_DATA (d)->xim_styles)
196 #define DEVICE_X_FONTSET(d) (DEVICE_X_DATA (d)->fontset)
197 #endif /* HAVE_XIM */
199 /* allocated in Xatoms_of_device_x */
200 #define DEVICE_XATOM_WM_PROTOCOLS(d) (DEVICE_X_DATA (d)->Xatom_WM_PROTOCOLS)
201 #define DEVICE_XATOM_WM_DELETE_WINDOW(d) (DEVICE_X_DATA (d)->Xatom_WM_DELETE_WINDOW)
202 #define DEVICE_XATOM_WM_SAVE_YOURSELF(d) (DEVICE_X_DATA (d)->Xatom_WM_SAVE_YOURSELF)
203 #define DEVICE_XATOM_WM_TAKE_FOCUS(d) (DEVICE_X_DATA (d)->Xatom_WM_TAKE_FOCUS)
204 #define DEVICE_XATOM_WM_STATE(d) (DEVICE_X_DATA (d)->Xatom_WM_STATE)
206 /* allocated in Xatoms_of_select_x */
207 #define DEVICE_XATOM_CLIPBOARD(d) (DEVICE_X_DATA (d)->Xatom_CLIPBOARD)
208 #define DEVICE_XATOM_TIMESTAMP(d) (DEVICE_X_DATA (d)->Xatom_TIMESTAMP)
209 #define DEVICE_XATOM_TEXT(d) (DEVICE_X_DATA (d)->Xatom_TEXT)
210 #define DEVICE_XATOM_DELETE(d) (DEVICE_X_DATA (d)->Xatom_DELETE)
211 #define DEVICE_XATOM_MULTIPLE(d) (DEVICE_X_DATA (d)->Xatom_MULTIPLE)
212 #define DEVICE_XATOM_INCR(d) (DEVICE_X_DATA (d)->Xatom_INCR)
213 #define DEVICE_XATOM_EMACS_TMP(d) (DEVICE_X_DATA (d)->Xatom_EMACS_TMP)
214 #define DEVICE_XATOM_TARGETS(d) (DEVICE_X_DATA (d)->Xatom_TARGETS)
215 #define DEVICE_XATOM_NULL(d) (DEVICE_X_DATA (d)->Xatom_NULL)
216 #define DEVICE_XATOM_ATOM_PAIR(d) (DEVICE_X_DATA (d)->Xatom_ATOM_PAIR)
217 #define DEVICE_XATOM_COMPOUND_TEXT(d) (DEVICE_X_DATA (d)->Xatom_COMPOUND_TEXT)
219 /* allocated in Xatoms_of_objects_x */
220 #define DEVICE_XATOM_FOUNDRY(d) (DEVICE_X_DATA (d)->Xatom_FOUNDRY)
221 #define DEVICE_XATOM_FAMILY_NAME(d) (DEVICE_X_DATA (d)->Xatom_FAMILY_NAME)
222 #define DEVICE_XATOM_WEIGHT_NAME(d) (DEVICE_X_DATA (d)->Xatom_WEIGHT_NAME)
223 #define DEVICE_XATOM_SLANT(d) (DEVICE_X_DATA (d)->Xatom_SLANT)
224 #define DEVICE_XATOM_SETWIDTH_NAME(d) (DEVICE_X_DATA (d)->Xatom_SETWIDTH_NAME)
225 #define DEVICE_XATOM_ADD_STYLE_NAME(d) (DEVICE_X_DATA (d)->Xatom_ADD_STYLE_NAME)
226 #define DEVICE_XATOM_PIXEL_SIZE(d) (DEVICE_X_DATA (d)->Xatom_PIXEL_SIZE)
227 #define DEVICE_XATOM_POINT_SIZE(d) (DEVICE_X_DATA (d)->Xatom_POINT_SIZE)
228 #define DEVICE_XATOM_RESOLUTION_X(d) (DEVICE_X_DATA (d)->Xatom_RESOLUTION_X)
229 #define DEVICE_XATOM_RESOLUTION_Y(d) (DEVICE_X_DATA (d)->Xatom_RESOLUTION_Y)
230 #define DEVICE_XATOM_SPACING(d) (DEVICE_X_DATA (d)->Xatom_SPACING)
231 #define DEVICE_XATOM_AVERAGE_WIDTH(d) (DEVICE_X_DATA (d)->Xatom_AVERAGE_WIDTH)
232 #define DEVICE_XATOM_CHARSET_REGISTRY(d) (DEVICE_X_DATA (d)->Xatom_CHARSET_REGISTRY)
233 #define DEVICE_XATOM_CHARSET_ENCODING(d) (DEVICE_X_DATA (d)->Xatom_CHARSET_ENCODING)
235 #define Xt_SET_VALUE(widget, resource, value) do { \
237 XtSetArg (al, resource, value); \
238 XtSetValues (widget, &al, 1); \
241 #define Xt_GET_VALUE(widget, resource, location) do { \
243 XtSetArg (al, resource, location); \
244 XtGetValues (widget, &al, 1); \
247 /* The maximum number of widgets that can be displayed above the text
248 area at one time. Currently no more than 3 will ever actually be
249 displayed (menubar, psheet, debugger panel). */
250 #define MAX_CONCURRENT_TOP_WIDGETS 8
253 /* The widget of this frame. This is an EmacsShell or an
257 /* The parent of the EmacsFrame, the menubar, and the scrollbars.
258 This is an EmacsManager. */
261 /* The widget of the menubar, of whatever widget class it happens to be. */
262 Widget menubar_widget;
264 /* The widget of the edit portion of this frame; this is an EmacsFrame,
265 and the window of this widget is what the redisplay code draws on. */
268 /* Lists the widgets above the text area, in the proper order.
269 Used by the EmacsManager. */
270 Widget top_widgets[MAX_CONCURRENT_TOP_WIDGETS];
273 /*************************** Miscellaneous **************************/
275 /* The icon pixmaps; these are Lisp_Image_Instance objects, or Qnil. */
276 Lisp_Object icon_pixmap;
277 Lisp_Object icon_pixmap_mask;
280 int old_toolbar_size[4];
282 /* We don't provide a mechanism for changing these after they are
283 initialized so we might as well keep pointers to them and avoid
284 lots of expensive calls to gc_cache_lookup. */
285 GC toolbar_top_shadow_gc;
286 GC toolbar_bottom_shadow_gc;
287 GC toolbar_blank_background_gc;
288 GC toolbar_pixmap_background_gc;
289 #endif /* HAVE_TOOLBARS */
291 /* geometry string that ought to be freed. */
292 char *geom_free_me_please;
295 XPoint xic_spot; /* Spot Location cache */
298 /* Could get these at any time by asking xic, but... */
299 XIMStyle xic_style; /* XIM Style cache */
300 #endif /* XIM_XLIB */
301 #endif /* HAVE_XIM */
303 /* 1 if the frame is completely visible on the display, 0 otherwise.
304 if 0 the frame may have been iconified or may be totally
305 or partially hidden by another X window */
306 unsigned int totally_visible_p:1;
308 /* NB: Both of the following flags are derivable from the 'shell'
309 field above, but it's easier if we also have them separately here. */
311 /* Are we a top-level frame? This means that our shell is a
312 TopLevelShell, and we should do certain things to interact with
313 the window manager. */
314 unsigned int top_level_frame_p:1;
316 #ifdef EXTERNAL_WIDGET
317 /* Are we using somebody else's window for our shell window? This
318 means that our shell is an ExternalShell. If this flag is set, then
319 `top_level_frame_p' will never be set. */
320 unsigned int external_window_p:1;
321 #endif /* EXTERNAL_WIDGET */
324 #define FRAME_X_DATA(f) FRAME_TYPE_DATA (f, x)
326 #define FRAME_X_SHELL_WIDGET(f) (FRAME_X_DATA (f)->widget)
327 #define FRAME_X_CONTAINER_WIDGET(f) (FRAME_X_DATA (f)->container)
328 #define FRAME_X_MENUBAR_WIDGET(f) (FRAME_X_DATA (f)->menubar_widget)
329 #define FRAME_X_TEXT_WIDGET(f) (FRAME_X_DATA (f)->edit_widget)
330 #define FRAME_X_TOP_WIDGETS(f) (FRAME_X_DATA (f)->top_widgets)
331 #define FRAME_X_NUM_TOP_WIDGETS(f) (FRAME_X_DATA (f)->num_top_widgets)
333 #define FRAME_X_ICON_PIXMAP(f) (FRAME_X_DATA (f)->icon_pixmap)
334 #define FRAME_X_ICON_PIXMAP_MASK(f) (FRAME_X_DATA (f)->icon_pixmap_mask)
337 #define FRAME_X_OLD_TOOLBAR_SIZE(f, pos) (FRAME_X_DATA (f)->old_toolbar_size[pos])
339 #define FRAME_X_TOOLBAR_TOP_SHADOW_GC(f) (FRAME_X_DATA (f)->toolbar_top_shadow_gc)
340 #define FRAME_X_TOOLBAR_BOTTOM_SHADOW_GC(f) (FRAME_X_DATA (f)->toolbar_bottom_shadow_gc)
341 #define FRAME_X_TOOLBAR_BLANK_BACKGROUND_GC(f) (FRAME_X_DATA (f)->toolbar_blank_background_gc)
342 #define FRAME_X_TOOLBAR_PIXMAP_BACKGROUND_GC(f) (FRAME_X_DATA (f)->toolbar_pixmap_background_gc)
343 #endif /* HAVE_TOOLBARS */
345 #define FRAME_X_GEOM_FREE_ME_PLEASE(f) (FRAME_X_DATA (f)->geom_free_me_please)
347 #define FRAME_X_TOTALLY_VISIBLE_P(f) (FRAME_X_DATA (f)->totally_visible_p)
348 #define FRAME_X_TOP_LEVEL_FRAME_P(f) (FRAME_X_DATA (f)->top_level_frame_p)
350 #ifdef EXTERNAL_WIDGET
351 #define FRAME_X_EXTERNAL_WINDOW_P(f) (FRAME_X_DATA (f)->external_window_p)
355 #define FRAME_X_XIC_SPOT(f) (FRAME_X_DATA (f)->xic_spot)
357 #define FRAME_X_XIC(f) (FRAME_X_DATA (f)->xic)
358 #define FRAME_X_XIC_STYLE(f) (FRAME_X_DATA (f)->xic_style)
359 #endif /* XIM_XLIB */
360 #endif /* HAVE_XIM */
362 /* Variables associated with the X display frame this emacs is using. */
363 extern XtAppContext Xt_app_con;
365 extern Lisp_Object Vx_gc_pointer_shape;
366 extern Lisp_Object Vx_scrollbar_pointer_shape;
367 extern Lisp_Object Qx_error;
369 extern struct console_type *x_console_type;
370 extern Lisp_Object Vdefault_x_device;
372 /* Number of pixels below each line. */
373 extern int x_interline_space; /* #### implement me */
375 extern Fixnum x_selection_timeout;
377 struct frame *x_any_window_to_frame(struct device *d, Window);
378 struct frame *x_any_widget_or_parent_to_frame(struct device *d, Widget widget);
379 struct frame *decode_x_frame(Lisp_Object);
380 struct frame *x_window_to_frame(struct device *d, Window);
381 struct device *get_device_from_display(Display * dpy);
382 struct device *decode_x_device(Lisp_Object);
384 void x_handle_selection_notify(XSelectionEvent * event);
385 void x_handle_selection_request(XSelectionRequestEvent * event);
386 void x_handle_selection_clear(XSelectionClearEvent * event);
387 void x_handle_property_notify(XPropertyEvent * event);
389 void Xatoms_of_select_x(struct device *d);
390 void Xatoms_of_objects_x(struct device *d);
392 void x_wm_set_shell_iconic_p(Widget shell, int iconic_p);
393 void x_wm_set_cell_size(Widget wmshell, int cw, int ch);
394 void x_wm_set_variable_size(Widget wmshell, int width, int height);
396 const char *x_event_name(int event_type);
397 int x_error_handler(Display * disp, XErrorEvent * event);
398 void expect_x_error(Display * dpy);
399 int x_error_occurred_p(Display * dpy);
400 int signal_if_x_error(Display * dpy, int resumable_p);
401 int x_IO_error_handler(Display * disp);
403 void x_redraw_exposed_area(struct frame *f, int x, int y,
404 int width, int height);
405 void x_output_string(struct window *w, struct display_line *dl,
406 Emchar_dynarr * buf, int xpos, int xoffset,
407 int start_pixpos, int width, face_index findex,
408 int cursor, int cursor_start, int cursor_width,
410 void x_output_x_pixmap(struct frame *f, Lisp_Image_Instance * p,
411 int x, int y, int xoffset, int yoffset,
412 int width, int height,
413 unsigned long fg, unsigned long bg, GC override_gc);
414 void x_output_shadows(struct frame *f, int x, int y, int width,
415 int height, GC top_shadow_gc,
416 GC bottom_shadow_gc, GC background_gc,
417 int shadow_thickness, int edges);
418 void x_generate_shadow_pixels(struct frame *f,
419 unsigned long *top_shadow,
420 unsigned long *bottom_shadow,
421 unsigned long background,
422 unsigned long core_background);
424 int x_initialize_frame_menubar(struct frame *f);
425 void x_init_modifier_mapping(struct device *d);
427 #define X_ERROR_OCCURRED(dpy, body) \
428 (expect_x_error (dpy), body, x_error_occurred_p (dpy))
430 #define HANDLING_X_ERROR(dpy, body) \
431 (expect_x_error (dpy), body, signal_if_x_error (dpy, 0))
433 void Initialize_Locale(void);
437 /* X Input Method `methods' */
438 void XIM_init_device(struct device *d);
439 void XIM_init_frame(struct frame *f);
440 void XIM_SetSpotLocation(struct frame *f, int x, int y);
441 void XIM_SetGeometry(struct frame *f);
442 void XIM_focus_event(struct frame *f, int in_p);
445 /* XtTypeConverter */
446 Boolean EmacsXtCvtStringToXIMStyles(Display * dpy,
450 XrmValuePtr to_in_out,
451 XtPointer * converter_data);
454 void EmacsFreeXIMStyles(XtAppContext app,
456 XtPointer converter_data,
457 XrmValuePtr args, Cardinal * num_args);
460 void describe_Window(Window win);
461 void describe_XFontSet(XFontSet font_set);
462 void describe_XIM(XIM im);
463 void describe_XIMStyle(XIMStyle style);
464 void describe_XIMStyles(XIMStyles * styles);
465 void describe_XIC(XIC ic);
466 void describe_event_mask(unsigned long mask);
467 void describe_XRectangle(char *name, XRectangle * rect);
468 void describe_Status(Status status);
469 #endif /* DEBUG_SXEMACS */
470 #endif /* XIM_XLIB */
471 #endif /* HAVE_XIM */
473 extern int in_resource_setting;
474 extern int in_specifier_change_function;
476 extern Lisp_Object Vx_initial_argv_list; /* #### ugh! */
478 /* Standins for various X encodings, until we know them better */
480 /* !!#### Need to verify the encoding used in lwlib -- Qnative or Qctext?
481 Almost certainly the former. Use a standin for now. */
482 #define Qlwlib_encoding Qnative
484 #define Qx_atom_name_encoding Qctext
485 /* font names are often stored in atoms, so it gets sticky if we set this
486 to something different from atom-name encoding */
487 #define Qx_font_name_encoding Qctext
489 #define Qx_color_name_encoding Qctext
491 /* the following probably must agree with Qcommand_argument_encoding and
492 Qenvironment_variable_encoding */
493 #define Qx_display_name_encoding Qnative
495 #endif /* HAVE_X_WINDOWS */
497 #endif /* INCLUDED_console_x_h_ */