1 /* Definitions and headers for communication with X protocol.
2 Copyright (C) 1989 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, 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>
31 /* Define a queue for X-events. One such queue is used for mouse clicks.
32 Another is used for expose events. */
34 #define EVENT_BUFFER_SIZE 64
36 /* Max and Min sizes in character columns. */
44 /* HAVE_X11R4 is defined if we have the features of X11R4. It should
45 be defined when we're using X11R5, since X11R5 has the features of
46 X11R4. If, in the future, we find we need more of these flags
47 (HAVE_X11R5, for example), code should always be written to test
48 the most recent flag first:
58 If you ever find yourself writing a "#ifdef HAVE_FOO" clause that
59 looks a lot like another one, consider moving the text into a macro
60 whose definition is configuration-dependent, but whose usage is
61 universal - like the stuff in systime.h.
63 It turns out that we can auto-detect whether we're being compiled
64 with X11R3 or X11R4 by looking for the flag macros for R4 structure
65 members that R3 doesn't have. */
70 #define PIX_TYPE unsigned long
71 #define XDISPLAY x_current_display,
72 #define XFlushQueue() XFlush(x_current_display)
73 #define BLACK_PIX_DEFAULT BlackPixel (x_current_display, \
74 XDefaultScreen (x_current_display))
75 #define WHITE_PIX_DEFAULT WhitePixel (x_current_display, \
76 XDefaultScreen (x_current_display))
77 #define DISPLAY_SCREEN_ARG x_current_display, \
78 XDefaultScreen (x_current_display)
79 #define DISPLAY_CELLS DisplayCells (x_current_display, XDefaultScreen (x_current_display))
80 #define ROOT_WINDOW RootWindow (x_current_display, DefaultScreen (x_current_display))
81 #define FONT_TYPE XFontStruct
84 #define XExposeRegionEvent XExposeEvent
85 #define Bitmap Pixmap /* In X11, Bitmaps are are kind of
87 #define WINDOWINFO_TYPE XWindowAttributes
88 #define XGetWindowInfo(w, i) XGetWindowAttributes (x_current_display, \
90 #define XGetFont(f) XLoadQueryFont (x_current_display, (f))
91 #define XLoseFont(f) XFreeFont (x_current_display, (f))
92 #define XStuffPending() XPending (x_current_display)
93 #define XClear(w) XClearWindow (x_current_display, (w))
94 #define XWarpMousePointer(w,x,y) XWarpPointer (x_current_display, None, w, \
96 #define XHandleError XSetErrorHandler
97 #define XHandleIOError XSetIOErrorHandler
99 #define XChangeWindowSize(w,x,y) XResizeWindow(x_current_display,w,x,y)
101 #define FONT_WIDTH(f) ((f)->max_bounds.width)
102 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
103 #define FONT_BASE(f) ((f)->ascent)
105 /* The mask of events that text windows always want to receive. This
106 does not include mouse movement events. It is used when the window
107 is created (in x_window) and when we ask/unask for mouse movement
108 events (in XTmouse_tracking_enable).
110 We do include ButtonReleases in this set because elisp isn't always
111 fast enough to catch them when it wants them, and they're rare
112 enough that they don't use much processor time. */
114 #define STANDARD_EVENT_SET \
118 | ButtonReleaseMask \
119 | PointerMotionMask \
120 | PointerMotionHintMask \
121 | StructureNotifyMask \
125 | VisibilityChangeMask)
129 #define ConnectionNumber(dpy) dpyno()
132 #define XFlushQueue() XFlush()
133 #define BLACK_PIX_DEFAULT BlackPixel
134 #define WHITE_PIX_DEFAULT WhitePixel
135 #define DISPLAY_SCREEN_ARG
136 #define DISPLAY_CELLS DisplayCells ()
137 #define ROOT_WINDOW RootWindow
139 #define FONT_TYPE FontInfo
141 #define WINDOWINFO_TYPE WindowInfo
142 #define XGetWindowInfo(w, i) XQueryWindow ((w), (i))
143 #define XGetFont(f) XOpenFont ((f))
144 #define XLoseFont(f) XCloseFont ((f))
145 #define XStuffPending() XPending ()
146 #define XWarpMousePointer(w,x,y) XWarpMouse (w,x,y)
147 #define XHandleError XErrorHandler
148 #define XHandleIOError XIOErrorHandler
150 #define FONT_WIDTH(f) ((f)->width)
151 #define FONT_HEIGHT(f) ((f)->height)
152 #define FONT_BASE(f) ((f)->base)
154 #define XChangeWindowSize(w,x,y) XChangeWindow(w,x,y)
160 int rindex
; /* Index at which to fetch next. */
161 int windex
; /* Index at which to store next. */
162 XEvent xrep
[EVENT_BUFFER_SIZE
];
165 /* Queue for mouse clicks. */
166 extern struct event_queue x_mouse_queue
;
168 /* Mechanism for interlocking between main program level
169 and input interrupt level. */
171 /* Nonzero during a critical section. At such a time, an input interrupt
172 does nothing but set `x_pending_input'. */
173 extern int x_input_blocked
;
175 /* Nonzero means an input interrupt has arrived
176 during the current critical section. */
177 extern int x_pending_input
;
179 /* Begin critical section. */
180 #define BLOCK_INPUT (x_input_blocked++)
182 /* End critical section. */
183 #define UNBLOCK_INPUT \
184 (x_input_blocked--, (x_input_blocked < 0 ? (abort (), 0) : 0))
186 #define TOTALLY_UNBLOCK_INPUT (x_input_blocked = 0)
187 #define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT
189 /* This is the X connection that we are using. */
191 extern Display
*x_current_display
;
193 extern struct frame
*x_window_to_frame ();
195 /* The frame (if any) which has the X window that has keyboard focus.
196 Zero if none. This is examined by Ffocus_frame in xfns.c */
198 struct frame
*x_focus_frame
;
201 /* Variables associated with the X display screen this emacs is using. */
203 /* How many screens this X display has. */
204 extern int x_screen_count
;
206 /* The vendor supporting this X server. */
207 extern Lisp_Object Vx_vendor
;
209 /* The vendor's release number for this X server. */
210 extern int x_release
;
212 /* Height of this X screen in pixels. */
213 extern int x_screen_height
;
215 /* Height of this X screen in millimeters. */
216 extern int x_screen_height_mm
;
218 /* Width of this X screen in pixels. */
219 extern int x_screen_width
;
221 /* Width of this X screen in millimeters. */
222 extern int x_screen_width_mm
;
224 /* Does this X screen do backing store? */
225 extern Lisp_Object Vx_backing_store
;
227 /* Does this X screen do save-unders? */
228 extern int x_save_under
;
230 /* Number of planes for this screen. */
231 extern int x_screen_planes
;
233 /* X Visual type of this screen. */
234 extern Lisp_Object Vx_screen_visual
;
236 #endif /* HAVE_X11 */
238 enum text_cursor_kinds
{
239 filled_box_cursor
, hollow_box_cursor
, bar_cursor
242 #define PIXEL_WIDTH(s) ((s)->display.x->pixel_width)
243 #define PIXEL_HEIGHT(s) ((s)->display.x->pixel_height)
245 /* Each X frame object points to its own struct x_display object
246 in the display.x field. The x_display structure contains all
247 the information that is specific to X windows. */
251 /* Position of the X window (x and y offsets in root window). */
255 /* Border width of the X window as known by the X window system. */
258 /* Size of the X window in pixels. */
259 int pixel_height
, pixel_width
;
262 /* The tiled border used when the mouse is out of the frame. */
265 /* Here are the Graphics Contexts for the default font. */
266 GC normal_gc
; /* Normal video */
267 GC reverse_gc
; /* Reverse video */
268 GC cursor_gc
; /* cursor drawing */
269 #endif /* HAVE_X11 */
271 /* Width of the internal border. This is a line of background color
272 just inside the window's border. When the frame is selected,
273 a highlighting is displayed inside the internal border. */
274 int internal_border_width
;
276 /* The X window used for this frame.
277 May be zero while the frame object is being created
278 and the X window has not yet been created. */
281 /* The X window used for the bitmap icon;
282 or 0 if we don't have a bitmap icon. */
285 /* The X window that is the parent of this X window.
286 Usually but not always RootWindow. */
289 /* 1 for bitmap icon, 0 for text icon. */
290 int icon_bitmap_flag
;
294 /* Pixel values used for various purposes.
295 border_pixel may be -1 meaning use a gray tile. */
296 PIX_TYPE background_pixel
;
297 PIX_TYPE foreground_pixel
;
298 PIX_TYPE cursor_pixel
;
299 PIX_TYPE border_pixel
;
300 PIX_TYPE mouse_pixel
;
302 /* Windows for scrollbars */
315 int v_scrollbar_width
;
316 int h_scrollbar_height
;
318 /* Descriptor for the cursor in use for this window. */
321 Cursor nontext_cursor
;
322 Cursor modeline_cursor
;
327 /* The name that was associated with the icon, the last time
328 it was refreshed. Usually the same as the name of the
329 buffer in the currently selected window in the frame */
332 /* Flag to set when the X window needs to be completely repainted. */
335 /* What kind of text cursor is drawn in this window right now? (If
336 there is no cursor (phys_cursor_x < 0), then this means nothing. */
337 enum text_cursor_kinds text_cursor_kind
;
339 /* These are the current window manager hints. It seems that
340 XSetWMHints, when presented with an unset bit in the `flags'
341 member of the hints structure, does not leave the corresponding
342 attribute unchanged; rather, it resets that attribute to its
343 default value. For example, unless you set the `icon_pixmap'
344 field and the `IconPixmapHint' bit, XSetWMHints will forget what
345 your icon pixmap was. This is rather troublesome, since some of
346 the members (for example, `input' and `icon_pixmap') want to stay
347 the same throughout the execution of Emacs. So, we keep this
348 structure around, just leaving values in it and adding new bits
349 to the mask as we go. */
353 /* Return the window associated with the frame F. */
354 #define FRAME_X_WINDOW(f) ((f)->display.x->window_desc)
357 /* When X windows are used, a glyf may be a 16 bit unsigned datum.
358 The high order byte is the face number and is used as an index
359 in the face table. A face is a font plus:
360 1) the unhighlighted foreground color,
361 2) the unhighlighted background color.
362 For highlighting, the two colors are exchanged.
363 Face number 0 is unused. The low order byte of a glyf gives
364 the character within the font. All fonts are assumed to be
365 fixed width, and to have the same height and width. */
369 /* Face declared in dispextern.h */
375 FONT_TYPE
*font
; /* Font info for specified font. */
376 int fg
; /* Unhighlighted foreground. */
377 int bg
; /* Unhighlighted background. */
381 #define MAX_FACES_AND_GLYPHS 256
382 extern struct face
*x_face_table
[];