1 /* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989, 1993, 1994 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #include <X11/cursorfont.h>
23 #include <X11/Xutil.h>
24 #include <X11/keysym.h>
25 #include <X11/Xatom.h>
26 #include <X11/Xresource.h>
29 #include <X11/StringDefs.h>
30 #include <X11/IntrinsicP.h> /* CoreP.h needs this */
31 #include <X11/CoreP.h> /* foul, but we need this to use our own
32 window inside a widget instead of one
34 #include <X11/StringDefs.h>
37 /* The class of this X application. */
38 #define EMACS_CLASS "Emacs"
40 /* Bookkeeping to distinguish X versions. */
42 /* HAVE_X11R4 is defined if we have the features of X11R4. It should
43 be defined when we're using X11R5, since X11R5 has the features of
44 X11R4. If, in the future, we find we need more of these flags
45 (HAVE_X11R5, for example), code should always be written to test
46 the most recent flag first:
56 If you ever find yourself writing a "#ifdef HAVE_FOO" clause that
57 looks a lot like another one, consider moving the text into a macro
58 whose definition is configuration-dependent, but whose usage is
59 universal - like the stuff in systime.h.
61 It turns out that we can auto-detect whether we're being compiled
62 with X11R3 or X11R4 by looking for the flag macros for R4 structure
63 members that R3 doesn't have. */
65 /* AIX 3.1's X is somewhere between X11R3 and X11R4. It has
66 PBaseSize, but not XWithdrawWindow, XSetWMName, XSetWMNormalHints,
68 AIX 3.2 is at least X11R4. */
69 #if (!defined AIX) || (defined AIX3_2)
75 /* In case someone has X11R5 on AIX 3.1,
76 make sure HAVE_X11R4 is defined as well as HAVE_X11R5. */
82 #include <X11/Xlocale.h>
85 #define BLACK_PIX_DEFAULT(f) BlackPixel (FRAME_X_DISPLAY (f), \
86 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))
87 #define WHITE_PIX_DEFAULT(f) WhitePixel (FRAME_X_DISPLAY (f), \
88 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))
90 #define FONT_WIDTH(f) ((f)->max_bounds.width)
91 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
92 #define FONT_BASE(f) ((f)->ascent)
94 /* The mask of events that text windows always want to receive. This
95 includes mouse movement events, since handling the mouse-font text property
96 means that we must track mouse motion all the time. */
98 #define STANDARD_EVENT_SET \
102 | ButtonReleaseMask \
103 | PointerMotionMask \
104 | StructureNotifyMask \
108 | VisibilityChangeMask)
110 /* This checks to make sure we have a display. */
111 extern void check_x ();
113 extern struct frame
*x_window_to_frame ();
116 extern struct frame
*x_any_window_to_frame ();
117 extern struct frame
*x_non_menubar_window_to_frame ();
118 extern struct frame
*x_top_window_to_frame ();
121 extern Visual
*select_visual ();
123 enum text_cursor_kinds
{
124 filled_box_cursor
, hollow_box_cursor
, bar_cursor
127 /* Structure recording X pixmap and reference count.
128 If REFCOUNT is 0 then this record is free to be reused. */
130 struct x_bitmap_record
135 /* Record some info about this pixmap. */
136 int height
, width
, depth
;
139 /* For each X display, we have a structure that records
140 information about it. */
142 struct x_display_info
144 /* Chain of all x_display_info structures. */
145 struct x_display_info
*next
;
146 /* Connection number (normally a file descriptor number). */
148 /* This says how to access this display in Xlib. */
150 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
151 The same cons cell also appears in x_display_name_list. */
152 Lisp_Object name_list_element
;
153 /* Number of frames that are on this display. */
155 /* The Screen this connection is connected to. */
157 /* The Visual being used for this display. */
159 /* Number of panes on this screen. */
161 /* Dimensions of this screen. */
163 /* Mask of things that cause the mouse to be grabbed. */
165 /* Emacs bitmap-id of the default icon bitmap for this frame.
166 Or -1 if none has been allocated yet. */
168 /* The root window of this screen. */
170 /* The cursor to use for vertical scroll bars. */
171 Cursor vertical_scroll_bar_cursor
;
172 /* X Resource data base */
175 /* A table of all the fonts we have already loaded. */
176 struct font_info
*font_table
;
178 /* The current capacity of x_font_table. */
181 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
182 GC scratch_cursor_gc
;
184 /* These variables describe the range of text currently shown
185 in its mouse-face, together with the window they apply to.
186 As long as the mouse stays within this range, we need not
187 redraw anything on its account. */
188 int mouse_face_beg_row
, mouse_face_beg_col
;
189 int mouse_face_end_row
, mouse_face_end_col
;
190 int mouse_face_past_end
;
191 Lisp_Object mouse_face_window
;
192 int mouse_face_face_id
;
194 /* 1 if a mouse motion event came and we didn't handle it right away because
195 gc was in progress. */
196 int mouse_face_deferred_gc
;
198 /* FRAME and X, Y position of mouse when last checked for
199 highlighting. X and Y can be negative or out of range for the frame. */
200 struct frame
*mouse_face_mouse_frame
;
201 int mouse_face_mouse_x
, mouse_face_mouse_y
;
203 /* Nonzero means defer mouse-motion highlighting. */
204 int mouse_face_defer
;
208 /* The number of fonts actually stored in x_font_table.
209 font_table[n] is used and valid iff 0 <= n < n_fonts.
210 0 <= n_fonts <= font_table_size. */
213 /* Pointer to bitmap records. */
214 struct x_bitmap_record
*bitmaps
;
216 /* Allocated size of bitmaps field. */
219 /* Last used bitmap index. */
222 /* Which modifier keys are on which modifier bits?
224 With each keystroke, X returns eight bits indicating which modifier
225 keys were held down when the key was pressed. The interpretation
226 of the top five modifier bits depends on what keys are attached
227 to them. If the Meta_L and Meta_R keysyms are on mod5, then mod5
230 meta_mod_mask is a mask containing the bits used for the meta key.
231 It may have more than one bit set, if more than one modifier bit
232 has meta keys on it. Basically, if EVENT is a KeyPress event,
233 the meta key is pressed if (EVENT.state & meta_mod_mask) != 0.
235 shift_lock_mask is LockMask if the XK_Shift_Lock keysym is on the
236 lock modifier bit, or zero otherwise. Non-alphabetic keys should
237 only be affected by the lock modifier bit if XK_Shift_Lock is in
238 use; XK_Caps_Lock should only affect alphabetic keys. With this
239 arrangement, the lock modifier should shift the character if
240 (EVENT.state & shift_lock_mask) != 0. */
241 int meta_mod_mask
, shift_lock_mask
;
243 /* These are like meta_mod_mask, but for different modifiers. */
244 int alt_mod_mask
, super_mod_mask
, hyper_mod_mask
;
246 /* Communication with window managers. */
247 Atom Xatom_wm_protocols
;
248 /* Kinds of protocol things we may receive. */
249 Atom Xatom_wm_take_focus
;
250 Atom Xatom_wm_save_yourself
;
251 Atom Xatom_wm_delete_window
;
252 /* Atom for indicating window state to the window manager. */
253 Atom Xatom_wm_change_state
;
254 /* Other WM communication */
255 Atom Xatom_wm_configure_denied
; /* When our config request is denied */
256 Atom Xatom_wm_window_moved
; /* When the WM moves us. */
257 /* EditRes protocol */
260 /* More atoms, which are selection types. */
261 Atom Xatom_CLIPBOARD
, Xatom_TIMESTAMP
, Xatom_TEXT
, Xatom_DELETE
,
263 Xatom_MULTIPLE
, Xatom_INCR
, Xatom_EMACS_TMP
, Xatom_TARGETS
, Xatom_NULL
,
266 /* More atoms for font properties. The last three are private
267 properties, see the comments in src/fontset.h. */
268 Atom Xatom_PIXEL_SIZE
,
269 Xatom_MULE_BASELINE_OFFSET
, Xatom_MULE_RELATIVE_COMPOSE
,
270 Xatom_MULE_DEFAULT_ASCENT
;
273 struct kboard
*kboard
;
275 int cut_buffers_initialized
; /* Whether we're sure they all exist */
277 /* The frame (if any) which has the X window that has keyboard focus.
278 Zero if none. This is examined by Ffocus_frame in xfns.c. Note
279 that a mere EnterNotify event can set this; if you need to know the
280 last frame specified in a FocusIn or FocusOut event, use
281 x_focus_event_frame. */
282 struct frame
*x_focus_frame
;
284 /* The last frame mentioned in a FocusIn or FocusOut event. This is
285 separate from x_focus_frame, because whether or not LeaveNotify
286 events cause us to lose focus depends on whether or not we have
287 received a FocusIn event for it. */
288 struct frame
*x_focus_event_frame
;
290 /* The frame which currently has the visual highlight, and should get
291 keyboard input (other sorts of input have the frame encoded in the
292 event). It points to the X focus frame's selected window's
293 frame. It differs from x_focus_frame when we're using a global
295 struct frame
*x_highlight_frame
;
297 /* The null pixel used for filling a character background with
298 background color of a gc. */
302 /* This is a chain of structures for all the X displays currently in use. */
303 extern struct x_display_info
*x_display_list
;
305 /* This is a list of cons cells, each of the form (NAME . FONT-LIST-CACHE),
306 one for each element of x_display_list and in the same order.
307 NAME is the name of the frame.
308 FONT-LIST-CACHE records previous values returned by x-list-fonts. */
309 extern Lisp_Object x_display_name_list
;
311 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
312 extern Lisp_Object Vx_pixel_size_width_font_regexp
;
314 extern struct x_display_info
*x_display_info_for_display ();
315 extern struct x_display_info
*x_display_info_for_name ();
317 extern struct x_display_info
*x_term_init ();
319 extern Lisp_Object
x_list_fonts ();
320 extern struct font_info
*x_get_font_info(), *x_load_font (), *x_query_font ();
321 extern void x_find_ccl_program();
323 /* Each X frame object points to its own struct x_output object
324 in the output_data.x field. The x_output structure contains
325 the information that is specific to X windows. */
329 /* Position of the X window (x and y offsets in root window). */
333 /* Border width of the X window as known by the X window system. */
336 /* Size of the X window in pixels. */
337 int pixel_height
, pixel_width
;
339 /* Height of menu bar widget, in pixels.
340 Zero if not using the X toolkit.
341 When using the toolkit, this value is not meaningful
342 if the menubar is turned off. */
345 /* Height of a line, in pixels. */
348 /* The tiled border used when the mouse is out of the frame. */
351 /* Here are the Graphics Contexts for the default font. */
352 GC normal_gc
; /* Normal video */
353 GC reverse_gc
; /* Reverse video */
354 GC cursor_gc
; /* cursor drawing */
356 /* Width of the internal border. This is a line of background color
357 just inside the window's border. When the frame is selected,
358 a highlighting is displayed inside the internal border. */
359 int internal_border_width
;
361 /* The X window used for this frame.
362 May be zero while the frame object is being created
363 and the X window has not yet been created. */
366 /* The X window used for the bitmap icon;
367 or 0 if we don't have a bitmap icon. */
370 /* The X window that is the parent of this X window.
371 Usually this is a window that was made by the window manager,
372 but it can be the root window, and it can be explicitly specified
373 (see the explicit_parent field, below). */
377 /* The widget of this screen. This is the window of a "shell" widget. */
379 /* The XmPanedWindows... */
380 Widget column_widget
;
381 /* The widget of the edit portion of this screen; the window in
382 "window_desc" is inside of this. */
385 Widget menubar_widget
;
388 /* If >=0, a bitmap index. The indicated bitmap is used for the
392 /* Default ASCII font of this frame. */
395 /* The baseline position of the default ASCII font. */
398 /* If a fontset is specified for this frame instead of font, this
399 value contains an ID of the fontset, else -1. */
402 /* Pixel values used for various purposes.
403 border_pixel may be -1 meaning use a gray tile. */
404 unsigned long background_pixel
;
405 unsigned long foreground_pixel
;
406 unsigned long cursor_pixel
;
407 unsigned long border_pixel
;
408 unsigned long mouse_pixel
;
409 unsigned long cursor_foreground_pixel
;
411 /* Descriptor for the cursor in use for this window. */
413 Cursor nontext_cursor
;
414 Cursor modeline_cursor
;
417 /* Flag to set when the X window needs to be completely repainted. */
420 /* What kind of text cursor is drawn in this window right now?
421 (If there is no cursor (phys_cursor_x < 0), then this means nothing.) */
422 enum text_cursor_kinds current_cursor
;
424 /* What kind of text cursor should we draw in the future?
425 This should always be filled_box_cursor or bar_cursor. */
426 enum text_cursor_kinds desired_cursor
;
428 /* Width of bar cursor (if we are using that). */
431 /* These are the current window manager hints. It seems that
432 XSetWMHints, when presented with an unset bit in the `flags'
433 member of the hints structure, does not leave the corresponding
434 attribute unchanged; rather, it resets that attribute to its
435 default value. For example, unless you set the `icon_pixmap'
436 field and the `IconPixmapHint' bit, XSetWMHints will forget what
437 your icon pixmap was. This is rather troublesome, since some of
438 the members (for example, `input' and `icon_pixmap') want to stay
439 the same throughout the execution of Emacs. So, we keep this
440 structure around, just leaving values in it and adding new bits
441 to the mask as we go. */
444 /* The size of the extra width currently allotted for vertical
445 scroll bars, in pixels. */
446 int vertical_scroll_bar_extra
;
448 /* Table of parameter faces for this frame. Any X resources (pixel
449 values, fonts) referred to here have been allocated explicitly
450 for this face, and should be freed if we change the face. */
451 struct face
**param_faces
;
454 /* Table of computed faces for this frame. These are the faces
455 whose indexes go into the upper bits of a glyph, computed by
456 combining the parameter faces specified by overlays, text
457 properties, and what have you. The X resources mentioned here
458 are all shared with parameter faces. */
459 struct face
**computed_faces
;
460 int n_computed_faces
; /* How many are valid */
461 int size_computed_faces
; /* How many are allocated */
463 /* This is the gravity value for the specified window position. */
466 /* The geometry flags for this window. */
469 /* This is the Emacs structure for the X display this frame is on. */
470 struct x_display_info
*display_info
;
472 /* This is a button event that wants to activate the menubar.
473 We save it here until the command loop gets to think about it. */
474 XEvent
*saved_menu_event
;
476 /* This is the widget id used for this frame's menubar in lwlib. */
481 /* Nonzero means our parent is another application's window
482 and was explicitly specified. */
483 char explicit_parent
;
485 /* Nonzero means tried already to make this frame visible. */
486 char asked_for_visible
;
488 /* Nonzero if this frame was ever previously visible. */
489 char has_been_visible
;
494 /* Input context (currently, this means Compose key handler setup). */
499 /* Get at the computed faces of an X window frame. */
500 #define FRAME_PARAM_FACES(f) ((f)->output_data.x->param_faces)
501 #define FRAME_N_PARAM_FACES(f) ((f)->output_data.x->n_param_faces)
502 #define FRAME_DEFAULT_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[0])
503 #define FRAME_MODE_LINE_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[1])
505 #define FRAME_COMPUTED_FACES(f) ((f)->output_data.x->computed_faces)
506 #define FRAME_N_COMPUTED_FACES(f) ((f)->output_data.x->n_computed_faces)
507 #define FRAME_SIZE_COMPUTED_FACES(f) ((f)->output_data.x->size_computed_faces)
508 #define FRAME_DEFAULT_FACE(f) ((f)->output_data.x->computed_faces[0])
509 #define FRAME_MODE_LINE_FACE(f) ((f)->output_data.x->computed_faces[1])
511 /* Return the window associated with the frame F. */
512 #define FRAME_X_WINDOW(f) ((f)->output_data.x->window_desc)
514 #define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel)
515 #define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
516 #define FRAME_FONT(f) ((f)->output_data.x->font)
517 #define FRAME_FONTSET(f) ((f)->output_data.x->fontset)
518 #define FRAME_INTERNAL_BORDER_WIDTH(f) ((f)->output_data.x->internal_border_width)
519 #define FRAME_LINE_HEIGHT(f) ((f)->output_data.x->line_height)
521 /* This gives the x_display_info structure for the display F is on. */
522 #define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.x->display_info)
524 /* This is the `Display *' which frame F is on. */
525 #define FRAME_X_DISPLAY(f) (FRAME_X_DISPLAY_INFO (f)->display)
527 /* This is the `Screen *' which frame F is on. */
528 #define FRAME_X_SCREEN(f) (FRAME_X_DISPLAY_INFO (f)->screen)
530 /* This is the 'font_info *' which frame F has. */
531 #define FRAME_X_FONT_TABLE(f) (FRAME_X_DISPLAY_INFO (f)->font_table)
533 /* These two really ought to be called FRAME_PIXEL_{WIDTH,HEIGHT}. */
534 #define PIXEL_WIDTH(f) ((f)->output_data.x->pixel_width)
535 #define PIXEL_HEIGHT(f) ((f)->output_data.x->pixel_height)
537 #define FRAME_DESIRED_CURSOR(f) ((f)->output_data.x->desired_cursor)
539 #define FRAME_XIM(f) ((f)->output_data.x->xim)
540 #define FRAME_XIC(f) ((f)->output_data.x->xic)
542 /* X-specific scroll bar stuff. */
544 /* We represent scroll bars as lisp vectors. This allows us to place
545 references to them in windows without worrying about whether we'll
546 end up with windows referring to dead scroll bars; the garbage
547 collector will free it when its time comes.
549 We use struct scroll_bar as a template for accessing fields of the
554 /* These fields are shared by all vectors. */
555 EMACS_INT size_from_Lisp_Vector_struct
;
556 struct Lisp_Vector
*next_from_Lisp_Vector_struct
;
558 /* The window we're a scroll bar for. */
561 /* The next and previous in the chain of scroll bars in this frame. */
562 Lisp_Object next
, prev
;
564 /* The X window representing this scroll bar. Since this is a full
565 32-bit quantity, we store it split into two 32-bit values. */
566 Lisp_Object x_window_low
, x_window_high
;
568 /* The position and size of the scroll bar in pixels, relative to the
570 Lisp_Object top
, left
, width
, height
;
572 /* The starting and ending positions of the handle, relative to the
573 handle area (i.e. zero is the top position, not
574 SCROLL_BAR_TOP_BORDER). If they're equal, that means the handle
575 hasn't been drawn yet.
577 These are not actually the locations where the beginning and end
578 are drawn; in order to keep handles from becoming invisible when
579 editing large files, we establish a minimum height by always
580 drawing handle bottoms VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
581 where they would be normally; the bottom and top are in a
582 different co-ordinate system. */
583 Lisp_Object start
, end
;
585 /* If the scroll bar handle is currently being dragged by the user,
586 this is the number of pixels from the top of the handle to the
587 place where the user grabbed it. If the handle isn't currently
588 being dragged, this is Qnil. */
589 Lisp_Object dragging
;
592 /* The number of elements a vector holding a struct scroll_bar needs. */
593 #define SCROLL_BAR_VEC_SIZE \
594 ((sizeof (struct scroll_bar) \
595 - sizeof (EMACS_INT) - sizeof (struct Lisp_Vector *)) \
596 / sizeof (Lisp_Object))
598 /* Turning a lisp vector value into a pointer to a struct scroll_bar. */
599 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
602 /* Building a 32-bit C integer from two 16-bit lisp integers. */
603 #define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
605 /* Setting two lisp integers to the low and high words of a 32-bit C int. */
606 #define SCROLL_BAR_UNPACK(low, high, int32) \
607 (XSETINT ((low), (int32) & 0xffff), \
608 XSETINT ((high), ((int32) >> 16) & 0xffff))
611 /* Extract the X window id of the scroll bar from a struct scroll_bar. */
612 #define SCROLL_BAR_X_WINDOW(ptr) \
613 ((Window) SCROLL_BAR_PACK ((ptr)->x_window_low, (ptr)->x_window_high))
615 /* Store a window id in a struct scroll_bar. */
616 #define SET_SCROLL_BAR_X_WINDOW(ptr, id) \
617 (SCROLL_BAR_UNPACK ((ptr)->x_window_low, (ptr)->x_window_high, (int) id))
620 /* Return the outside pixel height for a vertical scroll bar HEIGHT
621 rows high on frame F. */
622 #define VERTICAL_SCROLL_BAR_PIXEL_HEIGHT(f, height) \
623 ((height) * (f)->output_data.x->line_height)
625 /* Return the inside width of a vertical scroll bar, given the outside
627 #define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
629 - VERTICAL_SCROLL_BAR_LEFT_BORDER \
630 - VERTICAL_SCROLL_BAR_RIGHT_BORDER \
631 - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2)
633 /* Return the length of the rectangle within which the top of the
634 handle must stay. This isn't equivalent to the inside height,
635 because the scroll bar handle has a minimum height.
637 This is the real range of motion for the scroll bar, so when we're
638 scaling buffer positions to scroll bar positions, we use this, not
639 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT. */
640 #define VERTICAL_SCROLL_BAR_TOP_RANGE(f, height) \
641 (VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, height) - VERTICAL_SCROLL_BAR_MIN_HANDLE)
643 /* Return the inside height of vertical scroll bar, given the outside
644 height. See VERTICAL_SCROLL_BAR_TOP_RANGE too. */
645 #define VERTICAL_SCROLL_BAR_INSIDE_HEIGHT(f, height) \
646 ((height) - VERTICAL_SCROLL_BAR_TOP_BORDER - VERTICAL_SCROLL_BAR_BOTTOM_BORDER)
649 /* Border widths for scroll bars.
651 Scroll bar windows don't have any X borders; their border width is
652 set to zero, and we redraw borders ourselves. This makes the code
653 a bit cleaner, since we don't have to convert between outside width
654 (used when relating to the rest of the screen) and inside width
655 (used when sizing and drawing the scroll bar window itself).
657 The handle moves up and down/back and forth in a rectangle inset
658 from the edges of the scroll bar. These are widths by which we
659 inset the handle boundaries from the scroll bar edges. */
660 #define VERTICAL_SCROLL_BAR_LEFT_BORDER (2)
661 #define VERTICAL_SCROLL_BAR_RIGHT_BORDER (2)
662 #define VERTICAL_SCROLL_BAR_TOP_BORDER (2)
663 #define VERTICAL_SCROLL_BAR_BOTTOM_BORDER (2)
665 /* Minimum lengths for scroll bar handles, in pixels. */
666 #define VERTICAL_SCROLL_BAR_MIN_HANDLE (5)
668 /* Trimming off a few pixels from each side prevents
669 text from glomming up against the scroll bar */
670 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (2)
673 /* Manipulating pixel sizes and character sizes.
674 Knowledge of which factors affect the overall size of the window should
675 be hidden in these macros, if that's possible.
677 Return the upper/left pixel position of the character cell on frame F
679 #define CHAR_TO_PIXEL_ROW(f, row) \
680 ((f)->output_data.x->internal_border_width \
681 + (row) * (f)->output_data.x->line_height)
682 #define CHAR_TO_PIXEL_COL(f, col) \
683 ((f)->output_data.x->internal_border_width \
684 + (col) * FONT_WIDTH ((f)->output_data.x->font))
686 /* Return the pixel width/height of frame F if it has
687 WIDTH columns/HEIGHT rows. */
688 #define CHAR_TO_PIXEL_WIDTH(f, width) \
689 (CHAR_TO_PIXEL_COL (f, width) \
690 + (f)->output_data.x->vertical_scroll_bar_extra \
691 + (f)->output_data.x->internal_border_width)
692 #define CHAR_TO_PIXEL_HEIGHT(f, height) \
693 (CHAR_TO_PIXEL_ROW (f, height) \
694 + (f)->output_data.x->internal_border_width)
697 /* Return the row/column (zero-based) of the character cell containing
698 the pixel on FRAME at ROW/COL. */
699 #define PIXEL_TO_CHAR_ROW(f, row) \
700 (((row) - (f)->output_data.x->internal_border_width) \
701 / (f)->output_data.x->line_height)
702 #define PIXEL_TO_CHAR_COL(f, col) \
703 (((col) - (f)->output_data.x->internal_border_width) \
704 / FONT_WIDTH ((f)->output_data.x->font))
706 /* How many columns/rows of text can we fit in WIDTH/HEIGHT pixels on
708 #define PIXEL_TO_CHAR_WIDTH(f, width) \
709 (PIXEL_TO_CHAR_COL (f, ((width) \
710 - (f)->output_data.x->internal_border_width \
711 - (f)->output_data.x->vertical_scroll_bar_extra)))
712 #define PIXEL_TO_CHAR_HEIGHT(f, height) \
713 (PIXEL_TO_CHAR_ROW (f, ((height) \
714 - (f)->output_data.x->internal_border_width)))
716 /* If a struct input_event has a kind which is selection_request_event
717 or selection_clear_event, then its contents are really described
718 by this structure. */
720 /* For an event of kind selection_request_event,
721 this structure really describes the contents.
722 **Don't make this struct longer!**
723 If it overlaps the frame_or_window field of struct input_event,
724 that will cause GC to crash. */
725 struct selection_input_event
729 /* We spell it with an "o" here because X does. */
731 Atom selection
, target
, property
;
735 #define SELECTION_EVENT_DISPLAY(eventp) \
736 (((struct selection_input_event *) (eventp))->display)
737 /* We spell it with an "o" here because X does. */
738 #define SELECTION_EVENT_REQUESTOR(eventp) \
739 (((struct selection_input_event *) (eventp))->requestor)
740 #define SELECTION_EVENT_SELECTION(eventp) \
741 (((struct selection_input_event *) (eventp))->selection)
742 #define SELECTION_EVENT_TARGET(eventp) \
743 (((struct selection_input_event *) (eventp))->target)
744 #define SELECTION_EVENT_PROPERTY(eventp) \
745 (((struct selection_input_event *) (eventp))->property)
746 #define SELECTION_EVENT_TIME(eventp) \
747 (((struct selection_input_event *) (eventp))->time)
750 /* Interface to the face code functions. */
752 /* Forward declarations for prototypes. */
757 /* Create the first two computed faces for a frame -- the ones that
759 extern void init_frame_faces
P_ ((struct frame
*));
761 /* Free the resources for the faces associated with a frame. */
762 extern void free_frame_faces
P_ ((struct frame
*));
764 /* Given a computed face, find or make an equivalent display face
765 in face_vector, and return a pointer to it. */
766 extern struct face
*intern_face
P_ ((struct frame
*, struct face
*));
768 /* Given a frame and a face name, return the face's ID number, or
769 zero if it isn't a recognized face name. */
770 extern int face_name_id_number
P_ ((struct frame
*, Lisp_Object
));
772 /* Return non-zero if FONT1 and FONT2 have the same size bounding box.
773 We assume that they're both character-cell fonts. */
774 extern int same_size_fonts
P_ ((XFontStruct
*, XFontStruct
*));
776 /* Recompute the GC's for the default and modeline faces.
777 We call this after changing frame parameters on which those GC's
779 extern void recompute_basic_faces
P_ ((struct frame
*));
781 /* Return the face ID associated with a buffer position POS. Store
782 into *ENDPTR the next position at which a different face is
783 needed. This does not take account of glyphs that specify their
784 own face codes. F is the frame in use for display, and W is a
785 window displaying the current buffer.
787 REGION_BEG, REGION_END delimit the region, so it can be highlighted. */
788 extern int compute_char_face
P_ ((struct frame
*frame
,
791 int region_beg
, int region_end
,
793 int limit
, int mouse
));
794 /* Return the face ID to use to display a special glyph which selects
795 FACE_CODE as the face ID, assuming that ordinarily the face would
796 be BASIC_FACE. F is the frame. */
797 extern int compute_glyph_face
P_ ((struct frame
*, int, int));
799 /* Given a pixel position (PIX_X, PIX_Y) on the frame F, return
800 glyph co-ordinates in (*X, *Y). Set *BOUNDS to the rectangle
801 that the glyph at X, Y occupies, if BOUNDS != 0.
802 If NOCLIP is nonzero, do not force the value into range. */
804 extern void pixel_to_glyph_coords
P_ ((struct frame
*f
, int pix_x
, int pix_y
,
805 int *x
, int *y
, XRectangle
*bounds
,
808 extern void glyph_to_pixel_coords
P_ ((struct frame
*f
, int x
, int y
,
809 int *pix_x
, int *pix_y
));
811 /* Defined in xterm.c */
813 extern void cancel_mouse_face
P_ ((struct frame
*));
814 extern void x_scroll_bar_clear
P_ ((struct frame
*));
815 extern void x_start_queuing_selection_requests
P_ ((Display
*));
816 extern void x_stop_queuing_selection_requests
P_ ((Display
*));
817 extern void x_display_cursor
P_ ((struct frame
*, int, int, int));
818 extern void x_update_cursor
P_ ((struct frame
*, int));
819 extern int x_text_icon
P_ ((struct frame
*, char *));
820 extern int x_bitmap_icon
P_ ((struct frame
*, Lisp_Object
));
821 extern int x_catch_errors
P_ ((Display
*));
822 extern void x_check_errors
P_ ((Display
*, char *));
823 extern int x_had_errors_p
P_ ((Display
*));
824 extern void x_uncatch_errors
P_ ((Display
*, int));
825 extern Lisp_Object x_new_font
P_ ((struct frame
*, char *));
826 extern Lisp_Object x_new_fontset
P_ ((struct frame
*, char *));
827 extern void x_set_offset
P_ ((struct frame
*, int, int, int));
828 extern void x_set_window_size
P_ ((struct frame
*, int, int, int));
829 extern void x_set_mouse_position
P_ ((struct frame
*, int, int));
830 extern void x_set_mouse_pixel_position
P_ ((struct frame
*, int, int));
831 extern void x_raise_frame
P_ ((struct frame
*));
832 extern void x_lower_frame
P_ ((struct frame
*));
833 extern void x_make_frame_visible
P_ ((struct frame
*));
834 extern void x_make_frame_invisible
P_ ((struct frame
*));
835 extern void x_iconify_frame
P_ ((struct frame
*));
836 extern void x_destroy_window
P_ ((struct frame
*));
837 extern void x_wm_set_size_hint
P_ ((struct frame
*, long, int));
838 extern void x_wm_set_window_state
P_ ((struct frame
*, int));
839 extern void x_wm_set_icon_pixmap
P_ ((struct frame
*, int));
840 extern void x_wm_set_icon_position
P_ ((struct frame
*, int, int));
841 extern void x_delete_display
P_ ((struct x_display_info
*));
842 extern void x_initialize
P_ ((void));
844 /* Defined in xselect.c */
846 extern void x_handle_property_notify
P_ ((XPropertyEvent
*));
847 extern void x_handle_selection_notify
P_ ((XSelectionEvent
*));
848 extern void x_handle_selection_request
P_ ((struct input_event
*));
849 extern void x_handle_selection_clear
P_ ((struct input_event
*));
850 extern void x_clear_frame_selections
P_ ((struct frame
*));
852 /* Defined in xfns.c */
854 extern int have_menus_p
P_ ((void));
855 extern int x_bitmap_height
P_ ((struct frame
*, int));
856 extern int x_bitmap_width
P_ ((struct frame
*, int));
857 extern int x_bitmap_pixmap
P_ ((struct frame
*, int));
858 extern void x_reference_bitmap
P_ ((struct frame
*, int));
859 extern int x_create_bitmap_from_data
P_ ((struct frame
*, char *,
860 unsigned int, unsigned int));
861 extern int x_create_bitmap_from_file
P_ ((struct frame
*, Lisp_Object
));
862 extern void x_destroy_bitmap
P_ ((struct frame
*, int));
863 extern void x_set_frame_parameters
P_ ((struct frame
*, Lisp_Object
));
864 extern void x_real_positions
P_ ((struct frame
*, int *, int *));
865 extern void x_report_frame_params
P_ ((struct frame
*, Lisp_Object
*));
866 extern int defined_color
P_ ((struct frame
*, char *, XColor
*, int));
867 extern void x_set_border_pixel
P_ ((struct frame
*, int));
868 extern void x_set_menu_bar_lines
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
869 extern void x_implicitly_set_name
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
870 extern int x_pixel_width
P_ ((struct frame
*));
871 extern int x_pixel_height
P_ ((struct frame
*));
872 extern int x_char_width
P_ ((struct frame
*));
873 extern int x_char_height
P_ ((struct frame
*));
874 extern int x_screen_planes
P_ ((struct frame
*));
875 extern void x_sync
P_ ((struct frame
*));
877 /* Defined in xfaces.c */
878 extern int frame_update_line_height
P_ ((struct frame
*));
879 extern void clear_face_cache
P_ ((void));
880 extern int compute_glyph_face
P_ ((struct frame
*, int, int));
881 extern int compute_glyph_face_1
P_ ((struct frame
*, Lisp_Object
, int));
883 /* Defined in xmenu.c */
884 extern void x_activate_menubar
P_ ((struct frame
*));
885 extern int popup_activated
P_ ((void));
886 extern void initialize_frame_menubar
P_ ((struct frame
*));
888 /* Defined in widget.c */
889 extern void widget_store_internal_border
P_ ((Widget
));