***********************************************************/
#include "main.h"
+#include "misc.h"
+
+inline void InitEventFilter(EventFilter filter_function)
+{
+#ifdef USE_SDL_LIBRARY
+ /* set event filter to filter out certain events */
+ SDL_SetEventFilter(filter_function);
+#endif
+}
+
+inline void InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window)
+{
+#ifdef USE_SDL_LIBRARY
+ SDLInitBufferedDisplay(backbuffer, window);
+#else
+ X11InitBufferedDisplay(backbuffer, window);
+#endif
+}
+
+inline int GetDisplayDepth(void)
+{
+#ifdef USE_SDL_LIBRARY
+ return SDL_GetVideoSurface()->format->BitsPerPixel;
+#else
+ return XDefaultDepth(display, screen);
+#endif
+}
+
+inline Bitmap CreateBitmap(int width, int height, int depth)
+{
+ int real_depth = (depth == DEFAULT_DEPTH ? GetDisplayDepth() : depth);
+
+#ifdef USE_SDL_LIBRARY
+ SDL_Surface *surface_tmp, *surface_native;
+
+ if ((surface_tmp = SDL_CreateRGBSurface(SURFACE_FLAGS, width, height,
+ real_depth, 0, 0, 0, 0))
+ == NULL)
+ Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+ if ((surface_native = SDL_DisplayFormat(surface_tmp)) == NULL)
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+
+ SDL_FreeSurface(surface_tmp);
+
+ return surface_native;
+#else
+ Pixmap pixmap;
+
+ if (!(pixmap = XCreatePixmap(display, window, width, height, real_depth)))
+ Error(ERR_EXIT, "cannot create pixmap");
+
+ return pixmap;
+#endif
+}
+
+inline void FreeBitmap(Bitmap bitmap)
+{
+#ifdef USE_SDL_LIBRARY
+ SDL_FreeSurface(bitmap);
+#else
+ XFreePixmap(display, bitmap);
+#endif
+}
inline void ClearRectangle(Bitmap bitmap, int x, int y, int width, int height)
{
}
/* execute all pending screen drawing operations */
-inline void FlushDisplay()
+inline void FlushDisplay(void)
{
#ifndef USE_SDL_LIBRARY
XFlush(display);
}
/* execute and wait for all pending screen drawing operations */
-inline void SyncDisplay()
+inline void SyncDisplay(void)
{
#ifndef USE_SDL_LIBRARY
XSync(display, FALSE);
#endif
}
-inline void KeyboardAutoRepeatOn()
+inline void KeyboardAutoRepeatOn(void)
{
#ifdef USE_SDL_LIBRARY
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
#endif
}
-inline void KeyboardAutoRepeatOff()
+inline void KeyboardAutoRepeatOff(void)
{
#ifdef USE_SDL_LIBRARY
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
#endif
}
-inline boolean PendingEvent()
+inline boolean PendingEvent(void)
{
#ifdef USE_SDL_LIBRARY
return (SDL_PollEvent(NULL) ? TRUE : FALSE);
inline Key GetEventKey(KeyEvent *event, boolean with_modifiers)
{
#ifdef USE_SDL_LIBRARY
+#if 0
+ printf("unicode == '%d', sym == '%d', mod == '0x%04x'\n",
+ (int)event->keysym.unicode,
+ (int)event->keysym.sym,
+ (int)SDL_GetModState());
+#endif
+
if (with_modifiers && event->keysym.unicode != 0)
return event->keysym.unicode;
else
return event->keysym.sym;
#else
+#if 0
+ printf("with modifiers == '0x%04x', without modifiers == '0x%04x'\n",
+ (int)XLookupKeysym(event, event->state),
+ (int)XLookupKeysym(event, 0));
+#endif
+
if (with_modifiers)
return XLookupKeysym(event, event->state);
else
#endif
}
-inline void dummy()
+inline boolean SetVideoMode(void)
+{
+#ifdef USE_SDL_LIBRARY
+ return SDLSetVideoMode(&backbuffer);
+#else
+ boolean success = TRUE;
+
+ if (setup.fullscreen && fullscreen_available)
+ {
+ Error(ERR_WARN, "fullscreen not available in X11 version");
+
+ /* display error message only once */
+ fullscreen_available = FALSE;
+
+ success = FALSE;
+ }
+
+ return success;
+#endif
+}
+
+inline void ChangeVideoModeIfNeeded(void)
+{
+#ifdef USE_SDL_LIBRARY
+ if ((setup.fullscreen && !fullscreen_enabled && fullscreen_available) ||
+ (!setup.fullscreen && fullscreen_enabled))
+ SetVideoMode();
+#endif
+}
+
+inline void dummy(void)
{
#ifdef USE_SDL_LIBRARY
#else