mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Rename 'display' field to 'displayindex' in setMode and love.conf.
Fixes #1711.
This commit is contained in:
@@ -145,7 +145,7 @@ function love.init()
|
||||
minheight = 1,
|
||||
fullscreen = false,
|
||||
fullscreentype = "desktop",
|
||||
display = 1,
|
||||
displayindex = 1,
|
||||
vsync = 1,
|
||||
msaa = 0,
|
||||
borderless = false,
|
||||
|
||||
@@ -114,6 +114,7 @@ StringMap<Window::Setting, Window::SETTING_MAX_ENUM>::Entry Window::settingEntri
|
||||
{"minheight", SETTING_MIN_HEIGHT},
|
||||
{"borderless", SETTING_BORDERLESS},
|
||||
{"centered", SETTING_CENTERED},
|
||||
{"displayindex", SETTING_DISPLAYINDEX},
|
||||
{"display", SETTING_DISPLAY},
|
||||
{"highdpi", SETTING_HIGHDPI},
|
||||
{"usedpiscale", SETTING_USE_DPISCALE},
|
||||
|
||||
@@ -69,7 +69,8 @@ public:
|
||||
SETTING_MIN_HEIGHT,
|
||||
SETTING_BORDERLESS,
|
||||
SETTING_CENTERED,
|
||||
SETTING_DISPLAY,
|
||||
SETTING_DISPLAYINDEX,
|
||||
SETTING_DISPLAY, // Deprecated
|
||||
SETTING_HIGHDPI, // Deprecated
|
||||
SETTING_USE_DPISCALE,
|
||||
SETTING_REFRESHRATE,
|
||||
@@ -264,7 +265,7 @@ struct WindowSettings
|
||||
int minheight = 1;
|
||||
bool borderless = false;
|
||||
bool centered = true;
|
||||
int display = 0;
|
||||
int displayindex = 0;
|
||||
bool usedpiscale = true;
|
||||
double refreshrate = 0.0;
|
||||
bool useposition = false;
|
||||
|
||||
@@ -478,13 +478,13 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
f.minwidth = std::max(f.minwidth, 1);
|
||||
f.minheight = std::max(f.minheight, 1);
|
||||
|
||||
f.display = std::min(std::max(f.display, 0), getDisplayCount() - 1);
|
||||
f.displayindex = std::min(std::max(f.displayindex, 0), getDisplayCount() - 1);
|
||||
|
||||
// Use the desktop resolution if a width or height of 0 is specified.
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
SDL_DisplayMode mode = {};
|
||||
SDL_GetDesktopDisplayMode(f.display, &mode);
|
||||
SDL_GetDesktopDisplayMode(f.displayindex, &mode);
|
||||
width = mode.w;
|
||||
height = mode.h;
|
||||
}
|
||||
@@ -509,16 +509,16 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
{
|
||||
// The position needs to be in the global coordinate space.
|
||||
SDL_Rect displaybounds = {};
|
||||
SDL_GetDisplayBounds(f.display, &displaybounds);
|
||||
SDL_GetDisplayBounds(f.displayindex, &displaybounds);
|
||||
x += displaybounds.x;
|
||||
y += displaybounds.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (f.centered)
|
||||
x = y = SDL_WINDOWPOS_CENTERED_DISPLAY(f.display);
|
||||
x = y = SDL_WINDOWPOS_CENTERED_DISPLAY(f.displayindex);
|
||||
else
|
||||
x = y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(f.display);
|
||||
x = y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(f.displayindex);
|
||||
}
|
||||
|
||||
SDL_DisplayMode fsmode = {0, width, height, 0, nullptr};
|
||||
@@ -526,12 +526,12 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
if (f.fullscreen && f.fstype == FULLSCREEN_EXCLUSIVE)
|
||||
{
|
||||
// Fullscreen window creation will bug out if no mode can be used.
|
||||
if (SDL_GetClosestDisplayMode(f.display, &fsmode, &fsmode) == nullptr)
|
||||
if (SDL_GetClosestDisplayMode(f.displayindex, &fsmode, &fsmode) == nullptr)
|
||||
{
|
||||
// GetClosestDisplayMode will fail if we request a size larger
|
||||
// than the largest available display mode, so we'll try to use
|
||||
// the largest (first) mode in that case.
|
||||
if (SDL_GetDisplayMode(f.display, 0, &fsmode) < 0)
|
||||
if (SDL_GetDisplayMode(f.displayindex, 0, &fsmode) < 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -607,7 +607,7 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
|
||||
// Enforce minimum window dimensions.
|
||||
SDL_SetWindowMinimumSize(window, f.minwidth, f.minheight);
|
||||
|
||||
if (this->settings.display != f.display || f.useposition || f.centered)
|
||||
if (this->settings.displayindex != f.displayindex || f.useposition || f.centered)
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
|
||||
SDL_RaiseWindow(window);
|
||||
@@ -727,7 +727,7 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
||||
settings.borderless = (wflags & SDL_WINDOW_BORDERLESS) != 0;
|
||||
settings.centered = newsettings.centered;
|
||||
|
||||
getPosition(settings.x, settings.y, settings.display);
|
||||
getPosition(settings.x, settings.y, settings.displayindex);
|
||||
|
||||
setHighDPIAllowed((wflags & SDL_WINDOW_ALLOW_HIGHDPI) != 0);
|
||||
|
||||
@@ -745,7 +745,7 @@ void Window::updateSettings(const WindowSettings &newsettings, bool updateGraphi
|
||||
settings.depth = newsettings.depth;
|
||||
|
||||
SDL_DisplayMode dmode = {};
|
||||
SDL_GetCurrentDisplayMode(settings.display, &dmode);
|
||||
SDL_GetCurrentDisplayMode(settings.displayindex, &dmode);
|
||||
|
||||
// May be 0 if the refresh rate can't be determined.
|
||||
settings.refreshrate = (double) dmode.refresh_rate;
|
||||
|
||||
@@ -74,9 +74,17 @@ static int readWindowSettings(lua_State *L, int idx, WindowSettings &settings)
|
||||
settings.minheight = luax_intflag(L, idx, settingName(Window::SETTING_MIN_HEIGHT), settings.minheight);
|
||||
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.usedpiscale = luax_boolflag(L, idx, settingName(Window::SETTING_USE_DPISCALE), settings.usedpiscale);
|
||||
|
||||
settings.displayindex = luax_intflag(L, idx, settingName(Window::SETTING_DISPLAYINDEX), settings.displayindex + 1) - 1;
|
||||
lua_getfield(L, idx, settingName(Window::SETTING_DISPLAY));
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
{
|
||||
luax_markdeprecated(L, 1, "window.display", API_FIELD, DEPRECATED_REPLACED, "displayindex field");
|
||||
settings.displayindex = (int) luaL_checkinteger(L, -1) - 1;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, idx, settingName(Window::SETTING_HIGHDPI));
|
||||
if (!lua_isnoneornil(L, -1))
|
||||
{
|
||||
@@ -208,8 +216,8 @@ int w_getMode(lua_State *L)
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_CENTERED));
|
||||
|
||||
// Display index is 0-based internally and 1-based in Lua.
|
||||
lua_pushinteger(L, settings.display + 1);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_DISPLAY));
|
||||
lua_pushinteger(L, settings.displayindex + 1);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_DISPLAYINDEX));
|
||||
|
||||
luax_pushboolean(L, settings.usedpiscale);
|
||||
lua_setfield(L, -2, settingName(Window::SETTING_USE_DPISCALE));
|
||||
|
||||
Reference in New Issue
Block a user