Fixed several errors/crashes when attempting to open a window larger than

the given screen.  This is allowed in windowed mode, since the window
manager normally takes care of it.  In the case of fullscreen mode, however,
it is never allowed, and an error message is shown.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2169 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-11-07 16:19:26 +00:00
parent e8b080551f
commit b756f8c14a
2 changed files with 34 additions and 19 deletions

View File

@ -43,6 +43,7 @@
FrameBuffer::FrameBuffer(OSystem* osystem) FrameBuffer::FrameBuffer(OSystem* osystem)
: myOSystem(osystem), : myOSystem(osystem),
myScreen(0), myScreen(0),
mySDLFlags(0),
myRedrawEntireFrame(true), myRedrawEntireFrame(true),
myUsePhosphor(false), myUsePhosphor(false),
myPhosphorBlend(77), myPhosphorBlend(77),
@ -93,14 +94,8 @@ FBInitStatus FrameBuffer::initialize(const string& title, uInt32 width, uInt32 h
// If the WINDOWED_SUPPORT macro is defined, we treat the system as the // If the WINDOWED_SUPPORT macro is defined, we treat the system as the
// former type; if not, as the latter type // former type; if not, as the latter type
// Initialize SDL flags and set fullscreen flag uInt32 flags = mySDLFlags;
// This must be done before any modes are initialized
mySDLFlags = 0;
#ifdef WINDOWED_SUPPORT #ifdef WINDOWED_SUPPORT
if(myOSystem->settings().getString("fullscreen") == "1")
mySDLFlags = SDL_FULLSCREEN;
// We assume that a desktop size of at least 640x480 means that we're // We assume that a desktop size of at least 640x480 means that we're
// running on a 'large' system, and the window size requirements can // running on a 'large' system, and the window size requirements can
// be relaxed // be relaxed
@ -108,6 +103,16 @@ FBInitStatus FrameBuffer::initialize(const string& title, uInt32 width, uInt32 h
if(myOSystem->desktopWidth() < 640 && myOSystem->desktopHeight() < 480 && if(myOSystem->desktopWidth() < 640 && myOSystem->desktopHeight() < 480 &&
(myOSystem->desktopWidth() < width || myOSystem->desktopHeight() < height)) (myOSystem->desktopWidth() < width || myOSystem->desktopHeight() < height))
return kFailTooLarge; return kFailTooLarge;
if(myOSystem->settings().getString("fullscreen") == "1")
{
if(myOSystem->desktopWidth() < width || myOSystem->desktopHeight() < height)
return kFailTooLarge;
flags |= SDL_FULLSCREEN;
}
else
flags &= ~SDL_FULLSCREEN;
#else #else
// Make sure this mode is even possible // Make sure this mode is even possible
// We only really need to worry about it in non-windowed environments, // We only really need to worry about it in non-windowed environments,
@ -116,6 +121,9 @@ FBInitStatus FrameBuffer::initialize(const string& title, uInt32 width, uInt32 h
return kFailTooLarge; return kFailTooLarge;
#endif #endif
// Only update the actual flags if no errors were detected
mySDLFlags = flags;
// Set the available video modes for this framebuffer // Set the available video modes for this framebuffer
setAvailableVidModes(width, height); setAvailableVidModes(width, height);
@ -1194,21 +1202,27 @@ void FrameBuffer::VideoModeList::print()
for(Common::Array<VideoMode>::const_iterator i = myModeList.begin(); for(Common::Array<VideoMode>::const_iterator i = myModeList.begin();
i != myModeList.end(); ++i) i != myModeList.end(); ++i)
{ {
cerr << " Mode " << i << endl cerr << " Mode " << i << endl;
<< " screen w = " << i->screen_w << endl print(*i);
<< " screen h = " << i->screen_h << endl
<< " image x = " << i->image_x << endl
<< " image y = " << i->image_y << endl
<< " image w = " << i->image_w << endl
<< " image h = " << i->image_h << endl
<< " gfx id = " << i->gfxmode.type << endl
<< " gfx name = " << i->gfxmode.name << endl
<< " gfx desc = " << i->gfxmode.description << endl
<< " gfx zoom = " << i->gfxmode.zoom << endl
<< endl;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::print(const VideoMode& mode)
{
cerr << " screen w = " << mode.screen_w << endl
<< " screen h = " << mode.screen_h << endl
<< " image x = " << mode.image_x << endl
<< " image y = " << mode.image_y << endl
<< " image w = " << mode.image_w << endl
<< " image h = " << mode.image_h << endl
<< " gfx id = " << mode.gfxmode.type << endl
<< " gfx name = " << mode.gfxmode.name << endl
<< " gfx desc = " << mode.gfxmode.description << endl
<< " gfx zoom = " << mode.gfxmode.zoom << endl
<< endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h, void FBSurface::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
uInt32 colorA, uInt32 colorB) uInt32 colorA, uInt32 colorB)

View File

@ -546,6 +546,7 @@ class FrameBuffer
void setByGfxMode(GfxID id); void setByGfxMode(GfxID id);
void setByGfxMode(const string& name); void setByGfxMode(const string& name);
void print(); void print();
static void print(const VideoMode& mode);
private: private:
void set(const GraphicsMode& gfxmode); void set(const GraphicsMode& gfxmode);