1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
17 #if !defined(PLATFORM_MSDOS)
22 #include <X11/Xutil.h>
23 #include <X11/Xatom.h>
25 #include <X11/Intrinsic.h>
26 #include <X11/keysymdef.h>
30 /* system dependent definitions */
32 /* MS-DOS header file also defines "TARGET_STRING" */
34 #define TARGET_STRING "X11"
37 #if defined(PLATFORM_UNIX)
38 /* This triggers some stuff that is needed because X11 (XSetClipOrigin(),
39 to be precise) is often very slow when preparing a masked XCopyArea()
41 To prevent this, small (tile-sized) mask Pixmaps are created which will
42 then be set much faster with XSetClipOrigin() and speed things up a lot. */
43 #define TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND
46 #define FULLSCREEN_STATUS FULLSCREEN_NOT_AVAILABLE
48 #define CURSOR_MAX_WIDTH 32
49 #define CURSOR_MAX_HEIGHT 32
52 /* X11 type definitions */
54 typedef struct X11DrawableInfo Bitmap;
55 typedef struct X11DrawableInfo DrawWindow;
56 typedef struct X11DrawableInfo DrawBuffer;
57 /* "Pixel" is already defined */
58 /* "Cursor" is already defined */
61 typedef unsigned int KeyMod;
64 typedef XButtonEvent ButtonEvent;
65 typedef XMotionEvent MotionEvent;
66 typedef XKeyEvent KeyEvent;
67 typedef XExposeEvent ExposeEvent;
68 typedef XFocusChangeEvent FocusChangeEvent;
69 typedef XClientMessageEvent ClientMessageEvent;
72 /* structure definitions */
74 struct X11DrawableInfo
76 char *source_filename;
81 GC gc; /* GC for normal drawing (inheritated from 'window') */
82 GC line_gc[2]; /* GC for foreground and background line drawing */
83 GC stored_clip_gc; /* GC for masked drawing (used for whole Pixmap) */
84 GC clip_gc; /* can be 'stored_clip_gc' or one-tile-only clip GC */
87 struct MouseCursorInfo
92 char data[CURSOR_MAX_WIDTH * CURSOR_MAX_HEIGHT / 8];
93 char mask[CURSOR_MAX_WIDTH * CURSOR_MAX_HEIGHT / 8];
102 /* X11 symbol definitions */
104 #define BLACK_PIXEL BlackPixel(display, screen)
105 #define WHITE_PIXEL WhitePixel(display, screen)
107 #define EVENT_BUTTONPRESS ButtonPress
108 #define EVENT_BUTTONRELEASE ButtonRelease
109 #define EVENT_MOTIONNOTIFY MotionNotify
110 #define EVENT_KEYPRESS KeyPress
111 #define EVENT_KEYRELEASE KeyRelease
112 #define EVENT_EXPOSE Expose
113 #define EVENT_FOCUSIN FocusIn
114 #define EVENT_FOCUSOUT FocusOut
115 #define EVENT_CLIENTMESSAGE ClientMessage
116 #define EVENT_MAPNOTIFY MapNotify
117 #define EVENT_UNMAPNOTIFY UnmapNotify
119 #define KSYM_UNDEFINED XK_VoidSymbol
121 #define KSYM_Return XK_Return
122 #define KSYM_Escape XK_Escape
124 #define KSYM_Left XK_Left
125 #define KSYM_Right XK_Right
126 #define KSYM_Up XK_Up
127 #define KSYM_Down XK_Down
130 #define KSYM_KP_Left XK_KP_Left
131 #define KSYM_KP_Right XK_KP_Right
132 #define KSYM_KP_Up XK_KP_Up
133 #define KSYM_KP_Down XK_KP_Down
137 #define KSYM_KP_Enter XK_KP_Enter
138 #define KSYM_KP_Add XK_KP_Add
139 #define KSYM_KP_Subtract XK_KP_Subtract
140 #define KSYM_KP_Multiply XK_KP_Multiply
141 #define KSYM_KP_Divide XK_KP_Divide
142 #define KSYM_KP_Separator XK_KP_Separator
145 #define KSYM_Shift_L XK_Shift_L
146 #define KSYM_Shift_R XK_Shift_R
147 #define KSYM_Control_L XK_Control_L
148 #define KSYM_Control_R XK_Control_R
149 #define KSYM_Meta_L XK_Meta_L
150 #define KSYM_Meta_R XK_Meta_R
151 #define KSYM_Alt_L XK_Alt_L
152 #define KSYM_Alt_R XK_Alt_R
153 #define KSYM_Super_L XK_Super_L
154 #define KSYM_Super_R XK_Super_R
155 #define KSYM_Mode_switch XK_Mode_switch
156 #define KSYM_Multi_key XK_Multi_key
158 #define KSYM_BackSpace XK_BackSpace
159 #define KSYM_Delete XK_Delete
160 #define KSYM_Insert XK_Insert
161 #define KSYM_Tab XK_Tab
162 #define KSYM_Home XK_Home
163 #define KSYM_End XK_End
164 #define KSYM_Page_Up XK_Page_Up
165 #define KSYM_Page_Down XK_Page_Down
166 #define KSYM_Menu XK_Menu
168 #define KSYM_space XK_space
169 #define KSYM_exclam XK_exclam
170 #define KSYM_quotedbl XK_quotedbl
171 #define KSYM_numbersign XK_numbersign
172 #define KSYM_dollar XK_dollar
173 #define KSYM_percent XK_percent
174 #define KSYM_ampersand XK_ampersand
175 #define KSYM_apostrophe XK_apostrophe
176 #define KSYM_parenleft XK_parenleft
177 #define KSYM_parenright XK_parenright
178 #define KSYM_asterisk XK_asterisk
179 #define KSYM_plus XK_plus
180 #define KSYM_comma XK_comma
181 #define KSYM_minus XK_minus
182 #define KSYM_period XK_period
183 #define KSYM_slash XK_slash
185 #define KSYM_colon XK_colon
186 #define KSYM_semicolon XK_semicolon
187 #define KSYM_less XK_less
188 #define KSYM_equal XK_equal
189 #define KSYM_greater XK_greater
190 #define KSYM_question XK_question
191 #define KSYM_at XK_at
193 #define KSYM_bracketleft XK_bracketleft
194 #define KSYM_backslash XK_backslash
195 #define KSYM_bracketright XK_bracketright
196 #define KSYM_asciicircum XK_asciicircum
197 #define KSYM_underscore XK_underscore
198 #define KSYM_grave XK_grave
200 #define KSYM_quoteleft XK_quoteleft
201 #define KSYM_braceleft XK_braceleft
202 #define KSYM_bar XK_bar
203 #define KSYM_braceright XK_braceright
204 #define KSYM_asciitilde XK_asciitilde
206 #define KSYM_Adiaeresis XK_Adiaeresis
207 #define KSYM_Odiaeresis XK_Odiaeresis
208 #define KSYM_Udiaeresis XK_Udiaeresis
209 #define KSYM_adiaeresis XK_adiaeresis
210 #define KSYM_odiaeresis XK_odiaeresis
211 #define KSYM_udiaeresis XK_udiaeresis
212 #define KSYM_ssharp XK_ssharp
279 #define KSYM_KP_0 XK_KP_0
280 #define KSYM_KP_1 XK_KP_1
281 #define KSYM_KP_2 XK_KP_2
282 #define KSYM_KP_3 XK_KP_3
283 #define KSYM_KP_4 XK_KP_4
284 #define KSYM_KP_5 XK_KP_5
285 #define KSYM_KP_6 XK_KP_6
286 #define KSYM_KP_7 XK_KP_7
287 #define KSYM_KP_8 XK_KP_8
288 #define KSYM_KP_9 XK_KP_9
290 #define KSYM_F1 XK_F1
291 #define KSYM_F2 XK_F2
292 #define KSYM_F3 XK_F3
293 #define KSYM_F4 XK_F4
294 #define KSYM_F5 XK_F5
295 #define KSYM_F6 XK_F6
296 #define KSYM_F7 XK_F7
297 #define KSYM_F8 XK_F8
298 #define KSYM_F9 XK_F9
299 #define KSYM_F10 XK_F10
300 #define KSYM_F11 XK_F11
301 #define KSYM_F12 XK_F12
302 #define KSYM_F13 XK_F13
303 #define KSYM_F14 XK_F14
304 #define KSYM_F15 XK_F15
305 #define KSYM_F16 XK_F16
306 #define KSYM_F17 XK_F17
307 #define KSYM_F18 XK_F18
308 #define KSYM_F19 XK_F19
309 #define KSYM_F20 XK_F20
310 #define KSYM_F21 XK_F21
311 #define KSYM_F22 XK_F22
312 #define KSYM_F23 XK_F23
313 #define KSYM_F24 XK_F24
315 #define KSYM_FKEY_FIRST KSYM_F1
316 #define KSYM_FKEY_LAST KSYM_F24
317 #define KSYM_NUM_FKEYS (KSYM_FKEY_LAST - KSYM_FKEY_FIRST + 1)
319 #define KMOD_None None
320 #define KMOD_Shift_L 0x0001
321 #define KMOD_Shift_R 0x0002
322 #define KMOD_Control_L 0x0040
323 #define KMOD_Control_R 0x0080
324 #define KMOD_Meta_L 0x0400
325 #define KMOD_Meta_R 0x0800
326 #define KMOD_Alt_L 0x0100
327 #define KMOD_Alt_R 0x0200
329 #define KMOD_Shift (KMOD_Shift_L | KMOD_Shift_R)
330 #define KMOD_Control (KMOD_Control_L | KMOD_Control_R)
331 #define KMOD_Meta (KMOD_Meta_L | KMOD_Meta_R)
332 #define KMOD_Alt (KMOD_Alt_L | KMOD_Alt_R)
335 /* X11 function definitions */
337 void X11InitVideoDisplay(void);
338 void X11InitVideoBuffer(DrawBuffer **, DrawWindow **);
340 void X11ZoomBitmap(Bitmap *, Bitmap *);
341 Bitmap *X11LoadImage(char *);
343 void X11CreateBitmapContent(Bitmap *, int, int, int);
344 void X11FreeBitmapPointers(Bitmap *);
345 void X11CopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int);
346 void X11FillRectangle(Bitmap *, int, int, int, int, Pixel);
347 void X11FadeScreen(Bitmap *, int, int, int);
348 void X11DrawSimpleLine(Bitmap *, int, int, int, int, Pixel);
349 Pixel X11GetPixel(Bitmap *, int, int);
350 Pixel X11GetPixelFromRGB(unsigned int, unsigned int, unsigned int);
351 void X11DestroyImage(XImage *);
353 #if defined(TARGET_X11_NATIVE)
354 void X11SetMouseCursor(struct MouseCursorInfo *);