adding support for changing window position

mlx_set_window_position(void *mlx, void *win, int x, int y)
This commit is contained in:
Tidian Delage
2024-09-12 01:32:52 +02:00
parent 5a09ebb179
commit 466050ee7a
4 changed files with 32 additions and 3 deletions

View File

@@ -10,6 +10,7 @@
/* */
/* ************************************************************************** */
#include <SDL2/SDL_video.h>
#include <algorithm>
#include <core/application.h>
@@ -71,6 +72,16 @@ namespace mlx::core
_in->onEvent(_graphics[*static_cast<int*>(win)]->getWindow()->getID(), event, funct_ptr, param);
}
void Application::setWindowPosition(void *win, int x, int y) {
CHECK_WINDOW_PTR(win);
if(!_graphics[*static_cast<int*>(win)]->hasWindow())
{
error::report(e_kind::warning, "trying to move a window that is targeting an image and not a real window, this is not allowed");
return;
}
SDL_SetWindowPosition(_graphics[*static_cast<int*>(win)]->getWindow()->getNativeWindow(), x, y);
}
void Application::getScreenSize(void* win, int* w, int* h) noexcept
{
CHECK_WINDOW_PTR(win);