mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Replace highdpi window flag with t.highdpi in love.conf
This commit is contained in:
@@ -26,6 +26,18 @@ namespace love
|
||||
namespace window
|
||||
{
|
||||
|
||||
static bool highDPIAllowed = false;
|
||||
|
||||
void setHighDPIAllowed(bool enable)
|
||||
{
|
||||
highDPIAllowed = enable;
|
||||
}
|
||||
|
||||
bool isHighDPIAllowed()
|
||||
{
|
||||
return highDPIAllowed;
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ class Graphics;
|
||||
namespace window
|
||||
{
|
||||
|
||||
// Applied when the window is first created.
|
||||
void setHighDPIAllowed(bool enable);
|
||||
bool isHighDPIAllowed();
|
||||
|
||||
// Forward-declared so it can be used in the class methods. We can't define the
|
||||
// whole thing here because it uses the Window::Type enum.
|
||||
struct WindowSettings;
|
||||
@@ -66,7 +70,7 @@ public:
|
||||
SETTING_BORDERLESS,
|
||||
SETTING_CENTERED,
|
||||
SETTING_DISPLAY,
|
||||
SETTING_HIGHDPI,
|
||||
SETTING_HIGHDPI, // Deprecated
|
||||
SETTING_USE_DPISCALE,
|
||||
SETTING_REFRESHRATE,
|
||||
SETTING_X,
|
||||
@@ -261,7 +265,6 @@ struct WindowSettings
|
||||
bool borderless = false;
|
||||
bool centered = true;
|
||||
int display = 0;
|
||||
bool highdpi = false;
|
||||
bool usedpiscale = true;
|
||||
double refreshrate = 0.0;
|
||||
bool useposition = false;
|
||||
|
||||
@@ -477,7 +477,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
if (f.borderless)
|
||||
sdlflags |= SDL_WINDOW_BORDERLESS;
|
||||
|
||||
if (f.highdpi)
|
||||
if (isHighDPIAllowed())
|
||||
sdlflags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
|
||||
int x = f.x;
|
||||
@@ -596,7 +596,8 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
||||
|
||||
getPosition(settings.x, settings.y, settings.display);
|
||||
|
||||
settings.highdpi = (wflags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||
setHighDPIAllowed((wflags & SDL_WINDOW_ALLOW_HIGHDPI) != 0);
|
||||
|
||||
settings.usedpiscale = newsettings.usedpiscale;
|
||||
|
||||
// Only minimize on focus loss if the window is in exclusive-fullscreen mode
|
||||
|
||||
@@ -75,9 +75,19 @@ static int readWindowSettings(lua_State *L, int idx, WindowSettings &settings)
|
||||
settings.borderless = luax_boolflag(L, idx, settingName(Window::SETTING_BORDERLESS), settings.borderless);
|
||||
settings.centered = luax_boolflag(L, idx, settingName(Window::SETTING_CENTERED), settings.centered);
|
||||
settings.display = luax_intflag(L, idx, settingName(Window::SETTING_DISPLAY), settings.display+1) - 1;
|
||||
settings.highdpi = luax_boolflag(L, idx, settingName(Window::SETTING_HIGHDPI), settings.highdpi);
|
||||
settings.usedpiscale = luax_boolflag(L, idx, settingName(Window::SETTING_USE_DPISCALE), settings.usedpiscale);
|
||||
|
||||
lua_getfield(L, idx, settingName(Window::SETTING_HIGHDPI));
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
{
|
||||
luax_markdeprecated(L, "window.highdpi", API_FIELD, DEPRECATED_REPLACED, "t.highdpi in love.conf");
|
||||
bool highdpi = luax_checkboolean(L, -1);
|
||||
if (!instance()->isOpen())
|
||||
setHighDPIAllowed(highdpi);
|
||||
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, idx, settingName(Window::SETTING_VSYNC));
|
||||
if (lua_isnumber(L, -1))
|
||||
settings.vsync = (int) lua_tointeger(L, -1);
|
||||
@@ -201,9 +211,6 @@ int w_getMode(lua_State *L)
|
||||
lua_pushinteger(L, settings.display + 1);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_DISPLAY));
|
||||
|
||||
luax_pushboolean(L, settings.highdpi);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_HIGHDPI));
|
||||
|
||||
luax_pushboolean(L, settings.usedpiscale);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_USE_DPISCALE));
|
||||
|
||||
@@ -219,6 +226,12 @@ int w_getMode(lua_State *L)
|
||||
return 3;
|
||||
}
|
||||
|
||||
int w_isHighDPIAllowed(lua_State *L)
|
||||
{
|
||||
luax_pushboolean(L, isHighDPIAllowed());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_getDisplayOrientation(lua_State *L)
|
||||
{
|
||||
int displayindex = 0;
|
||||
@@ -618,6 +631,7 @@ static const luaL_Reg functions[] =
|
||||
{ "setMode", w_setMode },
|
||||
{ "updateMode", w_updateMode },
|
||||
{ "getMode", w_getMode },
|
||||
{ "isHighDPIAllowed", w_isHighDPIAllowed },
|
||||
{ "getDisplayOrientation", w_getDisplayOrientation },
|
||||
{ "getFullscreenModes", w_getFullscreenModes },
|
||||
{ "setFullscreen", w_setFullscreen },
|
||||
|
||||
Reference in New Issue
Block a user