mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Also fixed love.window.setMode to fail instead of bug out when trying to set a fullscreen mode which is too large for the monitor.
This commit is contained in:
@@ -103,15 +103,16 @@ bool Window::setWindow(int width, int height, WindowFlags *flags)
|
||||
|
||||
if (f.fullscreen)
|
||||
{
|
||||
switch (f.fstype)
|
||||
{
|
||||
case FULLSCREEN_TYPE_NORMAL:
|
||||
default:
|
||||
sdlflags |= SDL_WINDOW_FULLSCREEN;
|
||||
break;
|
||||
case FULLSCREEN_TYPE_DESKTOP:
|
||||
if (f.fstype == FULLSCREEN_TYPE_DESKTOP)
|
||||
sdlflags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
break;
|
||||
else
|
||||
{
|
||||
sdlflags |= SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
// Fullscreen window creation will bug out if no mode can be used.
|
||||
SDL_DisplayMode mode = {0, width, height, 0, 0};
|
||||
if (SDL_GetClosestDisplayMode(f.display, &mode, &mode) == 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,26 +374,6 @@ int Window::getDisplayCount() const
|
||||
return SDL_GetNumVideoDisplays();
|
||||
}
|
||||
|
||||
bool Window::checkWindowSize(int width, int height, bool fullscreen, int displayindex) const
|
||||
{
|
||||
if (fullscreen)
|
||||
{
|
||||
SDL_DisplayMode mode = {}, closest = {};
|
||||
mode.w = width;
|
||||
mode.h = height;
|
||||
SDL_GetClosestDisplayMode(displayindex, &mode, &closest);
|
||||
|
||||
return (mode.w == closest.w && mode.h == closest.h);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_DisplayMode mode = {};
|
||||
SDL_GetDesktopDisplayMode(displayindex, &mode);
|
||||
|
||||
return (width <= mode.w && height <= mode.h);
|
||||
}
|
||||
}
|
||||
|
||||
typedef Window::WindowSize WindowSize;
|
||||
|
||||
std::vector<WindowSize> Window::getFullscreenSizes(int displayindex) const
|
||||
|
||||
@@ -51,7 +51,6 @@ public:
|
||||
|
||||
int getDisplayCount() const;
|
||||
|
||||
bool checkWindowSize(int width, int height, bool fullscreen, int displayindex) const;
|
||||
std::vector<WindowSize> getFullscreenSizes(int displayindex) const;
|
||||
|
||||
int getWidth() const;
|
||||
|
||||
Reference in New Issue
Block a user