Add a work-around for SDL_GetAppState in SDL2.

The code only compiles, but never return a sensible value. This should
be done later.
This commit is contained in:
Mark de Wever 2014-03-02 10:56:21 +01:00
parent 8a079ba488
commit 57432e805f
3 changed files with 43 additions and 0 deletions

View file

@ -37,6 +37,7 @@
#define KMOD_META KMOD_GUI
#define SDL_FULLSCREEN SDL_WINDOW_FULLSCREEN_DESKTOP
#define SDL_EVENTMASK(EVENT) EVENT, EVENT
#define SDL_GetAppState CVideo::window_state
#endif

View file

@ -449,6 +449,33 @@ bool CVideo::update_locked() const
return updatesLocked_ > 0;
}
#if SDL_VERSION_ATLEAST(2, 0, 0)
static SDL_Window* window = NULL;
Uint8
CVideo::window_state(void)
{
Uint8 state = 0;
Uint32 flags = 0;
if(!::window) {
return state;
}
flags = SDL_GetWindowFlags(::window);
if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) {
state |= SDL_APPACTIVE;
}
if (flags & SDL_WINDOW_INPUT_FOCUS) {
state |= SDL_APPINPUTFOCUS;
}
if (flags & SDL_WINDOW_MOUSE_FOCUS) {
state |= SDL_APPMOUSEFOCUS;
}
return state;
}
#endif
surface& CVideo::getSurface()
{
return frameBuffer;

View file

@ -25,6 +25,12 @@ struct surface;
//possible flags when setting video modes
#define FULL_SCREEN SDL_FULLSCREEN
#if SDL_VERSION_ATLEAST(2, 0, 0)
#define SDL_APPMOUSEFOCUS 0x01 /**< The app has mouse coverage */
#define SDL_APPINPUTFOCUS 0x02 /**< The app has input focus */
#define SDL_APPACTIVE 0x04 /**< The application is active */
#endif
surface display_format_alpha(surface surf);
surface get_video_surface();
SDL_Rect screen_area();
@ -118,6 +124,15 @@ class CVideo : private boost::noncopyable {
void lock_updates(bool value);
bool update_locked() const;
#if SDL_VERSION_ATLEAST(2, 0, 0)
/**
* Wrapper for SDL_GetAppState.
*
* @warning The function always return 0 for now.
*/
static Uint8 window_state();
#endif
private:
void initSDL();