X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fsystem.c;h=54870c81a92398147445837564f9620b73482f89;hb=69c2342c24b734fcbcd7c5ab2acfb2b3837f5c5a;hp=08c2eb5d7d8b206d41a1530d81d71d9874b069a8;hpb=a8b2caa1d373c84c1b3fc2f615370c2a319051ca;p=rocksndiamonds.git diff --git a/src/system.c b/src/system.c index 08c2eb5d..54870c81 100644 --- a/src/system.c +++ b/src/system.c @@ -15,13 +15,10 @@ #include "main.h" #include "misc.h" -inline void InitEventFilter(EventFilter filter_function) -{ -#ifdef TARGET_SDL - /* set event filter to filter out certain events */ - SDL_SetEventFilter(filter_function); -#endif -} + +/* ========================================================================= */ +/* video functions */ +/* ========================================================================= */ inline void InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window) { @@ -201,6 +198,63 @@ inline boolean PointerInWindow(DrawWindow window) #endif } +inline boolean SetVideoMode(void) +{ +#ifdef TARGET_SDL + 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 TARGET_SDL + if ((setup.fullscreen && !fullscreen_enabled && fullscreen_available) || + (!setup.fullscreen && fullscreen_enabled)) + SetVideoMode(); +#endif +} + + +/* ========================================================================= */ +/* audio functions */ +/* ========================================================================= */ + +inline boolean InitAudio(void) +{ +#ifdef TARGET_SDL + return SDLInitAudio(); +#else + return TRUE; +#endif +} + + +/* ========================================================================= */ +/* event functions */ +/* ========================================================================= */ + +inline void InitEventFilter(EventFilter filter_function) +{ +#ifdef TARGET_SDL + /* set event filter to filter out certain events */ + SDL_SetEventFilter(filter_function); +#endif +} + inline boolean PendingEvent(void) { #ifdef TARGET_SDL @@ -247,44 +301,22 @@ inline Key GetEventKey(KeyEvent *event, boolean with_modifiers) #endif } -inline boolean SetVideoMode(void) +inline boolean CheckCloseWindowEvent(ClientMessageEvent *event) { -#ifdef TARGET_SDL - 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; + if (event->type != EVENT_CLIENTMESSAGE) + return FALSE; + +#if defined(TARGET_SDL) + return TRUE; /* the only possible message here is SDL_QUIT */ +#elif defined(PLATFORM_UNIX) + if ((event->window == window) && + (event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE))) + return TRUE; #endif -} -inline void ChangeVideoModeIfNeeded(void) -{ -#ifdef TARGET_SDL - if ((setup.fullscreen && !fullscreen_enabled && fullscreen_available) || - (!setup.fullscreen && fullscreen_enabled)) - SetVideoMode(); -#endif + return FALSE; } -inline boolean InitAudio(void) -{ -#ifdef TARGET_SDL - return SDLInitAudio(); -#else - return TRUE; -#endif -} inline void dummy(void) {