1 /***********************************************************
2 * Artsoft Retro-Game Library *
3 *----------------------------------------------------------*
4 * (c) 1994-2006 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;
78 unsigned int width, height;
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];
97 /* X11 symbol definitions */
99 #define BLACK_PIXEL BlackPixel(display, screen)
100 #define WHITE_PIXEL WhitePixel(display, screen)
102 #define EVENT_BUTTONPRESS ButtonPress
103 #define EVENT_BUTTONRELEASE ButtonRelease
104 #define EVENT_MOTIONNOTIFY MotionNotify
105 #define EVENT_KEYPRESS KeyPress
106 #define EVENT_KEYRELEASE KeyRelease
107 #define EVENT_EXPOSE Expose
108 #define EVENT_FOCUSIN FocusIn
109 #define EVENT_FOCUSOUT FocusOut
110 #define EVENT_CLIENTMESSAGE ClientMessage
111 #define EVENT_MAPNOTIFY MapNotify
112 #define EVENT_UNMAPNOTIFY UnmapNotify
114 #define KSYM_UNDEFINED XK_VoidSymbol
116 #define KSYM_Return XK_Return
117 #define KSYM_Escape XK_Escape
119 #define KSYM_Left XK_Left
120 #define KSYM_Right XK_Right
121 #define KSYM_Up XK_Up
122 #define KSYM_Down XK_Down
125 #define KSYM_KP_Left XK_KP_Left
126 #define KSYM_KP_Right XK_KP_Right
127 #define KSYM_KP_Up XK_KP_Up
128 #define KSYM_KP_Down XK_KP_Down
132 #define KSYM_KP_Enter XK_KP_Enter
133 #define KSYM_KP_Add XK_KP_Add
134 #define KSYM_KP_Subtract XK_KP_Subtract
135 #define KSYM_KP_Multiply XK_KP_Multiply
136 #define KSYM_KP_Divide XK_KP_Divide
137 #define KSYM_KP_Separator XK_KP_Separator
140 #define KSYM_Shift_L XK_Shift_L
141 #define KSYM_Shift_R XK_Shift_R
142 #define KSYM_Control_L XK_Control_L
143 #define KSYM_Control_R XK_Control_R
144 #define KSYM_Meta_L XK_Meta_L
145 #define KSYM_Meta_R XK_Meta_R
146 #define KSYM_Alt_L XK_Alt_L
147 #define KSYM_Alt_R XK_Alt_R
148 #define KSYM_Super_L XK_Super_L
149 #define KSYM_Super_R XK_Super_R
150 #define KSYM_Mode_switch XK_Mode_switch
151 #define KSYM_Multi_key XK_Multi_key
153 #define KSYM_BackSpace XK_BackSpace
154 #define KSYM_Delete XK_Delete
155 #define KSYM_Insert XK_Insert
156 #define KSYM_Tab XK_Tab
157 #define KSYM_Home XK_Home
158 #define KSYM_End XK_End
159 #define KSYM_Page_Up XK_Page_Up
160 #define KSYM_Page_Down XK_Page_Down
161 #define KSYM_Menu XK_Menu
163 #define KSYM_space XK_space
164 #define KSYM_exclam XK_exclam
165 #define KSYM_quotedbl XK_quotedbl
166 #define KSYM_numbersign XK_numbersign
167 #define KSYM_dollar XK_dollar
168 #define KSYM_percent XK_percent
169 #define KSYM_ampersand XK_ampersand
170 #define KSYM_apostrophe XK_apostrophe
171 #define KSYM_parenleft XK_parenleft
172 #define KSYM_parenright XK_parenright
173 #define KSYM_asterisk XK_asterisk
174 #define KSYM_plus XK_plus
175 #define KSYM_comma XK_comma
176 #define KSYM_minus XK_minus
177 #define KSYM_period XK_period
178 #define KSYM_slash XK_slash
180 #define KSYM_colon XK_colon
181 #define KSYM_semicolon XK_semicolon
182 #define KSYM_less XK_less
183 #define KSYM_equal XK_equal
184 #define KSYM_greater XK_greater
185 #define KSYM_question XK_question
186 #define KSYM_at XK_at
188 #define KSYM_bracketleft XK_bracketleft
189 #define KSYM_backslash XK_backslash
190 #define KSYM_bracketright XK_bracketright
191 #define KSYM_asciicircum XK_asciicircum
192 #define KSYM_underscore XK_underscore
193 #define KSYM_grave XK_grave
195 #define KSYM_quoteleft XK_quoteleft
196 #define KSYM_braceleft XK_braceleft
197 #define KSYM_bar XK_bar
198 #define KSYM_braceright XK_braceright
199 #define KSYM_asciitilde XK_asciitilde
201 #define KSYM_degree XK_degree
202 #define KSYM_Adiaeresis XK_Adiaeresis
203 #define KSYM_Odiaeresis XK_Odiaeresis
204 #define KSYM_Udiaeresis XK_Udiaeresis
205 #define KSYM_adiaeresis XK_adiaeresis
206 #define KSYM_odiaeresis XK_odiaeresis
207 #define KSYM_udiaeresis XK_udiaeresis
208 #define KSYM_ssharp XK_ssharp
275 #define KSYM_KP_0 XK_KP_0
276 #define KSYM_KP_1 XK_KP_1
277 #define KSYM_KP_2 XK_KP_2
278 #define KSYM_KP_3 XK_KP_3
279 #define KSYM_KP_4 XK_KP_4
280 #define KSYM_KP_5 XK_KP_5
281 #define KSYM_KP_6 XK_KP_6
282 #define KSYM_KP_7 XK_KP_7
283 #define KSYM_KP_8 XK_KP_8
284 #define KSYM_KP_9 XK_KP_9
286 #define KSYM_F1 XK_F1
287 #define KSYM_F2 XK_F2
288 #define KSYM_F3 XK_F3
289 #define KSYM_F4 XK_F4
290 #define KSYM_F5 XK_F5
291 #define KSYM_F6 XK_F6
292 #define KSYM_F7 XK_F7
293 #define KSYM_F8 XK_F8
294 #define KSYM_F9 XK_F9
295 #define KSYM_F10 XK_F10
296 #define KSYM_F11 XK_F11
297 #define KSYM_F12 XK_F12
298 #define KSYM_F13 XK_F13
299 #define KSYM_F14 XK_F14
300 #define KSYM_F15 XK_F15
301 #define KSYM_F16 XK_F16
302 #define KSYM_F17 XK_F17
303 #define KSYM_F18 XK_F18
304 #define KSYM_F19 XK_F19
305 #define KSYM_F20 XK_F20
306 #define KSYM_F21 XK_F21
307 #define KSYM_F22 XK_F22
308 #define KSYM_F23 XK_F23
309 #define KSYM_F24 XK_F24
311 #define KSYM_FKEY_FIRST KSYM_F1
312 #define KSYM_FKEY_LAST KSYM_F24
313 #define KSYM_NUM_FKEYS (KSYM_FKEY_LAST - KSYM_FKEY_FIRST + 1)
315 #define KMOD_None None
316 #define KMOD_Shift_L 0x0001
317 #define KMOD_Shift_R 0x0002
318 #define KMOD_Control_L 0x0040
319 #define KMOD_Control_R 0x0080
320 #define KMOD_Meta_L 0x0400
321 #define KMOD_Meta_R 0x0800
322 #define KMOD_Alt_L 0x0100
323 #define KMOD_Alt_R 0x0200
325 #define KMOD_Shift (KMOD_Shift_L | KMOD_Shift_R)
326 #define KMOD_Control (KMOD_Control_L | KMOD_Control_R)
327 #define KMOD_Meta (KMOD_Meta_L | KMOD_Meta_R)
328 #define KMOD_Alt (KMOD_Alt_L | KMOD_Alt_R)
331 /* X11 function definitions */
333 void X11InitVideoDisplay(void);
334 void X11InitVideoBuffer(DrawBuffer **, DrawWindow **);
336 void X11CloseWindow(DrawWindow *);
338 void X11ZoomBitmap(Bitmap *, Bitmap *);
339 Bitmap *X11LoadImage(char *);
341 void X11CreateBitmapContent(Bitmap *, int, int, int);
342 void X11FreeBitmapPointers(Bitmap *);
343 void X11CopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int);
344 void X11FillRectangle(Bitmap *, int, int, int, int, Pixel);
345 void X11FadeRectangle(Bitmap *, int, int, int, int, int, int, int,
346 void (*draw_border_function)(void));
347 void X11DrawSimpleLine(Bitmap *, int, int, int, int, Pixel);
348 Pixel X11GetPixel(Bitmap *, int, int);
349 Pixel X11GetPixelFromRGB(unsigned int, unsigned int, unsigned int);
350 void X11DestroyImage(XImage *);
352 #if defined(TARGET_X11_NATIVE)
353 void X11SetMouseCursor(struct MouseCursorInfo *);