Don't call the same hook twice due to obsolete aliases
[emacs.git] / src / xterm.h
blob803feda99f34889119256b0d79f25d0f188e1ecc
1 /* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989, 1993-1994, 1998-2017 Free Software Foundation,
3 Inc.
5 This file is part of GNU Emacs.
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.
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.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef XTERM_H
21 #define XTERM_H
23 #include <X11/Xlib.h>
24 #include <X11/cursorfont.h>
26 /* Include Xutil.h after keysym.h to work around a bug that prevents
27 correct recognition of AltGr key in some X versions. */
29 #include <X11/keysym.h>
30 #include <X11/Xutil.h>
32 #include <X11/Xatom.h>
33 #include <X11/Xresource.h>
35 #ifdef USE_X_TOOLKIT
36 #include <X11/StringDefs.h>
37 #include <X11/IntrinsicP.h> /* CoreP.h needs this */
38 #include <X11/CoreP.h> /* foul, but we need this to use our own
39 window inside a widget instead of one
40 that Xt creates... */
41 #ifdef X_TOOLKIT_EDITRES
42 #include <X11/Xmu/Editres.h>
43 #endif
45 typedef Widget xt_or_gtk_widget;
46 #endif
48 #ifdef USE_GTK
49 #include <gtk/gtk.h>
50 #include <gdk/gdkx.h>
52 /* Some definitions to reduce conditionals. */
53 typedef GtkWidget *xt_or_gtk_widget;
54 #undef XSync
55 #define XSync(d, b) do { gdk_window_process_all_updates (); \
56 XSync (d, b); } while (false)
57 #endif /* USE_GTK */
59 /* True iff GTK's version is at least I.J.K. */
60 #ifndef GTK_CHECK_VERSION
61 # ifdef USE_GTK
62 # define GTK_CHECK_VERSION(i, j, k) \
63 ((i) \
64 < GTK_MAJOR_VERSION + ((j) \
65 < GTK_MINOR_VERSION + ((k) \
66 <= GTK_MICRO_VERSION)))
67 # else
68 # define GTK_CHECK_VERSION(i, j, k) false
69 # endif
70 #endif
72 /* The GtkTooltip API came in 2.12, but gtk-enable-tooltips in 2.14. */
73 #if GTK_CHECK_VERSION (2, 14, 0)
74 #define USE_GTK_TOOLTIP
75 #endif
77 #ifdef USE_CAIRO
78 #include <cairo-xlib.h>
79 #ifdef CAIRO_HAS_PDF_SURFACE
80 #include <cairo-pdf.h>
81 #endif
82 #ifdef CAIRO_HAS_PS_SURFACE
83 #include <cairo-ps.h>
84 #endif
85 #ifdef CAIRO_HAS_SVG_SURFACE
86 #include <cairo-svg.h>
87 #endif
88 #endif
90 #ifdef HAVE_X_I18N
91 #include <X11/Xlocale.h>
92 #endif
94 #ifdef USE_XCB
95 #include <X11/Xlib-xcb.h>
96 #endif
98 #include "dispextern.h"
99 #include "termhooks.h"
101 INLINE_HEADER_BEGIN
103 /* Black and white pixel values for the screen which frame F is on. */
104 #define BLACK_PIX_DEFAULT(f) \
105 BlackPixel (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))
106 #define WHITE_PIX_DEFAULT(f) \
107 WhitePixel (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))
109 /* The mask of events that text windows always want to receive. This
110 includes mouse movement events, since handling the mouse-font text property
111 means that we must track mouse motion all the time. */
113 #define STANDARD_EVENT_SET \
114 (KeyPressMask \
115 | ExposureMask \
116 | ButtonPressMask \
117 | ButtonReleaseMask \
118 | PointerMotionMask \
119 | StructureNotifyMask \
120 | FocusChangeMask \
121 | LeaveWindowMask \
122 | EnterWindowMask \
123 | VisibilityChangeMask)
125 #ifdef HAVE_X11R6_XIM
126 /* Data structure passed to xim_instantiate_callback. */
127 struct xim_inst_t
129 struct x_display_info *dpyinfo;
130 char *resource_name;
132 #endif /* HAVE_X11R6_XIM */
134 /* Structure recording X pixmap and reference count.
135 If REFCOUNT is 0 then this record is free to be reused. */
137 struct x_bitmap_record
139 #ifdef USE_CAIRO
140 void *img;
141 #endif
142 Pixmap pixmap;
143 bool have_mask;
144 Pixmap mask;
145 char *file;
146 int refcount;
147 /* Record some info about this pixmap. */
148 int height, width, depth;
151 #ifdef USE_CAIRO
152 struct x_gc_ext_data
154 #define MAX_CLIP_RECTS 2
155 /* Number of clipping rectangles. */
156 int n_clip_rects;
158 /* Clipping rectangles. */
159 XRectangle clip_rects[MAX_CLIP_RECTS];
161 #endif
164 struct color_name_cache_entry
166 struct color_name_cache_entry *next;
167 XColor rgb;
168 char *name;
171 Status x_parse_color (struct frame *f, const char *color_name,
172 XColor *color);
175 /* For each X display, we have a structure that records
176 information about it. */
178 struct x_display_info
180 /* Chain of all x_display_info structures. */
181 struct x_display_info *next;
183 /* The generic display parameters corresponding to this X display. */
184 struct terminal *terminal;
186 /* This says how to access this display in Xlib. */
187 Display *display;
189 /* A connection number (file descriptor) for the display. */
190 int connection;
192 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE). */
193 Lisp_Object name_list_element;
195 /* Number of frames that are on this display. */
196 int reference_count;
198 /* The Screen this connection is connected to. */
199 Screen *screen;
201 /* Dots per inch of the screen. */
202 double resx, resy;
204 /* The Visual being used for this display. */
205 Visual *visual;
207 /* The colormap being used. */
208 Colormap cmap;
210 /* Number of planes on this screen. */
211 int n_planes;
213 /* Mask of things that cause the mouse to be grabbed. */
214 int grabbed;
216 /* Emacs bitmap-id of the default icon bitmap for this frame.
217 Or -1 if none has been allocated yet. */
218 ptrdiff_t icon_bitmap_id;
220 /* The root window of this screen. */
221 Window root_window;
223 /* Client leader window. */
224 Window client_leader_window;
226 /* The cursor to use for vertical scroll bars. */
227 Cursor vertical_scroll_bar_cursor;
229 /* The cursor to use for horizontal scroll bars. */
230 Cursor horizontal_scroll_bar_cursor;
232 /* The invisible cursor used for pointer blanking.
233 Unused if this display supports Xfixes extension. */
234 Cursor invisible_cursor;
236 /* Function used to toggle pointer visibility on this display. */
237 void (*toggle_visible_pointer) (struct frame *, bool);
239 #ifdef USE_GTK
240 /* The GDK cursor for scroll bars and popup menus. */
241 GdkCursor *xg_cursor;
242 #endif
244 /* X Resource data base */
245 XrmDatabase xrdb;
247 /* Minimum width over all characters in all fonts in font_table. */
248 int smallest_char_width;
250 /* Minimum font height over all fonts in font_table. */
251 int smallest_font_height;
253 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
254 GC scratch_cursor_gc;
256 /* Information about the range of text currently shown in
257 mouse-face. */
258 Mouse_HLInfo mouse_highlight;
260 /* Logical identifier of this display. */
261 unsigned x_id;
263 /* Default name for all frames on this display. */
264 char *x_id_name;
266 /* The number of fonts opened for this display. */
267 int n_fonts;
269 /* Pointer to bitmap records. */
270 struct x_bitmap_record *bitmaps;
272 /* Allocated size of bitmaps field. */
273 ptrdiff_t bitmaps_size;
275 /* Last used bitmap index. */
276 ptrdiff_t bitmaps_last;
278 /* Which modifier keys are on which modifier bits?
280 With each keystroke, X returns eight bits indicating which modifier
281 keys were held down when the key was pressed. The interpretation
282 of the top five modifier bits depends on what keys are attached
283 to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5
284 is the meta bit.
286 meta_mod_mask is a mask containing the bits used for the meta key.
287 It may have more than one bit set, if more than one modifier bit
288 has meta keys on it. Basically, if EVENT is a KeyPress event,
289 the meta key is pressed if (EVENT.state & meta_mod_mask) != 0.
291 shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the
292 lock modifier bit, or zero otherwise. Non-alphabetic keys should
293 only be affected by the lock modifier bit if XK_Shift_Lock is in
294 use; XK_Caps_Lock should only affect alphabetic keys. With this
295 arrangement, the lock modifier should shift the character if
296 (EVENT.state & shift_lock_mask) != 0. */
297 int meta_mod_mask, shift_lock_mask;
299 /* These are like meta_mod_mask, but for different modifiers. */
300 int alt_mod_mask, super_mod_mask, hyper_mod_mask;
302 /* Communication with window managers. */
303 Atom Xatom_wm_protocols;
305 /* Kinds of protocol things we may receive. */
306 Atom Xatom_wm_take_focus;
307 Atom Xatom_wm_save_yourself;
308 Atom Xatom_wm_delete_window;
310 /* Atom for indicating window state to the window manager. */
311 Atom Xatom_wm_change_state;
313 /* Other WM communication */
314 Atom Xatom_wm_configure_denied; /* When our config request is denied */
315 Atom Xatom_wm_window_moved; /* When the WM moves us. */
316 Atom Xatom_wm_client_leader; /* Id of client leader window. */
318 /* EditRes protocol */
319 Atom Xatom_editres;
321 /* More atoms, which are selection types. */
322 Atom Xatom_CLIPBOARD, Xatom_TIMESTAMP, Xatom_TEXT, Xatom_DELETE,
323 Xatom_COMPOUND_TEXT, Xatom_UTF8_STRING,
324 Xatom_MULTIPLE, Xatom_INCR, Xatom_EMACS_TMP, Xatom_TARGETS, Xatom_NULL,
325 Xatom_ATOM, Xatom_ATOM_PAIR, Xatom_CLIPBOARD_MANAGER;
327 /* More atoms for font properties. The last three are private
328 properties, see the comments in src/fontset.h. */
329 Atom Xatom_PIXEL_SIZE, Xatom_AVERAGE_WIDTH,
330 Xatom_MULE_BASELINE_OFFSET, Xatom_MULE_RELATIVE_COMPOSE,
331 Xatom_MULE_DEFAULT_ASCENT;
333 /* More atoms for Ghostscript support. */
334 Atom Xatom_DONE, Xatom_PAGE;
336 /* Atoms used in toolkit scroll bar client messages. */
337 Atom Xatom_Scrollbar, Xatom_Horizontal_Scrollbar;
339 /* Atom used in XEmbed client messages. */
340 Atom Xatom_XEMBED, Xatom_XEMBED_INFO;
342 /* The frame (if any) which has the X window that has keyboard focus.
343 Zero if none. This is examined by Ffocus_frame in xfns.c. Note
344 that a mere EnterNotify event can set this; if you need to know the
345 last frame specified in a FocusIn or FocusOut event, use
346 x_focus_event_frame. */
347 struct frame *x_focus_frame;
349 /* The last frame mentioned in a FocusIn or FocusOut event. This is
350 separate from x_focus_frame, because whether or not LeaveNotify
351 events cause us to lose focus depends on whether or not we have
352 received a FocusIn event for it. */
353 struct frame *x_focus_event_frame;
355 /* The frame which currently has the visual highlight, and should get
356 keyboard input (other sorts of input have the frame encoded in the
357 event). It points to the X focus frame's selected window's
358 frame. It differs from x_focus_frame when we're using a global
359 minibuffer. */
360 struct frame *x_highlight_frame;
362 /* The frame waiting to be auto-raised in XTread_socket. */
363 struct frame *x_pending_autoraise_frame;
365 /* The frame where the mouse was last time we reported a ButtonPress event. */
366 struct frame *last_mouse_frame;
368 /* The frame where the mouse was last time we reported a mouse position. */
369 struct frame *last_mouse_glyph_frame;
371 /* The frame where the mouse was last time we reported a mouse motion. */
372 struct frame *last_mouse_motion_frame;
374 /* The scroll bar in which the last X motion event occurred. */
375 struct scroll_bar *last_mouse_scroll_bar;
377 /* Time of last user interaction as returned in X events on this display. */
378 Time last_user_time;
380 /* Position where the mouse was last time we reported a motion.
381 This is a position on last_mouse_motion_frame. */
382 int last_mouse_motion_x;
383 int last_mouse_motion_y;
385 /* Where the mouse was last time we reported a mouse position.
386 This is a rectangle on last_mouse_glyph_frame. */
387 XRectangle last_mouse_glyph;
389 /* Time of last mouse movement on this display. This is a hack because
390 we would really prefer that XTmouse_position would return the time
391 associated with the position it returns, but there doesn't seem to be
392 any way to wrest the time-stamp from the server along with the position
393 query. So, we just keep track of the time of the last movement we
394 received, and return that in hopes that it's somewhat accurate. */
395 Time last_mouse_movement_time;
397 /* The gray pixmap. */
398 Pixmap gray;
400 #ifdef HAVE_X_I18N
401 /* XIM (X Input method). */
402 XIM xim;
403 XIMStyles *xim_styles;
404 struct xim_inst_t *xim_callback_data;
405 #endif
407 /* A cache mapping color names to RGB values. */
408 struct color_name_cache_entry *color_names;
410 /* If non-null, a cache of the colors in the color map. Don't
411 use this directly, call x_color_cells instead. */
412 XColor *color_cells;
413 int ncolor_cells;
415 /* Bits and shifts to use to compose pixel values on TrueColor visuals. */
416 int red_bits, blue_bits, green_bits;
417 int red_offset, blue_offset, green_offset;
419 /* The type of window manager we have. If we move FRAME_OUTER_WINDOW
420 to x/y 0/0, some window managers (type A) puts the window manager
421 decorations outside the screen and FRAME_OUTER_WINDOW exactly at 0/0.
422 Other window managers (type B) puts the window including decorations
423 at 0/0, so FRAME_OUTER_WINDOW is a bit below 0/0.
424 Record the type of WM in use so we can compensate for type A WMs. */
425 enum
427 X_WMTYPE_UNKNOWN,
428 X_WMTYPE_A,
429 X_WMTYPE_B
430 } wm_type;
433 /* Atoms that are drag and drop atoms */
434 Atom *x_dnd_atoms;
435 ptrdiff_t x_dnd_atoms_size;
436 ptrdiff_t x_dnd_atoms_length;
438 /* Extended window manager hints, Atoms supported by the window manager and
439 atoms for setting the window type. */
440 Atom Xatom_net_supported, Xatom_net_supporting_wm_check;
441 Atom *net_supported_atoms;
442 int nr_net_supported_atoms;
443 Window net_supported_window;
444 Atom Xatom_net_window_type, Xatom_net_window_type_tooltip;
445 Atom Xatom_net_active_window;
447 /* Atoms dealing with EWMH (i.e. _NET_...) */
448 Atom Xatom_net_wm_state, Xatom_net_wm_state_fullscreen,
449 Xatom_net_wm_state_maximized_horz, Xatom_net_wm_state_maximized_vert,
450 Xatom_net_wm_state_sticky, Xatom_net_wm_state_above, Xatom_net_wm_state_below,
451 Xatom_net_wm_state_hidden, Xatom_net_wm_state_skip_taskbar,
452 Xatom_net_frame_extents, Xatom_net_current_desktop, Xatom_net_workarea;
454 /* XSettings atoms and windows. */
455 Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr;
456 Window xsettings_window;
458 /* Frame name and icon name */
459 Atom Xatom_net_wm_name, Xatom_net_wm_icon_name;
460 /* Frame opacity */
461 Atom Xatom_net_wm_window_opacity;
463 /* SM */
464 Atom Xatom_SM_CLIENT_ID;
466 #ifdef HAVE_XRANDR
467 int xrandr_major_version;
468 int xrandr_minor_version;
469 #endif
471 #ifdef USE_CAIRO
472 XExtCodes *ext_codes;
473 #endif
475 #ifdef USE_XCB
476 xcb_connection_t *xcb_connection;
477 #endif
479 #ifdef HAVE_XDBE
480 bool supports_xdbe;
481 #endif
484 #ifdef HAVE_X_I18N
485 /* Whether or not to use XIM if we have it. */
486 extern bool use_xim;
487 #endif
489 /* This is a chain of structures for all the X displays currently in use. */
490 extern struct x_display_info *x_display_list;
492 extern struct x_display_info *x_display_info_for_display (Display *);
493 extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
494 extern struct x_display_info *x_term_init (Lisp_Object, char *, char *);
495 extern bool x_display_ok (const char *);
497 extern void select_visual (struct x_display_info *);
499 /* Each X frame object points to its own struct x_output object
500 in the output_data.x field. The x_output structure contains
501 the information that is specific to X windows. */
503 struct x_output
505 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
506 /* Height of menu bar widget, in pixels. This value
507 is not meaningful if the menubar is turned off. */
508 int menubar_height;
509 #endif
511 /* Height of tool bar widget, in pixels. top_height is used if tool bar
512 at top, bottom_height if tool bar is at the bottom.
513 Zero if not using an external tool bar or if tool bar is vertical. */
514 int toolbar_top_height, toolbar_bottom_height;
516 /* Width of tool bar widget, in pixels. left_width is used if tool bar
517 at left, right_width if tool bar is at the right.
518 Zero if not using an external tool bar or if tool bar is horizontal. */
519 int toolbar_left_width, toolbar_right_width;
521 /* The tiled border used when the mouse is out of the frame. */
522 Pixmap border_tile;
524 /* Here are the Graphics Contexts for the default font. */
525 GC normal_gc; /* Normal video */
526 GC reverse_gc; /* Reverse video */
527 GC cursor_gc; /* cursor drawing */
529 /* The X window used for this frame.
530 May be zero while the frame object is being created
531 and the X window has not yet been created. */
532 Window window_desc;
534 /* The drawable to which we're rendering. In the single-buffered
535 base, the window itself. In the double-buffered case, the
536 window's back buffer. */
537 Drawable draw_desc;
539 /* Flag that indicates whether we've modified the back buffer and
540 need to publish our modifications to the front buffer at a
541 convenient time. */
542 bool need_buffer_flip;
544 /* The X window used for the bitmap icon;
545 or 0 if we don't have a bitmap icon. */
546 Window icon_desc;
548 /* The X window that is the parent of this X window.
549 Usually this is a window that was made by the window manager,
550 but it can be the root window, and it can be explicitly specified
551 (see the explicit_parent field, below). */
552 Window parent_desc;
554 #ifdef USE_X_TOOLKIT
555 /* The widget of this screen. This is the window of a "shell" widget. */
556 Widget widget;
557 /* The XmPanedWindows... */
558 Widget column_widget;
559 /* The widget of the edit portion of this screen; the window in
560 "window_desc" is inside of this. */
561 Widget edit_widget;
563 Widget menubar_widget;
564 #endif
566 #ifdef USE_GTK
567 /* The widget of this screen. This is the window of a top widget. */
568 GtkWidget *widget;
569 /* The widget of the edit portion of this screen; the window in
570 "window_desc" is inside of this. */
571 GtkWidget *edit_widget;
572 /* The widget used for laying out widgets vertically. */
573 GtkWidget *vbox_widget;
574 /* The widget used for laying out widgets horizontally. */
575 GtkWidget *hbox_widget;
576 /* The menubar in this frame. */
577 GtkWidget *menubar_widget;
578 /* The tool bar in this frame */
579 GtkWidget *toolbar_widget;
580 /* True if tool bar is packed into the hbox widget (i.e. vertical). */
581 bool_bf toolbar_in_hbox : 1;
582 bool_bf toolbar_is_packed : 1;
584 /* The last size hints set. */
585 GdkGeometry size_hints;
586 long hint_flags;
588 #ifdef USE_GTK_TOOLTIP
589 GtkTooltip *ttip_widget;
590 GtkWidget *ttip_lbl;
591 GtkWindow *ttip_window;
592 #endif /* USE_GTK_TOOLTIP */
594 #endif /* USE_GTK */
596 /* If >=0, a bitmap index. The indicated bitmap is used for the
597 icon. */
598 ptrdiff_t icon_bitmap;
600 /* Default ASCII font of this frame. */
601 struct font *font;
603 /* The baseline offset of the default ASCII font. */
604 int baseline_offset;
606 /* If a fontset is specified for this frame instead of font, this
607 value contains an ID of the fontset, else -1. */
608 int fontset;
610 unsigned long cursor_pixel;
611 unsigned long border_pixel;
612 unsigned long mouse_pixel;
613 unsigned long cursor_foreground_pixel;
615 /* Foreground color for scroll bars. A value of -1 means use the
616 default (black for non-toolkit scroll bars). */
617 unsigned long scroll_bar_foreground_pixel;
619 /* Background color for scroll bars. A value of -1 means use the
620 default (background color of the frame for non-toolkit scroll
621 bars). */
622 unsigned long scroll_bar_background_pixel;
624 #if defined (USE_LUCID) && defined (USE_TOOLKIT_SCROLL_BARS)
625 /* Top and bottom shadow colors for 3D Lucid scrollbars.
626 -1 means let the scroll compute them itself. */
627 unsigned long scroll_bar_top_shadow_pixel;
628 unsigned long scroll_bar_bottom_shadow_pixel;
629 #endif
631 /* Descriptor for the cursor in use for this window. */
632 Cursor text_cursor;
633 Cursor nontext_cursor;
634 Cursor modeline_cursor;
635 Cursor hand_cursor;
636 Cursor hourglass_cursor;
637 Cursor horizontal_drag_cursor;
638 Cursor vertical_drag_cursor;
639 Cursor current_cursor;
640 Cursor left_edge_cursor;
641 Cursor top_left_corner_cursor;
642 Cursor top_edge_cursor;
643 Cursor top_right_corner_cursor;
644 Cursor right_edge_cursor;
645 Cursor bottom_right_corner_cursor;
646 Cursor bottom_edge_cursor;
647 Cursor bottom_left_corner_cursor;
649 /* Window whose cursor is hourglass_cursor. This window is temporarily
650 mapped to display an hourglass cursor. */
651 Window hourglass_window;
653 /* These are the current window manager hints. It seems that
654 XSetWMHints, when presented with an unset bit in the `flags'
655 member of the hints structure, does not leave the corresponding
656 attribute unchanged; rather, it resets that attribute to its
657 default value. For example, unless you set the `icon_pixmap'
658 field and the `IconPixmapHint' bit, XSetWMHints will forget what
659 your icon pixmap was. This is rather troublesome, since some of
660 the members (for example, `input' and `icon_pixmap') want to stay
661 the same throughout the execution of Emacs. So, we keep this
662 structure around, just leaving values in it and adding new bits
663 to the mask as we go. */
664 XWMHints wm_hints;
666 /* This is the Emacs structure for the X display this frame is on. */
667 struct x_display_info *display_info;
669 /* This is a button event that wants to activate the menubar.
670 We save it here until the command loop gets to think about it. */
671 XEvent *saved_menu_event;
673 /* This is the widget id used for this frame's menubar in lwlib. */
674 #ifdef USE_X_TOOLKIT
675 int id;
676 #endif
678 /* True means hourglass cursor is currently displayed. */
679 bool_bf hourglass_p : 1;
681 /* True means our parent is another application's window
682 and was explicitly specified. */
683 bool_bf explicit_parent : 1;
685 /* True means tried already to make this frame visible. */
686 bool_bf asked_for_visible : 1;
688 /* True if this frame was ever previously visible. */
689 bool_bf has_been_visible : 1;
691 /* Xt waits for a ConfigureNotify event from the window manager in
692 EmacsFrameSetCharSize when the shell widget is resized. For some
693 window managers like fvwm2 2.2.5 and KDE 2.1 this event doesn't
694 arrive for an unknown reason and Emacs hangs in Xt. If this is
695 false, tell Xt not to wait. */
696 bool_bf wait_for_wm : 1;
698 #ifdef HAVE_X_I18N
699 /* Input context (currently, this means Compose key handler setup). */
700 XIC xic;
701 XIMStyle xic_style;
702 XFontSet xic_xfs;
703 #endif
705 /* Relief GCs, colors etc. */
706 struct relief
708 GC gc;
709 unsigned long pixel;
711 black_relief, white_relief;
713 /* The background for which the above relief GCs were set up.
714 They are changed only when a different background is involved. */
715 unsigned long relief_background;
717 /* Keep track of focus. May be EXPLICIT if we received a FocusIn for this
718 frame, or IMPLICIT if we received an EnterNotify.
719 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
720 int focus_state;
722 /* The offset we need to add to compensate for type A WMs. */
723 int move_offset_top;
724 int move_offset_left;
726 /* Extreme 'short' and 'long' values suitable for libX11. */
727 #define X_SHRT_MAX 0x7fff
728 #define X_SHRT_MIN (-1 - X_SHRT_MAX)
729 #define X_LONG_MAX 0x7fffffff
730 #define X_LONG_MIN (-1 - X_LONG_MAX)
731 #define X_ULONG_MAX 0xffffffffUL
733 #ifdef USE_CAIRO
734 /* Cairo drawing context. */
735 cairo_t *cr_context;
736 /* Cairo surface for double buffering */
737 cairo_surface_t *cr_surface;
738 #endif
741 #define No_Cursor (None)
743 enum
745 /* Values for focus_state, used as bit mask.
746 EXPLICIT means we received a FocusIn for the frame and know it has
747 the focus. IMPLICIT means we received an EnterNotify and the frame
748 may have the focus if no window manager is running.
749 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
750 FOCUS_NONE = 0,
751 FOCUS_IMPLICIT = 1,
752 FOCUS_EXPLICIT = 2
756 /* Return the X output data for frame F. */
757 #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
759 /* Return the X window used for displaying data in frame F. */
760 #define FRAME_X_WINDOW(f) ((f)->output_data.x->window_desc)
762 /* Return the drawable used for rendering to frame F. */
763 #define FRAME_X_RAW_DRAWABLE(f) ((f)->output_data.x->draw_desc)
765 extern void x_mark_frame_dirty (struct frame *f);
767 /* Return the drawable used for rendering to frame F and mark the
768 frame as needing a buffer flip later. There's no easy way to run
769 code after any drawing command, but we can run code whenever
770 someone asks for the handle necessary to draw. */
771 #define FRAME_X_DRAWABLE(f) \
772 (x_mark_frame_dirty((f)), FRAME_X_RAW_DRAWABLE ((f)))
774 #define FRAME_X_DOUBLE_BUFFERED_P(f) \
775 (FRAME_X_WINDOW (f) != FRAME_X_RAW_DRAWABLE (f))
777 /* Return the need-buffer-flip flag for frame F. */
778 #define FRAME_X_NEED_BUFFER_FLIP(f) ((f)->output_data.x->need_buffer_flip)
780 /* Return the outermost X window associated with the frame F. */
781 #ifdef USE_X_TOOLKIT
782 #define FRAME_OUTER_WINDOW(f) ((f)->output_data.x->widget ? \
783 XtWindow ((f)->output_data.x->widget) : \
784 FRAME_X_WINDOW (f))
785 #else
786 #ifdef USE_GTK
787 /* Functions not present in older Gtk+ */
789 #ifndef HAVE_GTK_WIDGET_GET_WINDOW
790 #define gtk_widget_get_window(w) ((w)->window)
791 #endif
792 #ifndef HAVE_GTK_WIDGET_GET_MAPPED
793 #define gtk_widget_get_mapped(w) (GTK_WIDGET_MAPPED (w))
794 #endif
795 #ifndef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE
796 #define gtk_adjustment_get_page_size(w) ((w)->page_size)
797 #define gtk_adjustment_get_upper(w) ((w)->upper)
798 #endif
800 #ifdef HAVE_GTK3
801 #define DEFAULT_GDK_DISPLAY() \
802 gdk_x11_display_get_xdisplay (gdk_display_get_default ())
803 #else
804 #undef GDK_WINDOW_XID
805 #define GDK_WINDOW_XID(w) GDK_WINDOW_XWINDOW (w)
806 #define DEFAULT_GDK_DISPLAY() GDK_DISPLAY ()
807 #define gtk_widget_get_preferred_size(a, ign, b) \
808 gtk_widget_size_request (a, b)
809 #endif
811 #define GTK_WIDGET_TO_X_WIN(w) \
812 ((w) && gtk_widget_get_window (w) \
813 ? GDK_WINDOW_XID (gtk_widget_get_window (w)) : 0)
815 #define FRAME_GTK_OUTER_WIDGET(f) ((f)->output_data.x->widget)
816 #define FRAME_GTK_WIDGET(f) ((f)->output_data.x->edit_widget)
817 #define FRAME_OUTER_WINDOW(f) \
818 (FRAME_GTK_OUTER_WIDGET (f) ? \
819 GTK_WIDGET_TO_X_WIN (FRAME_GTK_OUTER_WIDGET (f)) : \
820 FRAME_X_WINDOW (f))
822 #else /* !USE_GTK */
823 #define FRAME_OUTER_WINDOW(f) (FRAME_X_WINDOW (f))
824 #endif /* !USE_GTK */
825 #endif
827 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
828 #define FRAME_MENUBAR_HEIGHT(f) ((f)->output_data.x->menubar_height)
829 #else
830 #define FRAME_MENUBAR_HEIGHT(f) ((void) f, 0)
831 #endif /* USE_X_TOOLKIT || USE_GTK */
833 #define FRAME_FONT(f) ((f)->output_data.x->font)
834 #define FRAME_FONTSET(f) ((f)->output_data.x->fontset)
835 #define FRAME_TOOLBAR_TOP_HEIGHT(f) ((f)->output_data.x->toolbar_top_height)
836 #define FRAME_TOOLBAR_BOTTOM_HEIGHT(f) \
837 ((f)->output_data.x->toolbar_bottom_height)
838 #define FRAME_TOOLBAR_HEIGHT(f) \
839 (FRAME_TOOLBAR_TOP_HEIGHT (f) + FRAME_TOOLBAR_BOTTOM_HEIGHT (f))
840 #define FRAME_TOOLBAR_LEFT_WIDTH(f) ((f)->output_data.x->toolbar_left_width)
841 #define FRAME_TOOLBAR_RIGHT_WIDTH(f) ((f)->output_data.x->toolbar_right_width)
842 #define FRAME_TOOLBAR_WIDTH(f) \
843 (FRAME_TOOLBAR_LEFT_WIDTH (f) + FRAME_TOOLBAR_RIGHT_WIDTH (f))
844 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.x->baseline_offset)
846 /* This gives the x_display_info structure for the display F is on. */
847 #define FRAME_DISPLAY_INFO(f) ((f)->output_data.x->display_info)
849 /* This is the `Display *' which frame F is on. */
850 #define FRAME_X_DISPLAY(f) (FRAME_DISPLAY_INFO (f)->display)
852 /* This is the `Screen *' which frame F is on. */
853 #define FRAME_X_SCREEN(f) (FRAME_DISPLAY_INFO (f)->screen)
855 /* This is the screen index number of screen which frame F is on. */
856 #define FRAME_X_SCREEN_NUMBER(f) XScreenNumberOfScreen (FRAME_X_SCREEN (f))
858 /* This is the Visual which frame F is on. */
859 #define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO (f)->visual
861 /* This is the Colormap which frame F uses. */
862 #define FRAME_X_COLORMAP(f) FRAME_DISPLAY_INFO (f)->cmap
864 #define FRAME_XIC(f) ((f)->output_data.x->xic)
865 #define FRAME_X_XIM(f) (FRAME_DISPLAY_INFO (f)->xim)
866 #define FRAME_X_XIM_STYLES(f) (FRAME_DISPLAY_INFO (f)->xim_styles)
867 #define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style)
868 #define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs)
870 /* X-specific scroll bar stuff. */
872 /* We represent scroll bars as lisp vectors. This allows us to place
873 references to them in windows without worrying about whether we'll
874 end up with windows referring to dead scroll bars; the garbage
875 collector will free it when its time comes.
877 We use struct scroll_bar as a template for accessing fields of the
878 vector. */
880 struct scroll_bar
882 /* These fields are shared by all vectors. */
883 struct vectorlike_header header;
885 /* The window we're a scroll bar for. */
886 Lisp_Object window;
888 /* The next and previous in the chain of scroll bars in this frame. */
889 Lisp_Object next, prev;
891 /* Fields from `x_window' down will not be traced by the GC. */
893 /* The X window representing this scroll bar. */
894 Window x_window;
896 /* The position and size of the scroll bar in pixels, relative to the
897 frame. */
898 int top, left, width, height;
900 /* The starting and ending positions of the handle, relative to the
901 handle area (i.e. zero is the top position, not
902 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
903 hasn't been drawn yet.
905 These are not actually the locations where the beginning and end
906 are drawn; in order to keep handles from becoming invisible when
907 editing large files, we establish a minimum height by always
908 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
909 where they would be normally; the bottom and top are in a
910 different co-ordinate system. */
911 int start, end;
913 /* If the scroll bar handle is currently being dragged by the user,
914 this is the number of pixels from the top of the handle to the
915 place where the user grabbed it. If the handle isn't currently
916 being dragged, this is -1. */
917 int dragging;
919 #if defined (USE_TOOLKIT_SCROLL_BARS) && defined (USE_LUCID)
920 /* Last scroll bar part seen in xaw_jump_callback and xaw_scroll_callback. */
921 enum scroll_bar_part last_seen_part;
922 #endif
924 #if defined (USE_TOOLKIT_SCROLL_BARS) && !defined (USE_GTK)
925 /* Last value of whole for horizontal scrollbars. */
926 int whole;
927 #endif
929 /* True if the scroll bar is horizontal. */
930 bool horizontal;
933 /* Turning a lisp vector value into a pointer to a struct scroll_bar. */
934 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
936 #ifdef USE_X_TOOLKIT
938 /* Extract the X widget of the scroll bar from a struct scroll_bar.
939 XtWindowToWidget should be fast enough since Xt uses a hash table
940 to map windows to widgets. */
942 #define SCROLL_BAR_X_WIDGET(dpy, ptr) \
943 XtWindowToWidget (dpy, ptr->x_window)
945 /* Store a widget id in a struct scroll_bar. */
947 #define SET_SCROLL_BAR_X_WIDGET(ptr, w) \
948 do { \
949 Window window = XtWindow (w); \
950 ptr->x_window = window; \
951 } while (false)
953 #endif /* USE_X_TOOLKIT */
955 /* Return the inside width of a vertical scroll bar, given the outside
956 width. */
957 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
958 ((width) \
959 - VERTICAL_SCROLL_BAR_LEFT_BORDER \
960 - VERTICAL_SCROLL_BAR_RIGHT_BORDER)
962 /* Return the length of the rectangle within which the top of the
963 handle must stay. This isn't equivalent to the inside height,
964 because the scroll bar handle has a minimum height.
966 This is the real range of motion for the scroll bar, so when we're
967 scaling buffer positions to scroll bar positions, we use this, not
968 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
969 #define VERTICAL_SCROLL_BAR_TOP_RANGE(f, height) \
970 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
972 /* Return the inside height of vertical scroll bar, given the outside
973 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
974 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f, height) \
975 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
977 /* Return the inside height of a horizontal scroll bar, given the outside
978 height. */
979 #define HORIZONTAL_SCROLL_BAR_INSIDE_HEIGHT(f, height) \
980 ((height) \
981 - HORIZONTAL_SCROLL_BAR_TOP_BORDER \
982 - HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER)
984 /* Return the length of the rectangle within which the left part of the
985 handle must stay. This isn't equivalent to the inside width, because
986 the scroll bar handle has a minimum width.
988 This is the real range of motion for the scroll bar, so when we're
989 scaling buffer positions to scroll bar positions, we use this, not
990 HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH. */
991 #define HORIZONTAL_SCROLL_BAR_LEFT_RANGE(f, width) \
992 (HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH (f, width) - HORIZONTAL_SCROLL_BAR_MIN_HANDLE)
994 /* Return the inside width of horizontal scroll bar, given the outside
995 width. See HORIZONTAL_SCROLL_BAR_LEFT_RANGE too. */
996 #define HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
997 ((width) - HORIZONTAL_SCROLL_BAR_LEFT_BORDER - HORIZONTAL_SCROLL_BAR_LEFT_BORDER)
1000 /* Border widths for scroll bars.
1002 Scroll bar windows don't have any X borders; their border width is
1003 set to zero, and we redraw borders ourselves. This makes the code
1004 a bit cleaner, since we don't have to convert between outside width
1005 (used when relating to the rest of the screen) and inside width
1006 (used when sizing and drawing the scroll bar window itself).
1008 The handle moves up and down/back and forth in a rectangle inset
1009 from the edges of the scroll bar. These are widths by which we
1010 inset the handle boundaries from the scroll bar edges. */
1011 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (2)
1012 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (2)
1013 #define VERTICAL_SCROLL_BAR_TOP_BORDER (2)
1014 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (2)
1016 #define HORIZONTAL_SCROLL_BAR_LEFT_BORDER (2)
1017 #define HORIZONTAL_SCROLL_BAR_RIGHT_BORDER (2)
1018 #define HORIZONTAL_SCROLL_BAR_TOP_BORDER (2)
1019 #define HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER (2)
1021 /* Minimum lengths for scroll bar handles, in pixels. */
1022 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (5)
1023 #define HORIZONTAL_SCROLL_BAR_MIN_HANDLE (5)
1025 /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT
1026 or SELECTION_CLEAR_EVENT, then its contents are really described
1027 by this structure. */
1029 /* For an event of kind SELECTION_REQUEST_EVENT,
1030 this structure really describes the contents. */
1032 struct selection_input_event
1034 ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH;
1035 struct x_display_info *dpyinfo;
1036 /* We spell it with an "o" here because X does. */
1037 Window requestor;
1038 Atom selection, target, property;
1039 Time time;
1042 /* Unlike macros below, this can't be used as an lvalue. */
1043 INLINE Display *
1044 SELECTION_EVENT_DISPLAY (struct selection_input_event *ev)
1046 return ev->dpyinfo->display;
1048 #define SELECTION_EVENT_DPYINFO(eventp) \
1049 ((eventp)->dpyinfo)
1050 /* We spell it with an "o" here because X does. */
1051 #define SELECTION_EVENT_REQUESTOR(eventp) \
1052 ((eventp)->requestor)
1053 #define SELECTION_EVENT_SELECTION(eventp) \
1054 ((eventp)->selection)
1055 #define SELECTION_EVENT_TARGET(eventp) \
1056 ((eventp)->target)
1057 #define SELECTION_EVENT_PROPERTY(eventp) \
1058 ((eventp)->property)
1059 #define SELECTION_EVENT_TIME(eventp) \
1060 ((eventp)->time)
1062 /* From xfns.c. */
1064 extern void x_free_gcs (struct frame *);
1065 extern void x_relative_mouse_position (struct frame *, int *, int *);
1066 extern void x_real_pos_and_offsets (struct frame *f,
1067 int *left_offset_x,
1068 int *right_offset_x,
1069 int *top_offset_y,
1070 int *bottom_offset_y,
1071 int *x_pixels_diff,
1072 int *y_pixels_diff,
1073 int *xptr,
1074 int *yptr,
1075 int *outer_border);
1077 /* From xrdb.c. */
1079 XrmDatabase x_load_resources (Display *, const char *, const char *,
1080 const char *);
1082 /* Defined in xterm.c */
1084 typedef void (*x_special_error_handler)(Display *, XErrorEvent *, char *,
1085 void *);
1087 extern bool x_text_icon (struct frame *, const char *);
1088 extern void x_catch_errors (Display *);
1089 extern void x_catch_errors_with_handler (Display *, x_special_error_handler,
1090 void *);
1091 extern void x_check_errors (Display *, const char *)
1092 ATTRIBUTE_FORMAT_PRINTF (2, 0);
1093 extern bool x_had_errors_p (Display *);
1094 extern void x_uncatch_errors (void);
1095 extern void x_uncatch_errors_after_check (void);
1096 extern void x_clear_errors (Display *);
1097 extern void xembed_request_focus (struct frame *);
1098 extern void x_ewmh_activate_frame (struct frame *);
1099 extern void x_delete_terminal (struct terminal *terminal);
1100 extern unsigned long x_copy_color (struct frame *, unsigned long);
1101 #ifdef USE_X_TOOLKIT
1102 extern XtAppContext Xt_app_con;
1103 extern void x_activate_timeout_atimer (void);
1104 #endif
1105 #ifdef USE_LUCID
1106 extern bool x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
1107 unsigned long *,
1108 double, int);
1109 #endif
1110 extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *);
1111 extern void x_query_color (struct frame *f, XColor *);
1112 extern void x_clear_area (struct frame *f, int, int, int, int);
1113 #if !defined USE_X_TOOLKIT && !defined USE_GTK
1114 extern void x_mouse_leave (struct x_display_info *);
1115 #endif
1117 #if defined USE_X_TOOLKIT || defined USE_MOTIF
1118 extern int x_dispatch_event (XEvent *, Display *);
1119 #endif
1120 extern int x_x_to_emacs_modifiers (struct x_display_info *, int);
1121 #ifdef USE_CAIRO
1122 extern cairo_t *x_begin_cr_clip (struct frame *, GC);
1123 extern void x_end_cr_clip (struct frame *);
1124 extern void x_set_cr_source_with_gc_foreground (struct frame *, GC);
1125 extern void x_set_cr_source_with_gc_background (struct frame *, GC);
1126 extern void x_cr_draw_frame (cairo_t *, struct frame *);
1127 extern Lisp_Object x_cr_export_frames (Lisp_Object, cairo_surface_type_t);
1128 #endif
1130 INLINE int
1131 x_display_pixel_height (struct x_display_info *dpyinfo)
1133 return HeightOfScreen (dpyinfo->screen);
1136 INLINE int
1137 x_display_pixel_width (struct x_display_info *dpyinfo)
1139 return WidthOfScreen (dpyinfo->screen);
1142 INLINE void
1143 x_display_set_last_user_time (struct x_display_info *dpyinfo, Time t)
1145 #ifdef ENABLE_CHECKING
1146 eassert (t <= X_ULONG_MAX);
1147 #endif
1148 dpyinfo->last_user_time = t;
1151 INLINE unsigned long
1152 x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b)
1154 unsigned long pr, pg, pb;
1156 /* Scale down RGB values to the visual's bits per RGB, and shift
1157 them to the right position in the pixel color. Note that the
1158 original RGB values are 16-bit values, as usual in X. */
1159 pr = (r >> (16 - dpyinfo->red_bits)) << dpyinfo->red_offset;
1160 pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset;
1161 pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset;
1163 /* Assemble the pixel color. */
1164 return pr | pg | pb;
1167 /* If display has an immutable color map, freeing colors is not
1168 necessary and some servers don't allow it, so we won't do it. That
1169 also allows us to make other optimizations relating to server-side
1170 reference counts. */
1171 INLINE bool
1172 x_mutable_colormap (Visual *visual)
1174 int class = visual->class;
1175 return (class != StaticColor && class != StaticGray && class != TrueColor);
1178 extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object);
1179 extern void x_set_skip_taskbar (struct frame *, Lisp_Object, Lisp_Object);
1180 extern void x_set_z_group (struct frame *, Lisp_Object, Lisp_Object);
1181 extern bool x_wm_supports (struct frame *, Atom);
1182 extern void x_wait_for_event (struct frame *, int);
1183 extern void x_clear_under_internal_border (struct frame *f);
1185 extern void tear_down_x_back_buffer (struct frame *f);
1186 extern void initial_set_up_x_back_buffer (struct frame *f);
1188 /* Defined in xselect.c. */
1190 extern void x_handle_property_notify (const XPropertyEvent *);
1191 extern void x_handle_selection_notify (const XSelectionEvent *);
1192 extern void x_handle_selection_event (struct selection_input_event *);
1193 extern void x_clear_frame_selections (struct frame *);
1195 extern void x_send_client_event (Lisp_Object display,
1196 Lisp_Object dest,
1197 Lisp_Object from,
1198 Atom message_type,
1199 Lisp_Object format,
1200 Lisp_Object values);
1202 extern bool x_handle_dnd_message (struct frame *,
1203 const XClientMessageEvent *,
1204 struct x_display_info *,
1205 struct input_event *);
1206 extern int x_check_property_data (Lisp_Object);
1207 extern void x_fill_property_data (Display *,
1208 Lisp_Object,
1209 void *,
1210 int);
1211 extern Lisp_Object x_property_data_to_lisp (struct frame *,
1212 const unsigned char *,
1213 Atom,
1214 int,
1215 unsigned long);
1216 extern void x_clipboard_manager_save_frame (Lisp_Object);
1217 extern void x_clipboard_manager_save_all (void);
1219 #ifdef USE_GTK
1220 extern bool xg_set_icon (struct frame *, Lisp_Object);
1221 extern bool xg_set_icon_from_xpm_data (struct frame *, const char **);
1222 #endif /* USE_GTK */
1224 extern void xic_free_xfontset (struct frame *);
1225 extern void create_frame_xic (struct frame *);
1226 extern void destroy_frame_xic (struct frame *);
1227 extern void xic_set_preeditarea (struct window *, int, int);
1228 extern void xic_set_statusarea (struct frame *);
1229 extern void xic_set_xfontset (struct frame *, const char *);
1230 extern bool x_defined_color (struct frame *, const char *, XColor *, bool);
1231 #ifdef HAVE_X_I18N
1232 extern void free_frame_xic (struct frame *);
1233 # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT
1234 extern char *xic_create_fontsetname (const char *, bool);
1235 # endif
1236 #endif
1238 /* Defined in xfaces.c */
1240 #ifdef USE_X_TOOLKIT
1241 extern void x_free_dpy_colors (Display *, Screen *, Colormap,
1242 unsigned long *, int);
1243 #endif /* USE_X_TOOLKIT */
1245 /* Defined in xmenu.c */
1247 #if defined USE_X_TOOLKIT || defined USE_GTK
1248 extern Lisp_Object xw_popup_dialog (struct frame *, Lisp_Object, Lisp_Object);
1249 #endif
1251 #if defined USE_GTK || defined USE_MOTIF
1252 extern void x_menu_set_in_use (bool);
1253 #endif
1254 extern void x_menu_wait_for_event (void *data);
1255 extern void initialize_frame_menubar (struct frame *);
1257 /* Defined in xsmfns.c */
1258 #ifdef HAVE_X_SM
1259 extern void x_session_initialize (struct x_display_info *dpyinfo);
1260 extern bool x_session_have_connection (void);
1261 extern void x_session_close (void);
1262 #endif
1265 /* Is the frame embedded into another application? */
1267 #define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0)
1269 #define STORE_XCHAR2B(chp, b1, b2) \
1270 ((chp)->byte1 = (b1), (chp)->byte2 = (b2))
1272 #define XCHAR2B_BYTE1(chp) \
1273 ((chp)->byte1)
1275 #define XCHAR2B_BYTE2(chp) \
1276 ((chp)->byte2)
1278 #define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight) \
1279 ((nr).x = (rx), \
1280 (nr).y = (ry), \
1281 (nr).width = (rwidth), \
1282 (nr).height = (rheight))
1284 INLINE_HEADER_END
1286 #endif /* XTERM_H */