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