lua.window.setPosition: add param waitForSync

if waitForSync is false, then SDL_SyncWindow is not called, and so the
method may return before the requested changes actually happen.

This is backwards-compatible with previous behaviour
This commit is contained in:
Shelvacu
2026-04-19 17:59:29 -07:00
committed by Shelvacu on fw
parent 0e0a7d2155
commit b1dba5939e
4 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -189,7 +189,7 @@ public:
virtual void getDesktopDimensions(int displayindex, int &width, int &height) const = 0;
virtual void setPosition(int x, int y, int displayindex) = 0;
virtual void setPosition(int x, int y, int displayindex, bool waitForSync) = 0;
virtual void getPosition(int &x, int &y, int &displayindex) = 0;
virtual Rect getSafeArea() const = 0;
+3 -2
View File
@@ -957,7 +957,7 @@ void Window::getDesktopDimensions(int displayindex, int &width, int &height) con
}
}
void Window::setPosition(int x, int y, int displayindex)
void Window::setPosition(int x, int y, int displayindex, bool waitForSync)
{
if (!window)
return;
@@ -974,7 +974,8 @@ void Window::setPosition(int x, int y, int displayindex)
y += displaybounds.y;
SDL_SetWindowPosition(window, x, y);
SDL_SyncWindow(window);
if (waitForSync)
SDL_SyncWindow(window);
settings.useposition = true;
}
+1 -1
View File
@@ -66,7 +66,7 @@ public:
void getDesktopDimensions(int displayindex, int &width, int &height) const override;
void setPosition(int x, int y, int displayindex) override;
void setPosition(int x, int y, int displayindex, bool waitForSync) override;
void getPosition(int &x, int &y, int &displayindex) override;
Rect getSafeArea() const override;
+2 -1
View File
@@ -384,8 +384,9 @@ int w_setPosition(lua_State *L)
int x_unused, y_unused;
instance()->getPosition(x_unused, y_unused, displayindex);
}
bool waitForSync = luax_optboolean(L, 4, true);
instance()->setPosition(x, y, displayindex);
instance()->setPosition(x, y, displayindex, waitForSync);
return 0;
}