From 1fe21e77259f0992a0622a3d1dd04cdd011fa551 Mon Sep 17 00:00:00 2001 From: bonsthie Date: Thu, 8 Aug 2024 17:49:14 +0200 Subject: [PATCH 1/3] Add header to fix compilation issue on Arch Linux The code was failing to compile on Arch Linux due to missing definitions from the header. Including this header resolves the issue, ensuring compatibility across different environments. --- src/core/application.inl | 1 + src/core/graphics.inl | 1 + src/renderer/command/vk_cmd_buffer.h | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/application.inl b/src/core/application.inl index a3ccec1..62c85ea 100644 --- a/src/core/application.inl +++ b/src/core/application.inl @@ -10,6 +10,7 @@ /* */ /* ************************************************************************** */ +#include #include #define CHECK_WINDOW_PTR(win) \ diff --git a/src/core/graphics.inl b/src/core/graphics.inl index 97958e0..6335cbf 100644 --- a/src/core/graphics.inl +++ b/src/core/graphics.inl @@ -10,6 +10,7 @@ /* */ /* ************************************************************************** */ +#include #include namespace mlx diff --git a/src/renderer/command/vk_cmd_buffer.h b/src/renderer/command/vk_cmd_buffer.h index d8fd7aa..39ef073 100644 --- a/src/renderer/command/vk_cmd_buffer.h +++ b/src/renderer/command/vk_cmd_buffer.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* vk_cmd_buffer.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: maldavid +#+ +:+ +#+ */ +/* By: bonsthie +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/06 18:25:42 by maldavid #+# #+# */ -/* Updated: 2024/01/07 01:25:50 by maldavid ### ########.fr */ +/* Updated: 2024/08/08 17:46:00 by bonsthie ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,7 @@ #include #include #include +#include namespace mlx { From d87d4fbd6acf846d7fb384bbd63c721acc4aa0c8 Mon Sep 17 00:00:00 2001 From: Tidian Delage Date: Thu, 12 Sep 2024 01:32:52 +0200 Subject: [PATCH 2/3] adding support for changing window position mlx_set_window_position(void *mlx, void *win, int x, int y) --- includes/mlx.h | 13 ++++++++++++- src/core/application.h | 3 ++- src/core/application.inl | 11 +++++++++++ src/core/bridge.cpp | 8 +++++++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/includes/mlx.h b/includes/mlx.h index 14e4a0e..078302b 100644 --- a/includes/mlx.h +++ b/includes/mlx.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */ -/* Updated: 2024/01/18 14:36:12 by maldavid ### ########.fr */ +/* Updated: 2024/09/12 01:28:12 by tdelage ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,6 +53,17 @@ MLX_API void* mlx_init(); */ MLX_API void* mlx_new_window(void* mlx, int w, int h, const char* title); +/** + * @brief Creates a new window + * + * @param mlx Internal MLX application + * @param win Internal window to move + * @param x New x position + * @param y New y position + * + */ +MLX_API void mlx_set_window_position(void *mlx, void *win, int x, int y); + /** * @brief Gives a function to be executed at each loop turn diff --git a/src/core/application.h b/src/core/application.h index 48717dc..fbb9ad0 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */ -/* Updated: 2024/01/26 11:26:54 by maldavid ### ########.fr */ +/* Updated: 2024/09/12 01:30:35 by tdelage ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,6 +45,7 @@ namespace mlx::core inline void* newGraphicsSuport(std::size_t w, std::size_t h, const char* title); inline void clearGraphicsSupport(void* win); inline void destroyGraphicsSupport(void* win); + inline void setWindowPosition(void *win, int x, int y); inline void pixelPut(void* win, int x, int y, std::uint32_t color) const noexcept; inline void stringPut(void* win, int x, int y, std::uint32_t color, char* str); diff --git a/src/core/application.inl b/src/core/application.inl index 62c85ea..1500667 100644 --- a/src/core/application.inl +++ b/src/core/application.inl @@ -10,6 +10,7 @@ /* */ /* ************************************************************************** */ +#include #include #include @@ -71,6 +72,16 @@ namespace mlx::core _in->onEvent(_graphics[*static_cast(win)]->getWindow()->getID(), event, funct_ptr, param); } + void Application::setWindowPosition(void *win, int x, int y) { + CHECK_WINDOW_PTR(win); + if(!_graphics[*static_cast(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(win)]->getWindow()->getNativeWindow(), x, y); + } + void Application::getScreenSize(void* win, int* w, int* h) noexcept { CHECK_WINDOW_PTR(win); diff --git a/src/core/bridge.cpp b/src/core/bridge.cpp index 9fb6b5a..debed1c 100644 --- a/src/core/bridge.cpp +++ b/src/core/bridge.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */ -/* Updated: 2024/02/23 22:37:24 by maldavid ### ########.fr */ +/* Updated: 2024/09/12 01:29:33 by tdelage ### ########.fr */ /* */ /* ************************************************************************** */ @@ -62,6 +62,12 @@ extern "C" return 0; } + void mlx_set_window_position(void *mlx, void *win, int x, int y) + { + MLX_CHECK_APPLICATION_POINTER(mlx); + static_cast(mlx)->setWindowPosition(win, x, y); + } + int mlx_loop(void* mlx) { MLX_CHECK_APPLICATION_POINTER(mlx); From 4f6886517e62ef1b3ff723f396c23318d1a68731 Mon Sep 17 00:00:00 2001 From: kbz_8 Date: Thu, 12 Sep 2024 03:32:08 +0200 Subject: [PATCH 3/3] fixing codestyle in application.inl --- src/core/application.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/application.inl b/src/core/application.inl index 1500667..be5e7c4 100644 --- a/src/core/application.inl +++ b/src/core/application.inl @@ -72,7 +72,8 @@ namespace mlx::core _in->onEvent(_graphics[*static_cast(win)]->getWindow()->getID(), event, funct_ptr, param); } - void Application::setWindowPosition(void *win, int x, int y) { + void Application::setWindowPosition(void* win, int x, int y) + { CHECK_WINDOW_PTR(win); if(!_graphics[*static_cast(win)]->hasWindow()) {