]> code.delx.au - gnu-emacs/blob - src/xterm.h
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
[gnu-emacs] / src / xterm.h
1 /* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989, 1993-1994, 1998-2016 Free Software Foundation,
3 Inc.
4
5 This file is part of GNU Emacs.
6
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.
11
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.
16
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/>. */
19
20 #ifndef XTERM_H
21 #define XTERM_H
22
23 #include <X11/Xlib.h>
24 #include <X11/cursorfont.h>
25
26 /* Include Xutil.h after keysym.h to work around a bug that prevents
27 correct recognition of AltGr key in some X versions. */
28
29 #include <X11/keysym.h>
30 #include <X11/Xutil.h>
31
32 #include <X11/Xatom.h>
33 #include <X11/Xresource.h>
34
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
44
45 typedef Widget xt_or_gtk_widget;
46 #endif
47
48 #ifdef USE_GTK
49 #include <gtk/gtk.h>
50 #include <gdk/gdkx.h>
51
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 */
58
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
71
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
76
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
89
90 #ifdef HAVE_X_I18N
91 #include <X11/Xlocale.h>
92 #endif
93
94 #ifdef USE_XCB
95 #include <X11/Xlib-xcb.h>
96 #endif
97
98 #include "dispextern.h"
99 #include "termhooks.h"
100
101 INLINE_HEADER_BEGIN
102
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))
108
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. */
112
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)
124
125 #ifdef HAVE_X11R6_XIM
126 /* Data structure passed to xim_instantiate_callback. */
127 struct xim_inst_t
128 {
129 struct x_display_info *dpyinfo;
130 char *resource_name;
131 };
132 #endif /* HAVE_X11R6_XIM */
133
134 /* Structure recording X pixmap and reference count.
135 If REFCOUNT is 0 then this record is free to be reused. */
136
137 struct x_bitmap_record
138 {
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;
149 };
150 \f
151 #ifdef USE_CAIRO
152 struct x_gc_ext_data
153 {
154 #define MAX_CLIP_RECTS 2
155 /* Number of clipping rectangles. */
156 int n_clip_rects;
157
158 /* Clipping rectangles. */
159 XRectangle clip_rects[MAX_CLIP_RECTS];
160 };
161 #endif
162
163 \f
164 struct color_name_cache_entry
165 {
166 struct color_name_cache_entry *next;
167 XColor rgb;
168 char *name;
169 };
170
171 Status x_parse_color (struct frame *f, const char *color_name,
172 XColor *color);
173
174 \f
175 /* For each X display, we have a structure that records
176 information about it. */
177
178 struct x_display_info
179 {
180 /* Chain of all x_display_info structures. */
181 struct x_display_info *next;
182
183 /* The generic display parameters corresponding to this X display. */
184 struct terminal *terminal;
185
186 /* This says how to access this display in Xlib. */
187 Display *display;
188
189 /* A connection number (file descriptor) for the display. */
190 int connection;
191
192 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE). */
193 Lisp_Object name_list_element;
194
195 /* Number of frames that are on this display. */
196 int reference_count;
197
198 /* The Screen this connection is connected to. */
199 Screen *screen;
200
201 /* Dots per inch of the screen. */
202 double resx, resy;
203
204 /* The Visual being used for this display. */
205 Visual *visual;
206
207 /* The colormap being used. */
208 Colormap cmap;
209
210 /* Number of planes on this screen. */
211 int n_planes;
212
213 /* Mask of things that cause the mouse to be grabbed. */
214 int grabbed;
215
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;
219
220 /* The root window of this screen. */
221 Window root_window;
222
223 /* Client leader window. */
224 Window client_leader_window;
225
226 /* The cursor to use for vertical scroll bars. */
227 Cursor vertical_scroll_bar_cursor;
228
229 /* The cursor to use for horizontal scroll bars. */
230 Cursor horizontal_scroll_bar_cursor;
231
232 /* The invisible cursor used for pointer blanking.
233 Unused if this display supports Xfixes extension. */
234 Cursor invisible_cursor;
235
236 /* Function used to toggle pointer visibility on this display. */
237 void (*toggle_visible_pointer) (struct frame *, bool);
238
239 #ifdef USE_GTK
240 /* The GDK cursor for scroll bars and popup menus. */
241 GdkCursor *xg_cursor;
242 #endif
243
244 /* X Resource data base */
245 XrmDatabase xrdb;
246
247 /* Minimum width over all characters in all fonts in font_table. */
248 int smallest_char_width;
249
250 /* Minimum font height over all fonts in font_table. */
251 int smallest_font_height;
252
253 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
254 GC scratch_cursor_gc;
255
256 /* Information about the range of text currently shown in
257 mouse-face. */
258 Mouse_HLInfo mouse_highlight;
259
260 /* Logical identifier of this display. */
261 unsigned x_id;
262
263 /* Default name for all frames on this display. */
264 char *x_id_name;
265
266 /* The number of fonts opened for this display. */
267 int n_fonts;
268
269 /* Pointer to bitmap records. */
270 struct x_bitmap_record *bitmaps;
271
272 /* Allocated size of bitmaps field. */
273 ptrdiff_t bitmaps_size;
274
275 /* Last used bitmap index. */
276 ptrdiff_t bitmaps_last;
277
278 /* Which modifier keys are on which modifier bits?
279
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.
285
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.
290
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;
298
299 /* These are like meta_mod_mask, but for different modifiers. */
300 int alt_mod_mask, super_mod_mask, hyper_mod_mask;
301
302 /* Communication with window managers. */
303 Atom Xatom_wm_protocols;
304
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;
309
310 /* Atom for indicating window state to the window manager. */
311 Atom Xatom_wm_change_state;
312
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. */
317
318 /* EditRes protocol */
319 Atom Xatom_editres;
320
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;
326
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;
332
333 /* More atoms for Ghostscript support. */
334 Atom Xatom_DONE, Xatom_PAGE;
335
336 /* Atoms used in toolkit scroll bar client messages. */
337 Atom Xatom_Scrollbar, Xatom_Horizontal_Scrollbar;
338
339 /* Atom used in XEmbed client messages. */
340 Atom Xatom_XEMBED, Xatom_XEMBED_INFO;
341
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;
348
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;
354
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;
361
362 /* The frame waiting to be auto-raised in XTread_socket. */
363 struct frame *x_pending_autoraise_frame;
364
365 /* Tooltip frame on this display. */
366 struct frame *x_tooltip_frame;
367
368 /* The frame where the mouse was last time we reported a ButtonPress event. */
369 struct frame *last_mouse_frame;
370
371 /* The frame where the mouse was last time we reported a mouse position. */
372 struct frame *last_mouse_glyph_frame;
373
374 /* The frame where the mouse was last time we reported a mouse motion. */
375 struct frame *last_mouse_motion_frame;
376
377 /* The scroll bar in which the last X motion event occurred. */
378 struct scroll_bar *last_mouse_scroll_bar;
379
380 /* Time of last user interaction as returned in X events on this display. */
381 Time last_user_time;
382
383 /* Position where the mouse was last time we reported a motion.
384 This is a position on last_mouse_motion_frame. */
385 int last_mouse_motion_x;
386 int last_mouse_motion_y;
387
388 /* Where the mouse was last time we reported a mouse position.
389 This is a rectangle on last_mouse_glyph_frame. */
390 XRectangle last_mouse_glyph;
391
392 /* Time of last mouse movement on this display. This is a hack because
393 we would really prefer that XTmouse_position would return the time
394 associated with the position it returns, but there doesn't seem to be
395 any way to wrest the time-stamp from the server along with the position
396 query. So, we just keep track of the time of the last movement we
397 received, and return that in hopes that it's somewhat accurate. */
398 Time last_mouse_movement_time;
399
400 /* The gray pixmap. */
401 Pixmap gray;
402
403 #ifdef HAVE_X_I18N
404 /* XIM (X Input method). */
405 XIM xim;
406 XIMStyles *xim_styles;
407 struct xim_inst_t *xim_callback_data;
408 #endif
409
410 /* A cache mapping color names to RGB values. */
411 struct color_name_cache_entry *color_names;
412
413 /* If non-null, a cache of the colors in the color map. Don't
414 use this directly, call x_color_cells instead. */
415 XColor *color_cells;
416 int ncolor_cells;
417
418 /* Bits and shifts to use to compose pixel values on TrueColor visuals. */
419 int red_bits, blue_bits, green_bits;
420 int red_offset, blue_offset, green_offset;
421
422 /* The type of window manager we have. If we move FRAME_OUTER_WINDOW
423 to x/y 0/0, some window managers (type A) puts the window manager
424 decorations outside the screen and FRAME_OUTER_WINDOW exactly at 0/0.
425 Other window managers (type B) puts the window including decorations
426 at 0/0, so FRAME_OUTER_WINDOW is a bit below 0/0.
427 Record the type of WM in use so we can compensate for type A WMs. */
428 enum
429 {
430 X_WMTYPE_UNKNOWN,
431 X_WMTYPE_A,
432 X_WMTYPE_B
433 } wm_type;
434
435
436 /* Atoms that are drag and drop atoms */
437 Atom *x_dnd_atoms;
438 ptrdiff_t x_dnd_atoms_size;
439 ptrdiff_t x_dnd_atoms_length;
440
441 /* Extended window manager hints, Atoms supported by the window manager and
442 atoms for setting the window type. */
443 Atom Xatom_net_supported, Xatom_net_supporting_wm_check;
444 Atom *net_supported_atoms;
445 int nr_net_supported_atoms;
446 Window net_supported_window;
447 Atom Xatom_net_window_type, Xatom_net_window_type_tooltip;
448 Atom Xatom_net_active_window;
449
450 /* Atoms dealing with EWMH (i.e. _NET_...) */
451 Atom Xatom_net_wm_state, Xatom_net_wm_state_fullscreen,
452 Xatom_net_wm_state_maximized_horz, Xatom_net_wm_state_maximized_vert,
453 Xatom_net_wm_state_sticky, Xatom_net_wm_state_hidden,
454 Xatom_net_frame_extents,
455 Xatom_net_current_desktop, Xatom_net_workarea;
456
457 /* XSettings atoms and windows. */
458 Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr;
459 Window xsettings_window;
460
461 /* Frame name and icon name */
462 Atom Xatom_net_wm_name, Xatom_net_wm_icon_name;
463 /* Frame opacity */
464 Atom Xatom_net_wm_window_opacity;
465
466 /* SM */
467 Atom Xatom_SM_CLIENT_ID;
468
469 #ifdef HAVE_XRANDR
470 int xrandr_major_version;
471 int xrandr_minor_version;
472 #endif
473
474 #ifdef USE_CAIRO
475 XExtCodes *ext_codes;
476 #endif
477
478 #ifdef USE_XCB
479 xcb_connection_t *xcb_connection;
480 #endif
481 };
482
483 #ifdef HAVE_X_I18N
484 /* Whether or not to use XIM if we have it. */
485 extern bool use_xim;
486 #endif
487
488 /* This is a chain of structures for all the X displays currently in use. */
489 extern struct x_display_info *x_display_list;
490
491 extern struct x_display_info *x_display_info_for_display (Display *);
492 extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
493 extern struct x_display_info *x_term_init (Lisp_Object, char *, char *);
494 extern bool x_display_ok (const char *);
495
496 extern void select_visual (struct x_display_info *);
497
498 /* Each X frame object points to its own struct x_output object
499 in the output_data.x field. The x_output structure contains
500 the information that is specific to X windows. */
501
502 struct x_output
503 {
504 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
505 /* Height of menu bar widget, in pixels. This value
506 is not meaningful if the menubar is turned off. */
507 int menubar_height;
508 #endif
509
510 /* Height of tool bar widget, in pixels. top_height is used if tool bar
511 at top, bottom_height if tool bar is at the bottom.
512 Zero if not using an external tool bar or if tool bar is vertical. */
513 int toolbar_top_height, toolbar_bottom_height;
514
515 /* Width of tool bar widget, in pixels. left_width is used if tool bar
516 at left, right_width if tool bar is at the right.
517 Zero if not using an external tool bar or if tool bar is horizontal. */
518 int toolbar_left_width, toolbar_right_width;
519
520 /* The tiled border used when the mouse is out of the frame. */
521 Pixmap border_tile;
522
523 /* Here are the Graphics Contexts for the default font. */
524 GC normal_gc; /* Normal video */
525 GC reverse_gc; /* Reverse video */
526 GC cursor_gc; /* cursor drawing */
527
528 /* The X window used for this frame.
529 May be zero while the frame object is being created
530 and the X window has not yet been created. */
531 Window window_desc;
532
533 /* The X window used for the bitmap icon;
534 or 0 if we don't have a bitmap icon. */
535 Window icon_desc;
536
537 /* The X window that is the parent of this X window.
538 Usually this is a window that was made by the window manager,
539 but it can be the root window, and it can be explicitly specified
540 (see the explicit_parent field, below). */
541 Window parent_desc;
542
543 #ifdef USE_X_TOOLKIT
544 /* The widget of this screen. This is the window of a "shell" widget. */
545 Widget widget;
546 /* The XmPanedWindows... */
547 Widget column_widget;
548 /* The widget of the edit portion of this screen; the window in
549 "window_desc" is inside of this. */
550 Widget edit_widget;
551
552 Widget menubar_widget;
553 #endif
554
555 #ifdef USE_GTK
556 /* The widget of this screen. This is the window of a top widget. */
557 GtkWidget *widget;
558 /* The widget of the edit portion of this screen; the window in
559 "window_desc" is inside of this. */
560 GtkWidget *edit_widget;
561 /* The widget used for laying out widgets vertically. */
562 GtkWidget *vbox_widget;
563 /* The widget used for laying out widgets horizontally. */
564 GtkWidget *hbox_widget;
565 /* The menubar in this frame. */
566 GtkWidget *menubar_widget;
567 /* The tool bar in this frame */
568 GtkWidget *toolbar_widget;
569 /* True if tool bar is packed into the hbox widget (i.e. vertical). */
570 bool_bf toolbar_in_hbox : 1;
571 bool_bf toolbar_is_packed : 1;
572
573 /* The last size hints set. */
574 GdkGeometry size_hints;
575 long hint_flags;
576
577 #ifdef USE_GTK_TOOLTIP
578 GtkTooltip *ttip_widget;
579 GtkWidget *ttip_lbl;
580 GtkWindow *ttip_window;
581 guint ttip_timeout;
582 #endif /* USE_GTK_TOOLTIP */
583
584 #endif /* USE_GTK */
585
586 /* If >=0, a bitmap index. The indicated bitmap is used for the
587 icon. */
588 ptrdiff_t icon_bitmap;
589
590 /* Default ASCII font of this frame. */
591 struct font *font;
592
593 /* The baseline offset of the default ASCII font. */
594 int baseline_offset;
595
596 /* If a fontset is specified for this frame instead of font, this
597 value contains an ID of the fontset, else -1. */
598 int fontset;
599
600 unsigned long cursor_pixel;
601 unsigned long border_pixel;
602 unsigned long mouse_pixel;
603 unsigned long cursor_foreground_pixel;
604
605 /* Foreground color for scroll bars. A value of -1 means use the
606 default (black for non-toolkit scroll bars). */
607 unsigned long scroll_bar_foreground_pixel;
608
609 /* Background color for scroll bars. A value of -1 means use the
610 default (background color of the frame for non-toolkit scroll
611 bars). */
612 unsigned long scroll_bar_background_pixel;
613
614 #if defined (USE_LUCID) && defined (USE_TOOLKIT_SCROLL_BARS)
615 /* Top and bottom shadow colors for 3D Lucid scrollbars.
616 -1 means let the scroll compute them itself. */
617 unsigned long scroll_bar_top_shadow_pixel;
618 unsigned long scroll_bar_bottom_shadow_pixel;
619 #endif
620
621 /* Descriptor for the cursor in use for this window. */
622 Cursor text_cursor;
623 Cursor nontext_cursor;
624 Cursor modeline_cursor;
625 Cursor hand_cursor;
626 Cursor hourglass_cursor;
627 Cursor horizontal_drag_cursor;
628 Cursor vertical_drag_cursor;
629 Cursor current_cursor;
630
631 /* Window whose cursor is hourglass_cursor. This window is temporarily
632 mapped to display an hourglass cursor. */
633 Window hourglass_window;
634
635 /* These are the current window manager hints. It seems that
636 XSetWMHints, when presented with an unset bit in the `flags'
637 member of the hints structure, does not leave the corresponding
638 attribute unchanged; rather, it resets that attribute to its
639 default value. For example, unless you set the `icon_pixmap'
640 field and the `IconPixmapHint' bit, XSetWMHints will forget what
641 your icon pixmap was. This is rather troublesome, since some of
642 the members (for example, `input' and `icon_pixmap') want to stay
643 the same throughout the execution of Emacs. So, we keep this
644 structure around, just leaving values in it and adding new bits
645 to the mask as we go. */
646 XWMHints wm_hints;
647
648 /* This is the Emacs structure for the X display this frame is on. */
649 struct x_display_info *display_info;
650
651 /* This is a button event that wants to activate the menubar.
652 We save it here until the command loop gets to think about it. */
653 XEvent *saved_menu_event;
654
655 /* This is the widget id used for this frame's menubar in lwlib. */
656 #ifdef USE_X_TOOLKIT
657 int id;
658 #endif
659
660 /* True means hourglass cursor is currently displayed. */
661 bool_bf hourglass_p : 1;
662
663 /* True means our parent is another application's window
664 and was explicitly specified. */
665 bool_bf explicit_parent : 1;
666
667 /* True means tried already to make this frame visible. */
668 bool_bf asked_for_visible : 1;
669
670 /* True if this frame was ever previously visible. */
671 bool_bf has_been_visible : 1;
672
673 /* Xt waits for a ConfigureNotify event from the window manager in
674 EmacsFrameSetCharSize when the shell widget is resized. For some
675 window managers like fvwm2 2.2.5 and KDE 2.1 this event doesn't
676 arrive for an unknown reason and Emacs hangs in Xt. If this is
677 false, tell Xt not to wait. */
678 bool_bf wait_for_wm : 1;
679
680 #ifdef HAVE_X_I18N
681 /* Input context (currently, this means Compose key handler setup). */
682 XIC xic;
683 XIMStyle xic_style;
684 XFontSet xic_xfs;
685 #endif
686
687 /* Relief GCs, colors etc. */
688 struct relief
689 {
690 GC gc;
691 unsigned long pixel;
692 }
693 black_relief, white_relief;
694
695 /* The background for which the above relief GCs were set up.
696 They are changed only when a different background is involved. */
697 unsigned long relief_background;
698
699 /* Keep track of focus. May be EXPLICIT if we received a FocusIn for this
700 frame, or IMPLICIT if we received an EnterNotify.
701 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
702 int focus_state;
703
704 /* The offset we need to add to compensate for type A WMs. */
705 int move_offset_top;
706 int move_offset_left;
707
708 /* Extreme 'short' and 'long' values suitable for libX11. */
709 #define X_SHRT_MAX 0x7fff
710 #define X_SHRT_MIN (-1 - X_SHRT_MAX)
711 #define X_LONG_MAX 0x7fffffff
712 #define X_LONG_MIN (-1 - X_LONG_MAX)
713 #define X_ULONG_MAX 0xffffffffUL
714
715 #ifdef USE_CAIRO
716 /* Cairo drawing context. */
717 cairo_t *cr_context;
718 /* Cairo surface for double buffering */
719 cairo_surface_t *cr_surface;
720 #endif
721 };
722
723 #define No_Cursor (None)
724
725 enum
726 {
727 /* Values for focus_state, used as bit mask.
728 EXPLICIT means we received a FocusIn for the frame and know it has
729 the focus. IMPLICIT means we received an EnterNotify and the frame
730 may have the focus if no window manager is running.
731 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
732 FOCUS_NONE = 0,
733 FOCUS_IMPLICIT = 1,
734 FOCUS_EXPLICIT = 2
735 };
736
737
738 /* Return the X output data for frame F. */
739 #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
740
741 /* Return the X window used for displaying data in frame F. */
742 #define FRAME_X_WINDOW(f) ((f)->output_data.x->window_desc)
743
744 /* Return the outermost X window associated with the frame F. */
745 #ifdef USE_X_TOOLKIT
746 #define FRAME_OUTER_WINDOW(f) ((f)->output_data.x->widget ? \
747 XtWindow ((f)->output_data.x->widget) : \
748 FRAME_X_WINDOW (f))
749 #else
750 #ifdef USE_GTK
751 /* Functions not present in older Gtk+ */
752
753 #ifndef HAVE_GTK_WIDGET_GET_WINDOW
754 #define gtk_widget_get_window(w) ((w)->window)
755 #endif
756 #ifndef HAVE_GTK_WIDGET_GET_MAPPED
757 #define gtk_widget_get_mapped(w) (GTK_WIDGET_MAPPED (w))
758 #endif
759 #ifndef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE
760 #define gtk_adjustment_get_page_size(w) ((w)->page_size)
761 #define gtk_adjustment_get_upper(w) ((w)->upper)
762 #endif
763
764 #ifdef HAVE_GTK3
765 #define DEFAULT_GDK_DISPLAY() \
766 gdk_x11_display_get_xdisplay (gdk_display_get_default ())
767 #else
768 #undef GDK_WINDOW_XID
769 #define GDK_WINDOW_XID(w) GDK_WINDOW_XWINDOW (w)
770 #define DEFAULT_GDK_DISPLAY() GDK_DISPLAY ()
771 #define gtk_widget_get_preferred_size(a, ign, b) \
772 gtk_widget_size_request (a, b)
773 #endif
774
775 #define GTK_WIDGET_TO_X_WIN(w) \
776 ((w) && gtk_widget_get_window (w) \
777 ? GDK_WINDOW_XID (gtk_widget_get_window (w)) : 0)
778
779 #define FRAME_GTK_OUTER_WIDGET(f) ((f)->output_data.x->widget)
780 #define FRAME_GTK_WIDGET(f) ((f)->output_data.x->edit_widget)
781 #define FRAME_OUTER_WINDOW(f) \
782 (FRAME_GTK_OUTER_WIDGET (f) ? \
783 GTK_WIDGET_TO_X_WIN (FRAME_GTK_OUTER_WIDGET (f)) : \
784 FRAME_X_WINDOW (f))
785
786 #else /* !USE_GTK */
787 #define FRAME_OUTER_WINDOW(f) (FRAME_X_WINDOW (f))
788 #endif /* !USE_GTK */
789 #endif
790
791 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
792 #define FRAME_MENUBAR_HEIGHT(f) ((f)->output_data.x->menubar_height)
793 #else
794 #define FRAME_MENUBAR_HEIGHT(f) ((void) f, 0)
795 #endif /* USE_X_TOOLKIT || USE_GTK */
796
797 #define FRAME_FONT(f) ((f)->output_data.x->font)
798 #define FRAME_FONTSET(f) ((f)->output_data.x->fontset)
799 #define FRAME_TOOLBAR_TOP_HEIGHT(f) ((f)->output_data.x->toolbar_top_height)
800 #define FRAME_TOOLBAR_BOTTOM_HEIGHT(f) \
801 ((f)->output_data.x->toolbar_bottom_height)
802 #define FRAME_TOOLBAR_HEIGHT(f) \
803 (FRAME_TOOLBAR_TOP_HEIGHT (f) + FRAME_TOOLBAR_BOTTOM_HEIGHT (f))
804 #define FRAME_TOOLBAR_LEFT_WIDTH(f) ((f)->output_data.x->toolbar_left_width)
805 #define FRAME_TOOLBAR_RIGHT_WIDTH(f) ((f)->output_data.x->toolbar_right_width)
806 #define FRAME_TOOLBAR_WIDTH(f) \
807 (FRAME_TOOLBAR_LEFT_WIDTH (f) + FRAME_TOOLBAR_RIGHT_WIDTH (f))
808 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.x->baseline_offset)
809
810 /* This gives the x_display_info structure for the display F is on. */
811 #define FRAME_DISPLAY_INFO(f) ((f)->output_data.x->display_info)
812
813 /* This is the `Display *' which frame F is on. */
814 #define FRAME_X_DISPLAY(f) (FRAME_DISPLAY_INFO (f)->display)
815
816 /* This is the `Screen *' which frame F is on. */
817 #define FRAME_X_SCREEN(f) (FRAME_DISPLAY_INFO (f)->screen)
818
819 /* This is the screen index number of screen which frame F is on. */
820 #define FRAME_X_SCREEN_NUMBER(f) XScreenNumberOfScreen (FRAME_X_SCREEN (f))
821
822 /* This is the Visual which frame F is on. */
823 #define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO (f)->visual
824
825 /* This is the Colormap which frame F uses. */
826 #define FRAME_X_COLORMAP(f) FRAME_DISPLAY_INFO (f)->cmap
827
828 #define FRAME_XIC(f) ((f)->output_data.x->xic)
829 #define FRAME_X_XIM(f) (FRAME_DISPLAY_INFO (f)->xim)
830 #define FRAME_X_XIM_STYLES(f) (FRAME_DISPLAY_INFO (f)->xim_styles)
831 #define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style)
832 #define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs)
833
834 /* X-specific scroll bar stuff. */
835
836 /* We represent scroll bars as lisp vectors. This allows us to place
837 references to them in windows without worrying about whether we'll
838 end up with windows referring to dead scroll bars; the garbage
839 collector will free it when its time comes.
840
841 We use struct scroll_bar as a template for accessing fields of the
842 vector. */
843
844 struct scroll_bar
845 {
846 /* These fields are shared by all vectors. */
847 struct vectorlike_header header;
848
849 /* The window we're a scroll bar for. */
850 Lisp_Object window;
851
852 /* The next and previous in the chain of scroll bars in this frame. */
853 Lisp_Object next, prev;
854
855 /* Fields from `x_window' down will not be traced by the GC. */
856
857 /* The X window representing this scroll bar. */
858 Window x_window;
859
860 /* The position and size of the scroll bar in pixels, relative to the
861 frame. */
862 int top, left, width, height;
863
864 /* The starting and ending positions of the handle, relative to the
865 handle area (i.e. zero is the top position, not
866 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
867 hasn't been drawn yet.
868
869 These are not actually the locations where the beginning and end
870 are drawn; in order to keep handles from becoming invisible when
871 editing large files, we establish a minimum height by always
872 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
873 where they would be normally; the bottom and top are in a
874 different co-ordinate system. */
875 int start, end;
876
877 /* If the scroll bar handle is currently being dragged by the user,
878 this is the number of pixels from the top of the handle to the
879 place where the user grabbed it. If the handle isn't currently
880 being dragged, this is -1. */
881 int dragging;
882
883 #if defined (USE_TOOLKIT_SCROLL_BARS) && defined (USE_LUCID)
884 /* Last scroll bar part seen in xaw_jump_callback and xaw_scroll_callback. */
885 enum scroll_bar_part last_seen_part;
886 #endif
887
888 #if defined (USE_TOOLKIT_SCROLL_BARS) && !defined (USE_GTK)
889 /* Last value of whole for horizontal scrollbars. */
890 int whole;
891 #endif
892
893 /* True if the scroll bar is horizontal. */
894 bool horizontal;
895 };
896
897 /* Turning a lisp vector value into a pointer to a struct scroll_bar. */
898 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
899
900 #ifdef USE_X_TOOLKIT
901
902 /* Extract the X widget of the scroll bar from a struct scroll_bar.
903 XtWindowToWidget should be fast enough since Xt uses a hash table
904 to map windows to widgets. */
905
906 #define SCROLL_BAR_X_WIDGET(dpy, ptr) \
907 XtWindowToWidget (dpy, ptr->x_window)
908
909 /* Store a widget id in a struct scroll_bar. */
910
911 #define SET_SCROLL_BAR_X_WIDGET(ptr, w) \
912 do { \
913 Window window = XtWindow (w); \
914 ptr->x_window = window; \
915 } while (false)
916
917 #endif /* USE_X_TOOLKIT */
918
919 /* Return the inside width of a vertical scroll bar, given the outside
920 width. */
921 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
922 ((width) \
923 - VERTICAL_SCROLL_BAR_LEFT_BORDER \
924 - VERTICAL_SCROLL_BAR_RIGHT_BORDER)
925
926 /* Return the length of the rectangle within which the top of the
927 handle must stay. This isn't equivalent to the inside height,
928 because the scroll bar handle has a minimum height.
929
930 This is the real range of motion for the scroll bar, so when we're
931 scaling buffer positions to scroll bar positions, we use this, not
932 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
933 #define VERTICAL_SCROLL_BAR_TOP_RANGE(f, height) \
934 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
935
936 /* Return the inside height of vertical scroll bar, given the outside
937 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
938 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f, height) \
939 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
940
941 /* Return the inside height of a horizontal scroll bar, given the outside
942 height. */
943 #define HORIZONTAL_SCROLL_BAR_INSIDE_HEIGHT(f, height) \
944 ((height) \
945 - HORIZONTAL_SCROLL_BAR_TOP_BORDER \
946 - HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER)
947
948 /* Return the length of the rectangle within which the left part of the
949 handle must stay. This isn't equivalent to the inside width, because
950 the scroll bar handle has a minimum width.
951
952 This is the real range of motion for the scroll bar, so when we're
953 scaling buffer positions to scroll bar positions, we use this, not
954 HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH. */
955 #define HORIZONTAL_SCROLL_BAR_LEFT_RANGE(f, width) \
956 (HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH (f, width) - HORIZONTAL_SCROLL_BAR_MIN_HANDLE)
957
958 /* Return the inside width of horizontal scroll bar, given the outside
959 width. See HORIZONTAL_SCROLL_BAR_LEFT_RANGE too. */
960 #define HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
961 ((width) - HORIZONTAL_SCROLL_BAR_LEFT_BORDER - HORIZONTAL_SCROLL_BAR_LEFT_BORDER)
962
963
964 /* Border widths for scroll bars.
965
966 Scroll bar windows don't have any X borders; their border width is
967 set to zero, and we redraw borders ourselves. This makes the code
968 a bit cleaner, since we don't have to convert between outside width
969 (used when relating to the rest of the screen) and inside width
970 (used when sizing and drawing the scroll bar window itself).
971
972 The handle moves up and down/back and forth in a rectangle inset
973 from the edges of the scroll bar. These are widths by which we
974 inset the handle boundaries from the scroll bar edges. */
975 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (2)
976 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (2)
977 #define VERTICAL_SCROLL_BAR_TOP_BORDER (2)
978 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (2)
979
980 #define HORIZONTAL_SCROLL_BAR_LEFT_BORDER (2)
981 #define HORIZONTAL_SCROLL_BAR_RIGHT_BORDER (2)
982 #define HORIZONTAL_SCROLL_BAR_TOP_BORDER (2)
983 #define HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER (2)
984
985 /* Minimum lengths for scroll bar handles, in pixels. */
986 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (5)
987 #define HORIZONTAL_SCROLL_BAR_MIN_HANDLE (5)
988
989 /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT
990 or SELECTION_CLEAR_EVENT, then its contents are really described
991 by this structure. */
992
993 /* For an event of kind SELECTION_REQUEST_EVENT,
994 this structure really describes the contents. */
995
996 struct selection_input_event
997 {
998 ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH;
999 struct x_display_info *dpyinfo;
1000 /* We spell it with an "o" here because X does. */
1001 Window requestor;
1002 Atom selection, target, property;
1003 Time time;
1004 };
1005
1006 /* Unlike macros below, this can't be used as an lvalue. */
1007 INLINE Display *
1008 SELECTION_EVENT_DISPLAY (struct selection_input_event *ev)
1009 {
1010 return ev->dpyinfo->display;
1011 }
1012 #define SELECTION_EVENT_DPYINFO(eventp) \
1013 ((eventp)->dpyinfo)
1014 /* We spell it with an "o" here because X does. */
1015 #define SELECTION_EVENT_REQUESTOR(eventp) \
1016 ((eventp)->requestor)
1017 #define SELECTION_EVENT_SELECTION(eventp) \
1018 ((eventp)->selection)
1019 #define SELECTION_EVENT_TARGET(eventp) \
1020 ((eventp)->target)
1021 #define SELECTION_EVENT_PROPERTY(eventp) \
1022 ((eventp)->property)
1023 #define SELECTION_EVENT_TIME(eventp) \
1024 ((eventp)->time)
1025
1026 /* From xfns.c. */
1027
1028 extern void x_free_gcs (struct frame *);
1029 extern void x_relative_mouse_position (struct frame *, int *, int *);
1030 extern void x_real_pos_and_offsets (struct frame *f,
1031 int *left_offset_x,
1032 int *right_offset_x,
1033 int *top_offset_y,
1034 int *bottom_offset_y,
1035 int *x_pixels_diff,
1036 int *y_pixels_diff,
1037 int *xptr,
1038 int *yptr,
1039 int *outer_border);
1040
1041 /* From xrdb.c. */
1042
1043 XrmDatabase x_load_resources (Display *, const char *, const char *,
1044 const char *);
1045
1046 /* Defined in xterm.c */
1047
1048 typedef void (*x_special_error_handler)(Display *, XErrorEvent *, char *,
1049 void *);
1050
1051 extern bool x_text_icon (struct frame *, const char *);
1052 extern void x_catch_errors (Display *);
1053 extern void x_catch_errors_with_handler (Display *, x_special_error_handler,
1054 void *);
1055 extern void x_check_errors (Display *, const char *)
1056 ATTRIBUTE_FORMAT_PRINTF (2, 0);
1057 extern bool x_had_errors_p (Display *);
1058 extern void x_uncatch_errors (void);
1059 extern void x_uncatch_errors_after_check (void);
1060 extern void x_clear_errors (Display *);
1061 extern void xembed_request_focus (struct frame *);
1062 extern void x_ewmh_activate_frame (struct frame *);
1063 extern void x_delete_terminal (struct terminal *terminal);
1064 extern unsigned long x_copy_color (struct frame *, unsigned long);
1065 #ifdef USE_X_TOOLKIT
1066 extern XtAppContext Xt_app_con;
1067 extern void x_activate_timeout_atimer (void);
1068 #endif
1069 #ifdef USE_LUCID
1070 extern bool x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
1071 unsigned long *,
1072 double, int);
1073 #endif
1074 extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *);
1075 extern void x_query_color (struct frame *f, XColor *);
1076 extern void x_clear_area (struct frame *f, int, int, int, int);
1077 #if !defined USE_X_TOOLKIT && !defined USE_GTK
1078 extern void x_mouse_leave (struct x_display_info *);
1079 #endif
1080
1081 #if defined USE_X_TOOLKIT || defined USE_MOTIF
1082 extern int x_dispatch_event (XEvent *, Display *);
1083 #endif
1084 extern int x_x_to_emacs_modifiers (struct x_display_info *, int);
1085 #ifdef USE_CAIRO
1086 extern cairo_t *x_begin_cr_clip (struct frame *, GC);
1087 extern void x_end_cr_clip (struct frame *);
1088 extern void x_set_cr_source_with_gc_foreground (struct frame *, GC);
1089 extern void x_set_cr_source_with_gc_background (struct frame *, GC);
1090 extern void x_cr_draw_frame (cairo_t *, struct frame *);
1091 extern Lisp_Object x_cr_export_frames (Lisp_Object, cairo_surface_type_t);
1092 #endif
1093
1094 INLINE int
1095 x_display_pixel_height (struct x_display_info *dpyinfo)
1096 {
1097 return HeightOfScreen (dpyinfo->screen);
1098 }
1099
1100 INLINE int
1101 x_display_pixel_width (struct x_display_info *dpyinfo)
1102 {
1103 return WidthOfScreen (dpyinfo->screen);
1104 }
1105
1106 INLINE void
1107 x_display_set_last_user_time (struct x_display_info *dpyinfo, Time t)
1108 {
1109 #ifdef ENABLE_CHECKING
1110 eassert (t <= X_ULONG_MAX);
1111 #endif
1112 dpyinfo->last_user_time = t;
1113 }
1114
1115 INLINE unsigned long
1116 x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b)
1117 {
1118 unsigned long pr, pg, pb;
1119
1120 /* Scale down RGB values to the visual's bits per RGB, and shift
1121 them to the right position in the pixel color. Note that the
1122 original RGB values are 16-bit values, as usual in X. */
1123 pr = (r >> (16 - dpyinfo->red_bits)) << dpyinfo->red_offset;
1124 pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset;
1125 pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset;
1126
1127 /* Assemble the pixel color. */
1128 return pr | pg | pb;
1129 }
1130
1131 /* If display has an immutable color map, freeing colors is not
1132 necessary and some servers don't allow it, so we won't do it. That
1133 also allows us to make other optimizations relating to server-side
1134 reference counts. */
1135 INLINE bool
1136 x_mutable_colormap (Visual *visual)
1137 {
1138 int class = visual->class;
1139 return (class != StaticColor && class != StaticGray && class != TrueColor);
1140 }
1141
1142 extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object);
1143 extern bool x_wm_supports (struct frame *, Atom);
1144 extern void x_wait_for_event (struct frame *, int);
1145 extern void x_clear_under_internal_border (struct frame *f);
1146
1147 /* Defined in xselect.c. */
1148
1149 extern void x_handle_property_notify (const XPropertyEvent *);
1150 extern void x_handle_selection_notify (const XSelectionEvent *);
1151 extern void x_handle_selection_event (struct selection_input_event *);
1152 extern void x_clear_frame_selections (struct frame *);
1153
1154 extern void x_send_client_event (Lisp_Object display,
1155 Lisp_Object dest,
1156 Lisp_Object from,
1157 Atom message_type,
1158 Lisp_Object format,
1159 Lisp_Object values);
1160
1161 extern bool x_handle_dnd_message (struct frame *,
1162 const XClientMessageEvent *,
1163 struct x_display_info *,
1164 struct input_event *);
1165 extern int x_check_property_data (Lisp_Object);
1166 extern void x_fill_property_data (Display *,
1167 Lisp_Object,
1168 void *,
1169 int);
1170 extern Lisp_Object x_property_data_to_lisp (struct frame *,
1171 const unsigned char *,
1172 Atom,
1173 int,
1174 unsigned long);
1175 extern void x_clipboard_manager_save_frame (Lisp_Object);
1176 extern void x_clipboard_manager_save_all (void);
1177
1178 #ifdef USE_GTK
1179 extern bool xg_set_icon (struct frame *, Lisp_Object);
1180 extern bool xg_set_icon_from_xpm_data (struct frame *, const char **);
1181 #endif /* USE_GTK */
1182
1183 extern void xic_free_xfontset (struct frame *);
1184 extern void create_frame_xic (struct frame *);
1185 extern void destroy_frame_xic (struct frame *);
1186 extern void xic_set_preeditarea (struct window *, int, int);
1187 extern void xic_set_statusarea (struct frame *);
1188 extern void xic_set_xfontset (struct frame *, const char *);
1189 extern bool x_defined_color (struct frame *, const char *, XColor *, bool);
1190 #ifdef HAVE_X_I18N
1191 extern void free_frame_xic (struct frame *);
1192 # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT
1193 extern char *xic_create_fontsetname (const char *, bool);
1194 # endif
1195 #endif
1196
1197 /* Defined in xfaces.c */
1198
1199 #ifdef USE_X_TOOLKIT
1200 extern void x_free_dpy_colors (Display *, Screen *, Colormap,
1201 unsigned long *, int);
1202 #endif /* USE_X_TOOLKIT */
1203
1204 /* Defined in xmenu.c */
1205
1206 #if defined USE_X_TOOLKIT || defined USE_GTK
1207 extern Lisp_Object xw_popup_dialog (struct frame *, Lisp_Object, Lisp_Object);
1208 #endif
1209
1210 #if defined USE_GTK || defined USE_MOTIF
1211 extern void x_menu_set_in_use (bool);
1212 #endif
1213 extern void x_menu_wait_for_event (void *data);
1214 extern void initialize_frame_menubar (struct frame *);
1215
1216 /* Defined in xsmfns.c */
1217 #ifdef HAVE_X_SM
1218 extern void x_session_initialize (struct x_display_info *dpyinfo);
1219 extern bool x_session_have_connection (void);
1220 extern void x_session_close (void);
1221 #endif
1222
1223
1224 /* Is the frame embedded into another application? */
1225
1226 #define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0)
1227
1228 #define STORE_XCHAR2B(chp, b1, b2) \
1229 ((chp)->byte1 = (b1), (chp)->byte2 = (b2))
1230
1231 #define XCHAR2B_BYTE1(chp) \
1232 ((chp)->byte1)
1233
1234 #define XCHAR2B_BYTE2(chp) \
1235 ((chp)->byte2)
1236
1237 #define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight) \
1238 ((nr).x = (rx), \
1239 (nr).y = (ry), \
1240 (nr).width = (rwidth), \
1241 (nr).height = (rheight))
1242
1243 INLINE_HEADER_END
1244
1245 #endif /* XTERM_H */