SDL: Hack to handle special SDL events.

svn-id: r51015
This commit is contained in:
Alejandro Marzini 2010-07-19 05:33:58 +00:00
parent 6215f2b6d4
commit 38b4098f67
3 changed files with 25 additions and 5 deletions

View File

@ -238,6 +238,18 @@ bool SdlEventManager::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
case SDL_JOYAXISMOTION:
return handleJoyAxisMotion(ev, event);
case SDL_VIDEOEXPOSE:
// HACK: Send a fake event, handled by SdlGraphicsManager
event.type = (Common::EventType)OSystem_SDL::kSdlEventExpose;
return true;
case SDL_VIDEORESIZE:
// HACK: Send a fake event, handled by OpenGLSdlGraphicsManager
event.type = (Common::EventType)OSystem_SDL::kSdlEventResize;
event.mouse.x = ev.resize.w;
event.mouse.y = ev.resize.h;
return true;
case SDL_QUIT:
event.type = Common::EVENT_QUIT;
return true;

View File

@ -26,7 +26,8 @@
#if defined(WIN32) || defined(UNIX) || defined(MACOSX)
#include "backends/graphics/sdl/sdl-graphics.h"
#include "common/system.h"
#include "backends/events/sdl/sdl-events.h"
#include "backends/platform/sdl/sdl.h"
#include "common/config-manager.h"
#include "common/mutex.h"
#include "common/translation.h"
@ -39,7 +40,6 @@
#include "graphics/scaler.h"
#include "graphics/scaler/aspect.h"
#include "graphics/surface.h"
#include "backends/events/sdl/sdl-events.h"
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
{"1x", _s("Normal (no scaling)"), GFX_NORMAL},
@ -2122,7 +2122,7 @@ void SdlGraphicsManager::toggleFullScreen() {
}
bool SdlGraphicsManager::notifyEvent(const Common::Event &event) {
switch (event.type) {
switch ((int)event.type) {
case Common::EVENT_KEYDOWN:
// Alt-Return and Alt-Enter toggle full screen mode
if (event.kbd.hasFlags(Common::KBD_ALT) &&
@ -2172,9 +2172,11 @@ bool SdlGraphicsManager::notifyEvent(const Common::Event &event) {
case Common::EVENT_MBUTTONUP:
adjustMouseEvent(event);
return !event.synthetic;
/*case SDL_VIDEOEXPOSE:
// HACK: Handle special SDL event
case OSystem_SDL::kSdlEventExpose:
_forceFull = true;
return false;*/
return false;
default:
break;
}

View File

@ -72,6 +72,12 @@ public:
virtual void getTimeAndDate(TimeDate &td) const;
virtual Audio::Mixer *getMixer();
// HACK: Special SDL events types
enum SdlEvent {
kSdlEventExpose = 100,
kSdlEventResize = 101
};
protected:
bool _inited;
bool _initedSDL;