]> code.delx.au - gnu-emacs/blob - src/xterm.h
675a48443dcae439087a85c8a761eb752c61e1b6
[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 /* The frame where the mouse was last time we reported a ButtonPress event. */
366 struct frame *last_mouse_frame;
367
368 /* The frame where the mouse was last time we reported a mouse position. */
369 struct frame *last_mouse_glyph_frame;
370
371 /* The frame where the mouse was last time we reported a mouse motion. */
372 struct frame *last_mouse_motion_frame;
373
374 /* The scroll bar in which the last X motion event occurred. */
375 struct scroll_bar *last_mouse_scroll_bar;
376
377 /* Time of last user interaction as returned in X events on this display. */
378 Time last_user_time;
379
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;
384
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;
388
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;
396
397 /* The gray pixmap. */
398 Pixmap gray;
399
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
406
407 /* A cache mapping color names to RGB values. */
408 struct color_name_cache_entry *color_names;
409
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;
414
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;
418
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
426 {
427 X_WMTYPE_UNKNOWN,
428 X_WMTYPE_A,
429 X_WMTYPE_B
430 } wm_type;
431
432
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;
437
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;
446
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_hidden,
451 Xatom_net_frame_extents,
452 Xatom_net_current_desktop, Xatom_net_workarea;
453
454 /* XSettings atoms and windows. */
455 Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr;
456 Window xsettings_window;
457
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;
462
463 /* SM */
464 Atom Xatom_SM_CLIENT_ID;
465
466 #ifdef HAVE_XRANDR
467 int xrandr_major_version;
468 int xrandr_minor_version;
469 #endif
470
471 #ifdef USE_CAIRO
472 XExtCodes *ext_codes;
473 #endif
474
475 #ifdef USE_XCB
476 xcb_connection_t *xcb_connection;
477 #endif
478 };
479
480 #ifdef HAVE_X_I18N
481 /* Whether or not to use XIM if we have it. */
482 extern bool use_xim;
483 #endif
484
485 /* This is a chain of structures for all the X displays currently in use. */
486 extern struct x_display_info *x_display_list;
487
488 extern struct x_display_info *x_display_info_for_display (Display *);
489 extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
490 extern struct x_display_info *x_term_init (Lisp_Object, char *, char *);
491 extern bool x_display_ok (const char *);
492
493 extern void select_visual (struct x_display_info *);
494
495 /* Each X frame object points to its own struct x_output object
496 in the output_data.x field. The x_output structure contains
497 the information that is specific to X windows. */
498
499 struct x_output
500 {
501 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
502 /* Height of menu bar widget, in pixels. This value
503 is not meaningful if the menubar is turned off. */
504 int menubar_height;
505 #endif
506
507 /* Height of tool bar widget, in pixels. top_height is used if tool bar
508 at top, bottom_height if tool bar is at the bottom.
509 Zero if not using an external tool bar or if tool bar is vertical. */
510 int toolbar_top_height, toolbar_bottom_height;
511
512 /* Width of tool bar widget, in pixels. left_width is used if tool bar
513 at left, right_width if tool bar is at the right.
514 Zero if not using an external tool bar or if tool bar is horizontal. */
515 int toolbar_left_width, toolbar_right_width;
516
517 /* The tiled border used when the mouse is out of the frame. */
518 Pixmap border_tile;
519
520 /* Here are the Graphics Contexts for the default font. */
521 GC normal_gc; /* Normal video */
522 GC reverse_gc; /* Reverse video */
523 GC cursor_gc; /* cursor drawing */
524
525 /* The X window used for this frame.
526 May be zero while the frame object is being created
527 and the X window has not yet been created. */
528 Window window_desc;
529
530 /* The X window used for the bitmap icon;
531 or 0 if we don't have a bitmap icon. */
532 Window icon_desc;
533
534 /* The X window that is the parent of this X window.
535 Usually this is a window that was made by the window manager,
536 but it can be the root window, and it can be explicitly specified
537 (see the explicit_parent field, below). */
538 Window parent_desc;
539
540 #ifdef USE_X_TOOLKIT
541 /* The widget of this screen. This is the window of a "shell" widget. */
542 Widget widget;
543 /* The XmPanedWindows... */
544 Widget column_widget;
545 /* The widget of the edit portion of this screen; the window in
546 "window_desc" is inside of this. */
547 Widget edit_widget;
548
549 Widget menubar_widget;
550 #endif
551
552 #ifdef USE_GTK
553 /* The widget of this screen. This is the window of a top widget. */
554 GtkWidget *widget;
555 /* The widget of the edit portion of this screen; the window in
556 "window_desc" is inside of this. */
557 GtkWidget *edit_widget;
558 /* The widget used for laying out widgets vertically. */
559 GtkWidget *vbox_widget;
560 /* The widget used for laying out widgets horizontally. */
561 GtkWidget *hbox_widget;
562 /* The menubar in this frame. */
563 GtkWidget *menubar_widget;
564 /* The tool bar in this frame */
565 GtkWidget *toolbar_widget;
566 /* True if tool bar is packed into the hbox widget (i.e. vertical). */
567 bool_bf toolbar_in_hbox : 1;
568 bool_bf toolbar_is_packed : 1;
569
570 /* The last size hints set. */
571 GdkGeometry size_hints;
572 long hint_flags;
573
574 #ifdef USE_GTK_TOOLTIP
575 GtkTooltip *ttip_widget;
576 GtkWidget *ttip_lbl;
577 GtkWindow *ttip_window;
578 #endif /* USE_GTK_TOOLTIP */
579
580 #endif /* USE_GTK */
581
582 /* If >=0, a bitmap index. The indicated bitmap is used for the
583 icon. */
584 ptrdiff_t icon_bitmap;
585
586 /* Default ASCII font of this frame. */
587 struct font *font;
588
589 /* The baseline offset of the default ASCII font. */
590 int baseline_offset;
591
592 /* If a fontset is specified for this frame instead of font, this
593 value contains an ID of the fontset, else -1. */
594 int fontset;
595
596 unsigned long cursor_pixel;
597 unsigned long border_pixel;
598 unsigned long mouse_pixel;
599 unsigned long cursor_foreground_pixel;
600
601 /* Foreground color for scroll bars. A value of -1 means use the
602 default (black for non-toolkit scroll bars). */
603 unsigned long scroll_bar_foreground_pixel;
604
605 /* Background color for scroll bars. A value of -1 means use the
606 default (background color of the frame for non-toolkit scroll
607 bars). */
608 unsigned long scroll_bar_background_pixel;
609
610 #if defined (USE_LUCID) && defined (USE_TOOLKIT_SCROLL_BARS)
611 /* Top and bottom shadow colors for 3D Lucid scrollbars.
612 -1 means let the scroll compute them itself. */
613 unsigned long scroll_bar_top_shadow_pixel;
614 unsigned long scroll_bar_bottom_shadow_pixel;
615 #endif
616
617 /* Descriptor for the cursor in use for this window. */
618 Cursor text_cursor;
619 Cursor nontext_cursor;
620 Cursor modeline_cursor;
621 Cursor hand_cursor;
622 Cursor hourglass_cursor;
623 Cursor horizontal_drag_cursor;
624 Cursor vertical_drag_cursor;
625 Cursor current_cursor;
626
627 /* Window whose cursor is hourglass_cursor. This window is temporarily
628 mapped to display an hourglass cursor. */
629 Window hourglass_window;
630
631 /* These are the current window manager hints. It seems that
632 XSetWMHints, when presented with an unset bit in the `flags'
633 member of the hints structure, does not leave the corresponding
634 attribute unchanged; rather, it resets that attribute to its
635 default value. For example, unless you set the `icon_pixmap'
636 field and the `IconPixmapHint' bit, XSetWMHints will forget what
637 your icon pixmap was. This is rather troublesome, since some of
638 the members (for example, `input' and `icon_pixmap') want to stay
639 the same throughout the execution of Emacs. So, we keep this
640 structure around, just leaving values in it and adding new bits
641 to the mask as we go. */
642 XWMHints wm_hints;
643
644 /* This is the Emacs structure for the X display this frame is on. */
645 struct x_display_info *display_info;
646
647 /* This is a button event that wants to activate the menubar.
648 We save it here until the command loop gets to think about it. */
649 XEvent *saved_menu_event;
650
651 /* This is the widget id used for this frame's menubar in lwlib. */
652 #ifdef USE_X_TOOLKIT
653 int id;
654 #endif
655
656 /* True means hourglass cursor is currently displayed. */
657 bool_bf hourglass_p : 1;
658
659 /* True means our parent is another application's window
660 and was explicitly specified. */
661 bool_bf explicit_parent : 1;
662
663 /* True means tried already to make this frame visible. */
664 bool_bf asked_for_visible : 1;
665
666 /* True if this frame was ever previously visible. */
667 bool_bf has_been_visible : 1;
668
669 /* Xt waits for a ConfigureNotify event from the window manager in
670 EmacsFrameSetCharSize when the shell widget is resized. For some
671 window managers like fvwm2 2.2.5 and KDE 2.1 this event doesn't
672 arrive for an unknown reason and Emacs hangs in Xt. If this is
673 false, tell Xt not to wait. */
674 bool_bf wait_for_wm : 1;
675
676 #ifdef HAVE_X_I18N
677 /* Input context (currently, this means Compose key handler setup). */
678 XIC xic;
679 XIMStyle xic_style;
680 XFontSet xic_xfs;
681 #endif
682
683 /* Relief GCs, colors etc. */
684 struct relief
685 {
686 GC gc;
687 unsigned long pixel;
688 }
689 black_relief, white_relief;
690
691 /* The background for which the above relief GCs were set up.
692 They are changed only when a different background is involved. */
693 unsigned long relief_background;
694
695 /* Keep track of focus. May be EXPLICIT if we received a FocusIn for this
696 frame, or IMPLICIT if we received an EnterNotify.
697 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
698 int focus_state;
699
700 /* The offset we need to add to compensate for type A WMs. */
701 int move_offset_top;
702 int move_offset_left;
703
704 /* Extreme 'short' and 'long' values suitable for libX11. */
705 #define X_SHRT_MAX 0x7fff
706 #define X_SHRT_MIN (-1 - X_SHRT_MAX)
707 #define X_LONG_MAX 0x7fffffff
708 #define X_LONG_MIN (-1 - X_LONG_MAX)
709 #define X_ULONG_MAX 0xffffffffUL
710
711 #ifdef USE_CAIRO
712 /* Cairo drawing context. */
713 cairo_t *cr_context;
714 /* Cairo surface for double buffering */
715 cairo_surface_t *cr_surface;
716 #endif
717 };
718
719 #define No_Cursor (None)
720
721 enum
722 {
723 /* Values for focus_state, used as bit mask.
724 EXPLICIT means we received a FocusIn for the frame and know it has
725 the focus. IMPLICIT means we received an EnterNotify and the frame
726 may have the focus if no window manager is running.
727 FocusOut and LeaveNotify clears EXPLICIT/IMPLICIT. */
728 FOCUS_NONE = 0,
729 FOCUS_IMPLICIT = 1,
730 FOCUS_EXPLICIT = 2
731 };
732
733
734 /* Return the X output data for frame F. */
735 #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
736
737 /* Return the X window used for displaying data in frame F. */
738 #define FRAME_X_WINDOW(f) ((f)->output_data.x->window_desc)
739
740 /* Return the outermost X window associated with the frame F. */
741 #ifdef USE_X_TOOLKIT
742 #define FRAME_OUTER_WINDOW(f) ((f)->output_data.x->widget ? \
743 XtWindow ((f)->output_data.x->widget) : \
744 FRAME_X_WINDOW (f))
745 #else
746 #ifdef USE_GTK
747 /* Functions not present in older Gtk+ */
748
749 #ifndef HAVE_GTK_WIDGET_GET_WINDOW
750 #define gtk_widget_get_window(w) ((w)->window)
751 #endif
752 #ifndef HAVE_GTK_WIDGET_GET_MAPPED
753 #define gtk_widget_get_mapped(w) (GTK_WIDGET_MAPPED (w))
754 #endif
755 #ifndef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE
756 #define gtk_adjustment_get_page_size(w) ((w)->page_size)
757 #define gtk_adjustment_get_upper(w) ((w)->upper)
758 #endif
759
760 #ifdef HAVE_GTK3
761 #define DEFAULT_GDK_DISPLAY() \
762 gdk_x11_display_get_xdisplay (gdk_display_get_default ())
763 #else
764 #undef GDK_WINDOW_XID
765 #define GDK_WINDOW_XID(w) GDK_WINDOW_XWINDOW (w)
766 #define DEFAULT_GDK_DISPLAY() GDK_DISPLAY ()
767 #define gtk_widget_get_preferred_size(a, ign, b) \
768 gtk_widget_size_request (a, b)
769 #endif
770
771 #define GTK_WIDGET_TO_X_WIN(w) \
772 ((w) && gtk_widget_get_window (w) \
773 ? GDK_WINDOW_XID (gtk_widget_get_window (w)) : 0)
774
775 #define FRAME_GTK_OUTER_WIDGET(f) ((f)->output_data.x->widget)
776 #define FRAME_GTK_WIDGET(f) ((f)->output_data.x->edit_widget)
777 #define FRAME_OUTER_WINDOW(f) \
778 (FRAME_GTK_OUTER_WIDGET (f) ? \
779 GTK_WIDGET_TO_X_WIN (FRAME_GTK_OUTER_WIDGET (f)) : \
780 FRAME_X_WINDOW (f))
781
782 #else /* !USE_GTK */
783 #define FRAME_OUTER_WINDOW(f) (FRAME_X_WINDOW (f))
784 #endif /* !USE_GTK */
785 #endif
786
787 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
788 #define FRAME_MENUBAR_HEIGHT(f) ((f)->output_data.x->menubar_height)
789 #else
790 #define FRAME_MENUBAR_HEIGHT(f) ((void) f, 0)
791 #endif /* USE_X_TOOLKIT || USE_GTK */
792
793 #define FRAME_FONT(f) ((f)->output_data.x->font)
794 #define FRAME_FONTSET(f) ((f)->output_data.x->fontset)
795 #define FRAME_TOOLBAR_TOP_HEIGHT(f) ((f)->output_data.x->toolbar_top_height)
796 #define FRAME_TOOLBAR_BOTTOM_HEIGHT(f) \
797 ((f)->output_data.x->toolbar_bottom_height)
798 #define FRAME_TOOLBAR_HEIGHT(f) \
799 (FRAME_TOOLBAR_TOP_HEIGHT (f) + FRAME_TOOLBAR_BOTTOM_HEIGHT (f))
800 #define FRAME_TOOLBAR_LEFT_WIDTH(f) ((f)->output_data.x->toolbar_left_width)
801 #define FRAME_TOOLBAR_RIGHT_WIDTH(f) ((f)->output_data.x->toolbar_right_width)
802 #define FRAME_TOOLBAR_WIDTH(f) \
803 (FRAME_TOOLBAR_LEFT_WIDTH (f) + FRAME_TOOLBAR_RIGHT_WIDTH (f))
804 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.x->baseline_offset)
805
806 /* This gives the x_display_info structure for the display F is on. */
807 #define FRAME_DISPLAY_INFO(f) ((f)->output_data.x->display_info)
808
809 /* This is the `Display *' which frame F is on. */
810 #define FRAME_X_DISPLAY(f) (FRAME_DISPLAY_INFO (f)->display)
811
812 /* This is the `Screen *' which frame F is on. */
813 #define FRAME_X_SCREEN(f) (FRAME_DISPLAY_INFO (f)->screen)
814
815 /* This is the screen index number of screen which frame F is on. */
816 #define FRAME_X_SCREEN_NUMBER(f) XScreenNumberOfScreen (FRAME_X_SCREEN (f))
817
818 /* This is the Visual which frame F is on. */
819 #define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO (f)->visual
820
821 /* This is the Colormap which frame F uses. */
822 #define FRAME_X_COLORMAP(f) FRAME_DISPLAY_INFO (f)->cmap
823
824 #define FRAME_XIC(f) ((f)->output_data.x->xic)
825 #define FRAME_X_XIM(f) (FRAME_DISPLAY_INFO (f)->xim)
826 #define FRAME_X_XIM_STYLES(f) (FRAME_DISPLAY_INFO (f)->xim_styles)
827 #define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style)
828 #define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs)
829
830 /* X-specific scroll bar stuff. */
831
832 /* We represent scroll bars as lisp vectors. This allows us to place
833 references to them in windows without worrying about whether we'll
834 end up with windows referring to dead scroll bars; the garbage
835 collector will free it when its time comes.
836
837 We use struct scroll_bar as a template for accessing fields of the
838 vector. */
839
840 struct scroll_bar
841 {
842 /* These fields are shared by all vectors. */
843 struct vectorlike_header header;
844
845 /* The window we're a scroll bar for. */
846 Lisp_Object window;
847
848 /* The next and previous in the chain of scroll bars in this frame. */
849 Lisp_Object next, prev;
850
851 /* Fields from `x_window' down will not be traced by the GC. */
852
853 /* The X window representing this scroll bar. */
854 Window x_window;
855
856 /* The position and size of the scroll bar in pixels, relative to the
857 frame. */
858 int top, left, width, height;
859
860 /* The starting and ending positions of the handle, relative to the
861 handle area (i.e. zero is the top position, not
862 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
863 hasn't been drawn yet.
864
865 These are not actually the locations where the beginning and end
866 are drawn; in order to keep handles from becoming invisible when
867 editing large files, we establish a minimum height by always
868 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
869 where they would be normally; the bottom and top are in a
870 different co-ordinate system. */
871 int start, end;
872
873 /* If the scroll bar handle is currently being dragged by the user,
874 this is the number of pixels from the top of the handle to the
875 place where the user grabbed it. If the handle isn't currently
876 being dragged, this is -1. */
877 int dragging;
878
879 #if defined (USE_TOOLKIT_SCROLL_BARS) && defined (USE_LUCID)
880 /* Last scroll bar part seen in xaw_jump_callback and xaw_scroll_callback. */
881 enum scroll_bar_part last_seen_part;
882 #endif
883
884 #if defined (USE_TOOLKIT_SCROLL_BARS) && !defined (USE_GTK)
885 /* Last value of whole for horizontal scrollbars. */
886 int whole;
887 #endif
888
889 /* True if the scroll bar is horizontal. */
890 bool horizontal;
891 };
892
893 /* Turning a lisp vector value into a pointer to a struct scroll_bar. */
894 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
895
896 #ifdef USE_X_TOOLKIT
897
898 /* Extract the X widget of the scroll bar from a struct scroll_bar.
899 XtWindowToWidget should be fast enough since Xt uses a hash table
900 to map windows to widgets. */
901
902 #define SCROLL_BAR_X_WIDGET(dpy, ptr) \
903 XtWindowToWidget (dpy, ptr->x_window)
904
905 /* Store a widget id in a struct scroll_bar. */
906
907 #define SET_SCROLL_BAR_X_WIDGET(ptr, w) \
908 do { \
909 Window window = XtWindow (w); \
910 ptr->x_window = window; \
911 } while (false)
912
913 #endif /* USE_X_TOOLKIT */
914
915 /* Return the inside width of a vertical scroll bar, given the outside
916 width. */
917 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
918 ((width) \
919 - VERTICAL_SCROLL_BAR_LEFT_BORDER \
920 - VERTICAL_SCROLL_BAR_RIGHT_BORDER)
921
922 /* Return the length of the rectangle within which the top of the
923 handle must stay. This isn't equivalent to the inside height,
924 because the scroll bar handle has a minimum height.
925
926 This is the real range of motion for the scroll bar, so when we're
927 scaling buffer positions to scroll bar positions, we use this, not
928 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
929 #define VERTICAL_SCROLL_BAR_TOP_RANGE(f, height) \
930 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
931
932 /* Return the inside height of vertical scroll bar, given the outside
933 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
934 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f, height) \
935 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
936
937 /* Return the inside height of a horizontal scroll bar, given the outside
938 height. */
939 #define HORIZONTAL_SCROLL_BAR_INSIDE_HEIGHT(f, height) \
940 ((height) \
941 - HORIZONTAL_SCROLL_BAR_TOP_BORDER \
942 - HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER)
943
944 /* Return the length of the rectangle within which the left part of the
945 handle must stay. This isn't equivalent to the inside width, because
946 the scroll bar handle has a minimum width.
947
948 This is the real range of motion for the scroll bar, so when we're
949 scaling buffer positions to scroll bar positions, we use this, not
950 HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH. */
951 #define HORIZONTAL_SCROLL_BAR_LEFT_RANGE(f, width) \
952 (HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH (f, width) - HORIZONTAL_SCROLL_BAR_MIN_HANDLE)
953
954 /* Return the inside width of horizontal scroll bar, given the outside
955 width. See HORIZONTAL_SCROLL_BAR_LEFT_RANGE too. */
956 #define HORIZONTAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
957 ((width) - HORIZONTAL_SCROLL_BAR_LEFT_BORDER - HORIZONTAL_SCROLL_BAR_LEFT_BORDER)
958
959
960 /* Border widths for scroll bars.
961
962 Scroll bar windows don't have any X borders; their border width is
963 set to zero, and we redraw borders ourselves. This makes the code
964 a bit cleaner, since we don't have to convert between outside width
965 (used when relating to the rest of the screen) and inside width
966 (used when sizing and drawing the scroll bar window itself).
967
968 The handle moves up and down/back and forth in a rectangle inset
969 from the edges of the scroll bar. These are widths by which we
970 inset the handle boundaries from the scroll bar edges. */
971 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (2)
972 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (2)
973 #define VERTICAL_SCROLL_BAR_TOP_BORDER (2)
974 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (2)
975
976 #define HORIZONTAL_SCROLL_BAR_LEFT_BORDER (2)
977 #define HORIZONTAL_SCROLL_BAR_RIGHT_BORDER (2)
978 #define HORIZONTAL_SCROLL_BAR_TOP_BORDER (2)
979 #define HORIZONTAL_SCROLL_BAR_BOTTOM_BORDER (2)
980
981 /* Minimum lengths for scroll bar handles, in pixels. */
982 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (5)
983 #define HORIZONTAL_SCROLL_BAR_MIN_HANDLE (5)
984
985 /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT
986 or SELECTION_CLEAR_EVENT, then its contents are really described
987 by this structure. */
988
989 /* For an event of kind SELECTION_REQUEST_EVENT,
990 this structure really describes the contents. */
991
992 struct selection_input_event
993 {
994 ENUM_BF (event_kind) kind : EVENT_KIND_WIDTH;
995 struct x_display_info *dpyinfo;
996 /* We spell it with an "o" here because X does. */
997 Window requestor;
998 Atom selection, target, property;
999 Time time;
1000 };
1001
1002 /* Unlike macros below, this can't be used as an lvalue. */
1003 INLINE Display *
1004 SELECTION_EVENT_DISPLAY (struct selection_input_event *ev)
1005 {
1006 return ev->dpyinfo->display;
1007 }
1008 #define SELECTION_EVENT_DPYINFO(eventp) \
1009 ((eventp)->dpyinfo)
1010 /* We spell it with an "o" here because X does. */
1011 #define SELECTION_EVENT_REQUESTOR(eventp) \
1012 ((eventp)->requestor)
1013 #define SELECTION_EVENT_SELECTION(eventp) \
1014 ((eventp)->selection)
1015 #define SELECTION_EVENT_TARGET(eventp) \
1016 ((eventp)->target)
1017 #define SELECTION_EVENT_PROPERTY(eventp) \
1018 ((eventp)->property)
1019 #define SELECTION_EVENT_TIME(eventp) \
1020 ((eventp)->time)
1021
1022 /* From xfns.c. */
1023
1024 extern void x_free_gcs (struct frame *);
1025 extern void x_relative_mouse_position (struct frame *, int *, int *);
1026 extern void x_real_pos_and_offsets (struct frame *f,
1027 int *left_offset_x,
1028 int *right_offset_x,
1029 int *top_offset_y,
1030 int *bottom_offset_y,
1031 int *x_pixels_diff,
1032 int *y_pixels_diff,
1033 int *xptr,
1034 int *yptr,
1035 int *outer_border);
1036
1037 /* From xrdb.c. */
1038
1039 XrmDatabase x_load_resources (Display *, const char *, const char *,
1040 const char *);
1041
1042 /* Defined in xterm.c */
1043
1044 typedef void (*x_special_error_handler)(Display *, XErrorEvent *, char *,
1045 void *);
1046
1047 extern bool x_text_icon (struct frame *, const char *);
1048 extern void x_catch_errors (Display *);
1049 extern void x_catch_errors_with_handler (Display *, x_special_error_handler,
1050 void *);
1051 extern void x_check_errors (Display *, const char *)
1052 ATTRIBUTE_FORMAT_PRINTF (2, 0);
1053 extern bool x_had_errors_p (Display *);
1054 extern void x_uncatch_errors (void);
1055 extern void x_uncatch_errors_after_check (void);
1056 extern void x_clear_errors (Display *);
1057 extern void xembed_request_focus (struct frame *);
1058 extern void x_ewmh_activate_frame (struct frame *);
1059 extern void x_delete_terminal (struct terminal *terminal);
1060 extern unsigned long x_copy_color (struct frame *, unsigned long);
1061 #ifdef USE_X_TOOLKIT
1062 extern XtAppContext Xt_app_con;
1063 extern void x_activate_timeout_atimer (void);
1064 #endif
1065 #ifdef USE_LUCID
1066 extern bool x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
1067 unsigned long *,
1068 double, int);
1069 #endif
1070 extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *);
1071 extern void x_query_color (struct frame *f, XColor *);
1072 extern void x_clear_area (struct frame *f, int, int, int, int);
1073 #if !defined USE_X_TOOLKIT && !defined USE_GTK
1074 extern void x_mouse_leave (struct x_display_info *);
1075 #endif
1076
1077 #if defined USE_X_TOOLKIT || defined USE_MOTIF
1078 extern int x_dispatch_event (XEvent *, Display *);
1079 #endif
1080 extern int x_x_to_emacs_modifiers (struct x_display_info *, int);
1081 #ifdef USE_CAIRO
1082 extern cairo_t *x_begin_cr_clip (struct frame *, GC);
1083 extern void x_end_cr_clip (struct frame *);
1084 extern void x_set_cr_source_with_gc_foreground (struct frame *, GC);
1085 extern void x_set_cr_source_with_gc_background (struct frame *, GC);
1086 extern void x_cr_draw_frame (cairo_t *, struct frame *);
1087 extern Lisp_Object x_cr_export_frames (Lisp_Object, cairo_surface_type_t);
1088 #endif
1089
1090 INLINE int
1091 x_display_pixel_height (struct x_display_info *dpyinfo)
1092 {
1093 return HeightOfScreen (dpyinfo->screen);
1094 }
1095
1096 INLINE int
1097 x_display_pixel_width (struct x_display_info *dpyinfo)
1098 {
1099 return WidthOfScreen (dpyinfo->screen);
1100 }
1101
1102 INLINE void
1103 x_display_set_last_user_time (struct x_display_info *dpyinfo, Time t)
1104 {
1105 #ifdef ENABLE_CHECKING
1106 eassert (t <= X_ULONG_MAX);
1107 #endif
1108 dpyinfo->last_user_time = t;
1109 }
1110
1111 INLINE unsigned long
1112 x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b)
1113 {
1114 unsigned long pr, pg, pb;
1115
1116 /* Scale down RGB values to the visual's bits per RGB, and shift
1117 them to the right position in the pixel color. Note that the
1118 original RGB values are 16-bit values, as usual in X. */
1119 pr = (r >> (16 - dpyinfo->red_bits)) << dpyinfo->red_offset;
1120 pg = (g >> (16 - dpyinfo->green_bits)) << dpyinfo->green_offset;
1121 pb = (b >> (16 - dpyinfo->blue_bits)) << dpyinfo->blue_offset;
1122
1123 /* Assemble the pixel color. */
1124 return pr | pg | pb;
1125 }
1126
1127 /* If display has an immutable color map, freeing colors is not
1128 necessary and some servers don't allow it, so we won't do it. That
1129 also allows us to make other optimizations relating to server-side
1130 reference counts. */
1131 INLINE bool
1132 x_mutable_colormap (Visual *visual)
1133 {
1134 int class = visual->class;
1135 return (class != StaticColor && class != StaticGray && class != TrueColor);
1136 }
1137
1138 extern void x_set_sticky (struct frame *, Lisp_Object, Lisp_Object);
1139 extern bool x_wm_supports (struct frame *, Atom);
1140 extern void x_wait_for_event (struct frame *, int);
1141 extern void x_clear_under_internal_border (struct frame *f);
1142
1143 /* Defined in xselect.c. */
1144
1145 extern void x_handle_property_notify (const XPropertyEvent *);
1146 extern void x_handle_selection_notify (const XSelectionEvent *);
1147 extern void x_handle_selection_event (struct selection_input_event *);
1148 extern void x_clear_frame_selections (struct frame *);
1149
1150 extern void x_send_client_event (Lisp_Object display,
1151 Lisp_Object dest,
1152 Lisp_Object from,
1153 Atom message_type,
1154 Lisp_Object format,
1155 Lisp_Object values);
1156
1157 extern bool x_handle_dnd_message (struct frame *,
1158 const XClientMessageEvent *,
1159 struct x_display_info *,
1160 struct input_event *);
1161 extern int x_check_property_data (Lisp_Object);
1162 extern void x_fill_property_data (Display *,
1163 Lisp_Object,
1164 void *,
1165 int);
1166 extern Lisp_Object x_property_data_to_lisp (struct frame *,
1167 const unsigned char *,
1168 Atom,
1169 int,
1170 unsigned long);
1171 extern void x_clipboard_manager_save_frame (Lisp_Object);
1172 extern void x_clipboard_manager_save_all (void);
1173
1174 #ifdef USE_GTK
1175 extern bool xg_set_icon (struct frame *, Lisp_Object);
1176 extern bool xg_set_icon_from_xpm_data (struct frame *, const char **);
1177 #endif /* USE_GTK */
1178
1179 extern void xic_free_xfontset (struct frame *);
1180 extern void create_frame_xic (struct frame *);
1181 extern void destroy_frame_xic (struct frame *);
1182 extern void xic_set_preeditarea (struct window *, int, int);
1183 extern void xic_set_statusarea (struct frame *);
1184 extern void xic_set_xfontset (struct frame *, const char *);
1185 extern bool x_defined_color (struct frame *, const char *, XColor *, bool);
1186 #ifdef HAVE_X_I18N
1187 extern void free_frame_xic (struct frame *);
1188 # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT
1189 extern char *xic_create_fontsetname (const char *, bool);
1190 # endif
1191 #endif
1192
1193 /* Defined in xfaces.c */
1194
1195 #ifdef USE_X_TOOLKIT
1196 extern void x_free_dpy_colors (Display *, Screen *, Colormap,
1197 unsigned long *, int);
1198 #endif /* USE_X_TOOLKIT */
1199
1200 /* Defined in xmenu.c */
1201
1202 #if defined USE_X_TOOLKIT || defined USE_GTK
1203 extern Lisp_Object xw_popup_dialog (struct frame *, Lisp_Object, Lisp_Object);
1204 #endif
1205
1206 #if defined USE_GTK || defined USE_MOTIF
1207 extern void x_menu_set_in_use (bool);
1208 #endif
1209 extern void x_menu_wait_for_event (void *data);
1210 extern void initialize_frame_menubar (struct frame *);
1211
1212 /* Defined in xsmfns.c */
1213 #ifdef HAVE_X_SM
1214 extern void x_session_initialize (struct x_display_info *dpyinfo);
1215 extern bool x_session_have_connection (void);
1216 extern void x_session_close (void);
1217 #endif
1218
1219
1220 /* Is the frame embedded into another application? */
1221
1222 #define FRAME_X_EMBEDDED_P(f) (FRAME_X_OUTPUT(f)->explicit_parent != 0)
1223
1224 #define STORE_XCHAR2B(chp, b1, b2) \
1225 ((chp)->byte1 = (b1), (chp)->byte2 = (b2))
1226
1227 #define XCHAR2B_BYTE1(chp) \
1228 ((chp)->byte1)
1229
1230 #define XCHAR2B_BYTE2(chp) \
1231 ((chp)->byte2)
1232
1233 #define STORE_NATIVE_RECT(nr,rx,ry,rwidth,rheight) \
1234 ((nr).x = (rx), \
1235 (nr).y = (ry), \
1236 (nr).width = (rwidth), \
1237 (nr).height = (rheight))
1238
1239 INLINE_HEADER_END
1240
1241 #endif /* XTERM_H */