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 #define RES_CLASS "emacs"
38 /* Max and Min sizes in character columns. */
45 #define PIX_TYPE unsigned long
46 #define XDISPLAY x_current_display,
47 #define XFlushQueue() XFlush(x_current_display)
48 #define BLACK_PIX_DEFAULT BlackPixel (x_current_display, \
49 XDefaultScreen (x_current_display))
50 #define WHITE_PIX_DEFAULT WhitePixel (x_current_display, \
51 XDefaultScreen (x_current_display))
52 #define DISPLAY_SCREEN_ARG x_current_display, \
53 XDefaultScreen (x_current_display)
54 #define DISPLAY_CELLS DisplayCells (x_current_display, XDefaultScreen (x_current_display))
55 #define ROOT_WINDOW RootWindow (x_current_display, XDefaultScreen (x_current_display))
56 #define FONT_TYPE XFontStruct
59 #define XExposeRegionEvent XExposeEvent
60 #define Bitmap Pixmap /* In X11, Bitmaps are are kind of
62 #define WINDOWINFO_TYPE XWindowAttributes
63 #define XGetWindowInfo(w, i) XGetWindowAttributes (x_current_display, \
65 #define XGetFont(f) XLoadQueryFont (x_current_display, (f))
66 #define XLoseFont(f) XFreeFont (x_current_display, (f))
67 #define XStuffPending() XPending (x_current_display)
68 #define XClear(w) XClearWindow (x_current_display, (w))
69 #define XWarpMousePointer(w,x,y) XWarpPointer (x_current_display, None, w, \
71 #define XHandleError XSetErrorHandler
72 #define XHandleIOError XSetIOErrorHandler
74 #define XChangeWindowSize(w,x,y) XResizeWindow(x_current_display,w,x,y)
76 #define FONT_WIDTH(f) ((f)->max_bounds.width)
77 #define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
78 #define FONT_BASE(f) ((f)->ascent)
80 /* GC values used for drawing non-standard (other face) text. */
81 extern XGCValues face_gc_values
;
83 /* The mask of events that text windows always want to receive. This
84 does not include mouse movement events. It is used when the window
85 is created (in x_window) and when we ask/unask for mouse movement
86 events (in XTmouse_tracking_enable).
88 We do include ButtonReleases in this set because elisp isn't always
89 fast enough to catch them when it wants them, and they're rare
90 enough that they don't use much processor time. */
92 #define STANDARD_EVENT_SET \
98 | PointerMotionHintMask \
99 | StructureNotifyMask \
103 | VisibilityChangeMask)
107 #define ConnectionNumber(dpy) dpyno()
110 #define XFlushQueue() XFlush()
111 #define BLACK_PIX_DEFAULT BlackPixel
112 #define WHITE_PIX_DEFAULT WhitePixel
113 #define DISPLAY_SCREEN_ARG
114 #define DISPLAY_CELLS DisplayCells ()
115 #define ROOT_WINDOW RootWindow
117 #define FONT_TYPE FontInfo
119 #define WINDOWINFO_TYPE WindowInfo
120 #define XGetWindowInfo(w, i) XQueryWindow ((w), (i))
121 #define XGetFont(f) XOpenFont ((f))
122 #define XLoseFont(f) XCloseFont ((f))
123 #define XStuffPending() XPending ()
124 #define XWarpMousePointer(w,x,y) XWarpMouse (w,x,y)
125 #define XHandleError XErrorHandler
126 #define XHandleIOError XIOErrorHandler
128 #define FONT_WIDTH(f) ((f)->width)
129 #define FONT_HEIGHT(f) ((f)->height)
130 #define FONT_BASE(f) ((f)->base)
132 #define XChangeWindowSize(w,x,y) XChangeWindow(w,x,y)
138 int rindex
; /* Index at which to fetch next. */
139 int windex
; /* Index at which to store next. */
140 XEvent xrep
[EVENT_BUFFER_SIZE
];
143 /* Queue for mouse clicks. */
144 extern struct event_queue x_mouse_queue
;
146 /* Mechanism for interlocking between main program level
147 and input interrupt level. */
149 /* Nonzero during a critical section. At such a time, an input interrupt
150 does nothing but set `x_pending_input'. */
151 extern int x_input_blocked
;
153 /* Nonzero means an input interrupt has arrived
154 during the current critical section. */
155 extern int x_pending_input
;
157 /* Begin critical section. */
158 #define BLOCK_INPUT (x_input_blocked++)
160 /* End critical section. */
161 #define UNBLOCK_INPUT \
162 (x_input_blocked--, (x_input_blocked < 0 ? (abort (), 0) : 0))
164 #define TOTALLY_UNBLOCK_INPUT (x_input_blocked = 0)
165 #define UNBLOCK_INPUT_RESIGNAL UNBLOCK_INPUT
167 /* This is the X connection that we are using. */
169 extern Display
*x_current_display
;
171 extern struct screen
*x_window_to_screen ();
173 /* The screen (if any) which has the X window that has keyboard focus.
174 Zero if none. This is examined by Ffocus_screen in xfns.c */
176 struct screen
*x_focus_screen
;
179 /* Variables associated with the X display screen this emacs is using. */
181 /* How many screens this X display has. */
182 extern Lisp_Object x_screen_count
;
184 /* The vendor supporting this X server. */
185 extern Lisp_Object Vx_vendor
;
187 /* The vendor's release number for this X server. */
188 extern Lisp_Object x_release
;
190 /* Height of this X screen in pixels. */
191 extern Lisp_Object x_screen_height
;
193 /* Height of this X screen in millimeters. */
194 extern Lisp_Object x_screen_height_mm
;
196 /* Width of this X screen in pixels. */
197 extern Lisp_Object x_screen_width
;
199 /* Width of this X screen in millimeters. */
200 extern Lisp_Object x_screen_width_mm
;
202 /* Does this X screen do backing store? */
203 extern Lisp_Object Vx_backing_store
;
205 /* Does this X screen do save-unders? */
206 extern Lisp_Object x_save_under
;
208 /* Number of planes for this screen. */
209 extern Lisp_Object x_screen_planes
;
211 /* X Visual type of this screen. */
212 extern Lisp_Object Vx_screen_visual
;
214 #endif /* HAVE_X11 */
216 enum text_cursor_kinds
{
217 filled_box_cursor
, hollow_box_cursor
, bar_cursor
220 #define PIXEL_WIDTH(s) ((s)->display.x->pixel_width)
221 #define PIXEL_HEIGHT(s) ((s)->display.x->pixel_height)
223 /* Each X screen object points to its own struct x_display object
224 in the display.x field. The x_display structure contains all
225 the information that is specific to X windows. */
229 /* Position of the X window (x and y offsets in root window). */
233 /* Border width of the X window as known by the X window system. */
236 /* Size of the X window in pixels. */
237 int pixel_height
, pixel_width
;
240 /* The tiled border used when the mouse is out of the screen. */
243 /* Here are the Graphics Contexts for the default font. */
244 GC normal_gc
; /* Normal video */
245 GC reverse_gc
; /* Reverse video */
246 GC cursor_gc
; /* cursor drawing */
247 #endif /* HAVE_X11 */
249 /* Width of the internal border. This is a line of background color
250 just inside the window's border. When the screen is selected,
251 a highlighting is displayed inside the internal border. */
252 int internal_border_width
;
254 /* The X window used for this screen.
255 May be zero while the screen object is being created
256 and the X window has not yet been created. */
259 /* The X window used for the bitmap icon;
260 or 0 if we don't have a bitmap icon. */
263 /* The X window that is the parent of this X window.
264 Usually but not always RootWindow. */
267 /* 1 for bitmap icon, 0 for text icon. */
268 int icon_bitmap_flag
;
272 /* Pixel values used for various purposes.
273 border_pixel may be -1 meaning use a gray tile. */
274 PIX_TYPE background_pixel
;
275 PIX_TYPE foreground_pixel
;
276 PIX_TYPE cursor_pixel
;
277 PIX_TYPE border_pixel
;
278 PIX_TYPE mouse_pixel
;
280 /* Windows for scrollbars */
293 int v_scrollbar_width
;
294 int h_scrollbar_height
;
296 /* Descriptor for the cursor in use for this window. */
299 Cursor nontext_cursor
;
300 Cursor modeline_cursor
;
305 /* The name that was associated with the icon, the last time
306 it was refreshed. Usually the same as the name of the
307 buffer in the currently selected window in the screen */
310 /* Flag to set when the X window needs to be completely repainted. */
313 /* What kind of text cursor is drawn in this window right now? (If
314 there is no cursor (phys_cursor_x < 0), then this means nothing. */
315 enum text_cursor_kinds text_cursor_kind
;
318 /* When X windows are used, a glyf may be a 16 bit unsigned datum.
319 The high order byte is the face number and is used as an index
320 in the face table. A face is a font plus:
321 1) the unhighlighted foreground color,
322 2) the unhighlighted background color.
323 For highlighting, the two colors are exchanged.
324 Face number 0 is unused. The low order byte of a glyf gives
325 the character within the font. All fonts are assumed to be
326 fixed width, and to have the same height and width. */
329 /* Table of GC's used for this screen. */
332 /* How many GCs are in the table. */
338 unsigned int foreground
;
339 unsigned int background
;
348 FONT_TYPE
*font
; /* Font info for specified font. */
349 int fg
; /* Unhighlighted foreground. */
350 int bg
; /* Unhighlighted background. */
354 #define MAX_FACES_AND_GLYPHS 256
355 extern struct face
*x_face_table
[];