From 138b5d351e6671f414281a9e098944178d6c28b0 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 27 Sep 2026 19:17:38 +0200 Subject: [PATCH 1/3] fix(wsi) update wsi module against new convetion --- examples/wsi/events/src/main.cpp | 9 ++- examples/wsi/framebuffer/src/main.cpp | 10 ++- modules/stormkit/core/meta/concepts.cppm | 3 + modules/stormkit/wsi/core.cppm | 13 +--- modules/stormkit/wsi/keyboard.cppm | 16 ++--- modules/stormkit/wsi/monitor.cppm | 35 ++++------ modules/stormkit/wsi/mouse.cppm | 15 ++--- modules/stormkit/wsi/window.cppm | 83 +++++++++++------------- src/wsi/common/input_base.cppm | 3 +- src/wsi/common/window_base.cppm | 24 ++++--- src/wsi/linux/wayland/log.cppm | 67 ++++++++++++++++++- src/wsi/linux/x11/log.cppm | 67 ++++++++++++++++++- src/wsi/win32/keyboard.cppm | 2 +- src/wsi/win32/log.cppm | 67 ++++++++++++++++++- src/wsi/win32/mouse.cppm | 20 +++--- xmake/options.xmake.lua | 2 +- xmake/targets/wsi.xmake.lua | 2 +- 17 files changed, 307 insertions(+), 131 deletions(-) diff --git a/examples/wsi/events/src/main.cpp b/examples/wsi/events/src/main.cpp index 062ef83d5..03fc442d6 100644 --- a/examples/wsi/events/src/main.cpp +++ b/examples/wsi/events/src/main.cpp @@ -8,13 +8,18 @@ import stormkit; #include -LOGGER("Events"); - using namespace stormkit; using namespace std::literals; namespace stdr = std::ranges; +constexpr auto LOG_MODULE = log::module { "events" }; + +template +inline auto ilog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.ilog(std::move(format), std::forward(args)...); +} + //////////////////////////////////////// //////////////////////////////////////// auto main(array_view args) -> int { diff --git a/examples/wsi/framebuffer/src/main.cpp b/examples/wsi/framebuffer/src/main.cpp index d471bfb31..2111b233d 100644 --- a/examples/wsi/framebuffer/src/main.cpp +++ b/examples/wsi/framebuffer/src/main.cpp @@ -8,13 +8,19 @@ import stormkit; #include -LOGGER("Framebuffer"); - using namespace stormkit; +using namespace stormkit::literals; using namespace std::literals; namespace stdr = std::ranges; +constexpr auto LOG_MODULE = log::module { "framebuffer" }; + +template +inline auto ilog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.ilog(std::move(format), std::forward(args)...); +} + auto update_pixels(stormkit::thread_pool& pool, dynarray& pixels, const auto& extent) noexcept { const auto rect_width = extent.width / 5; const auto rect_height = extent.height / 5; diff --git a/modules/stormkit/core/meta/concepts.cppm b/modules/stormkit/core/meta/concepts.cppm index c68616c5a..a35c32853 100644 --- a/modules/stormkit/core/meta/concepts.cppm +++ b/modules/stormkit/core/meta/concepts.cppm @@ -36,6 +36,9 @@ export namespace stormkit { inline namespace core { namespace meta { using std::convertible_to; + template + concept convertible_to_any_of = (convertible_to or ...); + template concept explicitly_convertible_to = convertible_to or requires(From val) { static_cast(val); }; diff --git a/modules/stormkit/wsi/core.cppm b/modules/stormkit/wsi/core.cppm index 2a81971ec..a618fd3ba 100644 --- a/modules/stormkit/wsi/core.cppm +++ b/modules/stormkit/wsi/core.cppm @@ -26,8 +26,8 @@ export namespace stormkit::wsi { SWITCH, }; - constexpr auto as_string(WM wm) noexcept -> string_view; - constexpr auto to_string(WM wm) noexcept -> string; + [[nodiscard]] + constexpr auto tag_invoke(as_fn, WM value, const std::source_location&) noexcept -> string_view; STORMKIT_WSI_API auto parse_args(array_view args) noexcept -> void; @@ -44,7 +44,7 @@ namespace stormkit::wsi { //////////////////////////////////////// //////////////////////////////////////// STORMKIT_FORCE_INLINE STORMKIT_CONST - constexpr auto as_string(WM wm) noexcept -> string_view { + constexpr auto tag_invoke(as_fn, WM wm, const std::source_location&) noexcept -> string_view { switch (wm) { case WM::WIN32: return "WM::WIN32"; case WM::WAYLAND: return "WM::WAYLAND"; @@ -59,11 +59,4 @@ namespace stormkit::wsi { std::unreachable(); } - - //////////////////////////////////////// - //////////////////////////////////////// - STORMKIT_FORCE_INLINE - constexpr auto to_string(WM wm) noexcept -> string { - return string { as_string(wm) }; - } } // namespace stormkit::wsi diff --git a/modules/stormkit/wsi/keyboard.cppm b/modules/stormkit/wsi/keyboard.cppm index e01b8b205..01eac1cc3 100644 --- a/modules/stormkit/wsi/keyboard.cppm +++ b/modules/stormkit/wsi/keyboard.cppm @@ -12,6 +12,8 @@ import std; import stormkit.core; +using namespace stormkit::literals; + export namespace stormkit::wsi { inline constexpr auto GLOBAL_KEYBOARD_ID = 0_u8; @@ -142,8 +144,9 @@ export namespace stormkit::wsi { UNKNOWN = std::numeric_limits::max(), }; - constexpr auto as_string(Key key) noexcept -> string_view; - constexpr auto to_string(Key key) noexcept -> string; + + [[nodiscard]] + constexpr auto tag_invoke(as_fn, Key key, const std::source_location&) noexcept -> string_view; } // namespace stormkit::wsi //////////////////////////////////////////////////////////////////// @@ -154,7 +157,7 @@ namespace stormkit::wsi { //////////////////////////////////////// //////////////////////////////////////// STORMKIT_FORCE_INLINE STORMKIT_CONST - constexpr auto as_string(Key key) noexcept -> string_view { + constexpr auto tag_invoke(as_fn, Key key, const std::source_location&) noexcept -> string_view { switch (key) { case Key::A: return "Key::A"; case Key::B: return "Key::B"; @@ -284,11 +287,4 @@ namespace stormkit::wsi { } std::unreachable(); } - - //////////////////////////////////////// - //////////////////////////////////////// - STORMKIT_FORCE_INLINE - constexpr auto to_string(Key key) noexcept -> string { - return string { as_string(key) }; - } } // namespace stormkit::wsi diff --git a/modules/stormkit/wsi/monitor.cppm b/modules/stormkit/wsi/monitor.cppm index 004ff8181..31fdbf24f 100644 --- a/modules/stormkit/wsi/monitor.cppm +++ b/modules/stormkit/wsi/monitor.cppm @@ -13,6 +13,7 @@ export module stormkit.wsi:monitor; import std; import stormkit.core; +import stormkit.math.extent; export { namespace stormkit::wsi { @@ -37,13 +38,14 @@ export { void* native_handle = nullptr; }; - constexpr auto as_string(Monitor::Flags flags) noexcept -> string_view; - constexpr auto to_string(Monitor::Flags flags) noexcept -> string; - - auto to_string(const Monitor& monitor) noexcept -> string; + [[nodiscard]] + constexpr auto tag_invoke(as_fn, + Monitor::Flags value, + source_location_arg = std::source_location::current()) noexcept -> string_view; - template - auto format_as(const Monitor& monitor, FormatContext& ctx) noexcept -> decltype(ctx.out()); + template + constexpr auto tag_invoke(format_as_fn, const Monitor& monitor, meta::format_context auto& ctx) noexcept + -> decltype(ctx.out()); [[nodiscard]] STORMKIT_WSI_API auto get_monitors(bool update = false) noexcept -> array_view; @@ -105,7 +107,7 @@ namespace stormkit::wsi { //////////////////////////////////////// //////////////////////////////////////// STORMKIT_FORCE_INLINE STORMKIT_CONST - constexpr auto as_string(Monitor::Flags flags) noexcept -> string_view { + constexpr auto tag_invoke(as_fn, Monitor::Flags flags, source_location_arg) noexcept -> string_view { switch (flags) { case Monitor::Flags::NONE: return "Monitor::Flags::NONE"; case Monitor::Flags::PRIMARY: return "Monitor::Flags::PRIMARY"; @@ -117,23 +119,10 @@ namespace stormkit::wsi { //////////////////////////////////////// //////////////////////////////////////// + template STORMKIT_FORCE_INLINE - constexpr auto to_string(Monitor::Flags flags) noexcept -> string { - return string { as_string(flags) }; - } - - //////////////////////////////////////// - //////////////////////////////////////// - STORMKIT_FORCE_INLINE - inline auto to_string(const Monitor& monitor) noexcept -> string { - return std::format("{}", monitor); - } - - //////////////////////////////////////// - //////////////////////////////////////// - template - STORMKIT_FORCE_INLINE - inline auto format_as(const Monitor& monitor, FormatContext& ctx) noexcept -> decltype(ctx.out()) { + constexpr auto tag_invoke(format_as_fn, const Monitor& monitor, meta::format_context auto& ctx) noexcept + -> decltype(ctx.out()) { return std::format_to(ctx.out(), "[Monitor name: {}, flags: {}, extents: {}, scale_factor: {}]", monitor.name, diff --git a/modules/stormkit/wsi/mouse.cppm b/modules/stormkit/wsi/mouse.cppm index 77c1f4af2..03a12f75e 100644 --- a/modules/stormkit/wsi/mouse.cppm +++ b/modules/stormkit/wsi/mouse.cppm @@ -12,6 +12,8 @@ import std; import stormkit.core; +using namespace stormkit::literals; + export namespace stormkit::wsi { inline constexpr auto GLOBAL_MOUSE_ID = 0_u8; @@ -33,8 +35,8 @@ export namespace stormkit::wsi { BUTTON_12, }; - constexpr auto as_string(MouseButton button) noexcept -> string_view; - constexpr auto to_string(MouseButton button) noexcept -> string; + [[nodiscard]] + constexpr auto tag_invoke(as_fn, MouseButton button, const std::source_location&) noexcept -> string_view; } // namespace stormkit::wsi //////////////////////////////////////////////////////////////////// @@ -45,7 +47,7 @@ namespace stormkit::wsi { //////////////////////////////////////// //////////////////////////////////////// STORMKIT_FORCE_INLINE STORMKIT_CONST - constexpr auto as_string(MouseButton button) noexcept -> string_view { + constexpr auto tag_invoke(as_fn, MouseButton button, const std::source_location&) noexcept -> string_view { switch (button) { case MouseButton::LEFT: return "MouseButton::LEFT"; case MouseButton::RIGHT: return "MouseButton::RIGHT"; @@ -67,11 +69,4 @@ namespace stormkit::wsi { std::unreachable(); } - - //////////////////////////////////////// - //////////////////////////////////////// - STORMKIT_FORCE_INLINE - constexpr auto to_string(MouseButton button) noexcept -> string { - return string { as_string(button) }; - } } // namespace stormkit::wsi diff --git a/modules/stormkit/wsi/window.cppm b/modules/stormkit/wsi/window.cppm index abb68ba35..c1324da59 100644 --- a/modules/stormkit/wsi/window.cppm +++ b/modules/stormkit/wsi/window.cppm @@ -13,6 +13,8 @@ export module stormkit.wsi:window; import std; import stormkit.core; +import stormkit.math.extent; +import stormkit.math.linear; import :core; import :monitor; @@ -54,8 +56,11 @@ export { ACTIVATE, DEACTIVATE, }; - constexpr auto as_string(EventType type) noexcept -> string_view; - constexpr auto to_string(EventType type) noexcept -> string; + + [[nodiscard]] + constexpr auto tag_invoke(as_fn, + EventType value, + source_location_arg = std::source_location::current()) noexcept -> string_view; using NativeHandle = void*; @@ -108,7 +113,7 @@ export { }; template - concept EventCallbackFunc = meta::IsConvertibleToOneOf< + concept EventCallbackFunc = meta::convertible_to_any_of< T, ClosedEventFunc, MonitorChangedEventFunc, @@ -130,8 +135,8 @@ export { Window(Window&&) noexcept; auto operator=(Window&&) noexcept -> Window&; - static auto open(string title, const math::uextent2& size, WindowFlag flags) noexcept -> Window; - static auto allocate_and_open(string title, const math::uextent2& size, WindowFlag flags) noexcept + static auto open(string title, meta::in size, WindowFlag flags) noexcept -> Window; + static auto allocate_and_open(string title, meta::in size, WindowFlag flags) noexcept -> heap_ptr; auto close() noexcept -> void; @@ -139,7 +144,7 @@ export { auto is_open() const noexcept -> bool; auto handle_events() noexcept -> void; - auto clear(const ucolor_rgb& color = colors::BLACK) noexcept -> void; + auto clear(meta::in color = colors::BLACK) noexcept -> void; auto fill_framebuffer(array_view colors) noexcept -> void; template @@ -160,9 +165,10 @@ export { [[nodiscard]] auto title() const noexcept -> const string&; - auto set_title(string title) noexcept -> void; + auto set_title(const string& title) noexcept -> void; + auto set_title(string&& title) noexcept -> void; - auto set_extent(const math::uextent2& extent) noexcept -> void; + auto set_extent(meta::in extent) noexcept -> void; [[nodiscard]] auto extent() const noexcept -> const math::uextent2&; @@ -207,7 +213,7 @@ export { [[nodiscard]] auto is_virtual_keyboard_visible() const noexcept -> bool; - auto set_mouse_position(const math::ivec2& position, u8 mouse_id = GLOBAL_MOUSE_ID) noexcept -> void; + auto set_mouse_position(meta::in position, u8 mouse_id = GLOBAL_MOUSE_ID) noexcept -> void; [[nodiscard]] auto native_handle() const noexcept -> NativeHandle; @@ -256,33 +262,27 @@ namespace stormkit::wsi { //////////////////////////////////////// //////////////////////////////////////// STORMKIT_FORCE_INLINE STORMKIT_CONST - constexpr auto as_string(WindowFlag flag) noexcept -> string_view { - using Pair = std::pair; - static constexpr auto MAPPING = core::generate_substitutions_as_string_for( + constexpr auto tag_invoke(as_fn, WindowFlag flags, source_location_arg) noexcept -> string_view { + using pair = std::pair; + static constexpr auto MAPPING = core::generate_substitution_strings_for( "WindowFlag::", - { - Pair { WindowFlag::DEFAULT, "DEFAULT"sv }, - Pair { WindowFlag::BORDERLESS, "BORDERLESS"sv }, - Pair { WindowFlag::RESIZEABLE, "RESIZEABLE"sv }, - Pair { WindowFlag::EXTERNAL_CONTEXT, "EXTERNAL_CONTEXT"sv }, + array { + pair { WindowFlag::DEFAULT, "DEFAULT"sv }, + pair { WindowFlag::BORDERLESS, "BORDERLESS"sv }, + pair { WindowFlag::RESIZEABLE, "RESIZEABLE"sv }, + pair { WindowFlag::EXTERNAL_CONTEXT, "EXTERNAL_CONTEXT"sv }, }); - const auto it = stdr::find_if(MAPPING, [&flag](auto&& pair) { return pair.first == flag; }); + const auto it = stdr::find_if(MAPPING, [flags](auto&& pair) { return pair.first == flags; }); ensures(it != stdr::cend(MAPPING)); - return it->second; - } - //////////////////////////////////////// - //////////////////////////////////////// - STORMKIT_FORCE_INLINE - constexpr auto to_string(WindowFlag flag) noexcept -> string { - return string { as_string(flag) }; + return it->second; } //////////////////////////////////////// //////////////////////////////////////// STORMKIT_FORCE_INLINE STORMKIT_CONST - constexpr auto as_string(EventType type) noexcept -> string_view { + constexpr auto tag_invoke(as_fn, EventType type, source_location_arg) noexcept -> string_view { switch (type) { case EventType::NONE: return "EventType::NONE"; case EventType::CLOSED: return "EventType::CLOSED"; @@ -302,40 +302,33 @@ namespace stormkit::wsi { std::unreachable(); } - //////////////////////////////////////// - //////////////////////////////////////// - STORMKIT_FORCE_INLINE - constexpr auto to_string(EventType type) noexcept -> string { - return string { as_string(type) }; - } - //////////////////////////////////////// //////////////////////////////////////// template STORMKIT_FORCE_INLINE inline auto Window::on(T&& callback) noexcept -> void { - if constexpr (meta::IsCanonical) on_closed(std::forward(callback)); - else if constexpr (meta::IsCanonical) + if constexpr (meta::plain::is) on_closed(std::forward(callback)); + else if constexpr (meta::plain::is) on_monitor_changed(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_resized(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_restored(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_minimized(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_key_down(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_key_up(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_mouse_button_down(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_mouse_button_up(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_mouse_moved(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_activate(std::forward(callback)); - else if constexpr (meta::IsCanonical) + else if constexpr (meta::plain::is) on_deactivate(std::forward(callback)); } diff --git a/src/wsi/common/input_base.cppm b/src/wsi/common/input_base.cppm index 183cfa752..69cae00bf 100644 --- a/src/wsi/common/input_base.cppm +++ b/src/wsi/common/input_base.cppm @@ -13,6 +13,7 @@ import std; import stormkit.core; import stormkit.wsi; +import stormkit.math.linear; import :mouse; import :keyboard; @@ -89,6 +90,6 @@ namespace stormkit::wsi::common { constexpr auto as_index(Key key) noexcept -> usize { EXPECTS(key != Key::UNKNOWN); - return unchecked_narrow(key); + return as(key); } } // namespace stormkit::wsi::common diff --git a/src/wsi/common/window_base.cppm b/src/wsi/common/window_base.cppm index dea585fdf..32ff04ce7 100644 --- a/src/wsi/common/window_base.cppm +++ b/src/wsi/common/window_base.cppm @@ -4,6 +4,7 @@ module; +#include #include export module stormkit.wsi:common.window_base; @@ -11,6 +12,8 @@ export module stormkit.wsi:common.window_base; import std; import stormkit.core; +import stormkit.math.extent; +import stormkit.math.linear; import stormkit.wsi; import :common.input_base; @@ -93,14 +96,14 @@ export namespace stormkit::wsi::common { protected: struct { - bool open = false; - bool minimized = false; - bool active = false; - bool fullscreen = false; - bool visible = false; - math::uextent2 extent; - optref current_monitor; - string title; + bool open = false; + bool minimized = false; + bool active = false; + bool fullscreen = false; + bool visible = false; + math::uextent2 extent; + std::optional current_monitor; + string title; f32 dpi = 1.f; @@ -142,14 +145,15 @@ namespace stormkit::wsi::common { ///////////////////////////////////// STORMKIT_FORCE_INLINE inline auto WindowBase::current_monitor() const noexcept -> const Monitor& { - return m_state.current_monitor; + EXPECTS(m_state.current_monitor != std::nullopt); + return m_state.current_monitor.value(); } ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE inline auto WindowBase::set_current_monitor(const Monitor& monitor) noexcept -> void { - m_state.current_monitor = as_optref(monitor); + m_state.current_monitor = monitor; } ///////////////////////////////////// diff --git a/src/wsi/linux/wayland/log.cppm b/src/wsi/linux/wayland/log.cppm index ae06043af..b5cdd3d11 100644 --- a/src/wsi/linux/wayland/log.cppm +++ b/src/wsi/linux/wayland/log.cppm @@ -2,6 +2,10 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include + export module stormkit.wsi:linux.wayland.log; import std; @@ -10,5 +14,66 @@ import stormkit.core; import stormkit.log; export namespace stormkit::wsi::linux::wayland { - IN_MODULE_LOGGER("StormKit.Wsi.Linux.Wayland") + template + auto dlog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto ilog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto wlog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto elog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto flog(std::format_string format, Ts&&... args) noexcept -> void; +} // namespace stormkit::wsi::linux::wayland + +//////////////////////////////////////////////////////////////////// +/// IMPLEMENTATION /// +//////////////////////////////////////////////////////////////////// + +namespace stormkit::wsi::linux::wayland { + constexpr auto LOG_MODULE = log::module { "stormkit.wsi.linux.wayland" }; + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto dlog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.dlog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto ilog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.ilog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto wlog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.wlog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto elog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.elog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto flog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.flog(std::move(format), std::forward(args)...); + } } // namespace stormkit::wsi::linux::wayland diff --git a/src/wsi/linux/x11/log.cppm b/src/wsi/linux/x11/log.cppm index 2a3dbada3..725d1980a 100644 --- a/src/wsi/linux/x11/log.cppm +++ b/src/wsi/linux/x11/log.cppm @@ -2,6 +2,10 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include + export module stormkit.wsi:linux.x11.log; import std; @@ -10,5 +14,66 @@ import stormkit.core; import stormkit.log; export namespace stormkit::wsi::linux::x11 { - IN_MODULE_LOGGER("StormKit.Wsi.Linux.X11") + template + auto dlog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto ilog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto wlog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto elog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto flog(std::format_string format, Ts&&... args) noexcept -> void; +} // namespace stormkit::wsi::linux::x11 + +//////////////////////////////////////////////////////////////////// +/// IMPLEMENTATION /// +//////////////////////////////////////////////////////////////////// + +namespace stormkit::wsi::linux::x11 { + constexpr auto LOG_MODULE = log::module { "stormkit.wsi.linux.x11" }; + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto dlog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.dlog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto ilog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.ilog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto wlog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.wlog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto elog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.elog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto flog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.flog(std::move(format), std::forward(args)...); + } } // namespace stormkit::wsi::linux::x11 diff --git a/src/wsi/win32/keyboard.cppm b/src/wsi/win32/keyboard.cppm index 9ea95c6d1..6bc7516d0 100644 --- a/src/wsi/win32/keyboard.cppm +++ b/src/wsi/win32/keyboard.cppm @@ -157,7 +157,7 @@ namespace stormkit::wsi::win32 { auto i = 0_usize; for (const auto& [key, value] : SCANCODE_AS_KEY) out[i++] = std::make_pair(value.first, key); - return make_static_hash_map(out); + return make_static_hash_map(std::move(out)); }(); } // namespace diff --git a/src/wsi/win32/log.cppm b/src/wsi/win32/log.cppm index 1466e5933..ddd6d9e88 100644 --- a/src/wsi/win32/log.cppm +++ b/src/wsi/win32/log.cppm @@ -2,6 +2,10 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include + export module stormkit.wsi:win32.log; import std; @@ -10,5 +14,66 @@ import stormkit.core; import stormkit.log; export namespace stormkit::wsi::win32 { - IN_MODULE_LOGGER("StormKit.Wsi.Win32") + template + auto dlog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto ilog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto wlog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto elog(std::format_string format, Ts&&... args) noexcept -> void; + + template + auto flog(std::format_string format, Ts&&... args) noexcept -> void; +} // namespace stormkit::wsi::win32 + +//////////////////////////////////////////////////////////////////// +/// IMPLEMENTATION /// +//////////////////////////////////////////////////////////////////// + +namespace stormkit::wsi::win32 { + constexpr auto LOG_MODULE = log::module { "stormkit.wsi.win32" }; + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto dlog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.dlog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto ilog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.ilog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto wlog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.wlog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto elog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.elog(std::move(format), std::forward(args)...); + } + + //////////////////////////////////////// + //////////////////////////////////////// + template + STORMKIT_FORCE_INLINE + inline auto flog(std::format_string format, Ts&&... args) noexcept -> void { + LOG_MODULE.flog(std::move(format), std::forward(args)...); + } } // namespace stormkit::wsi::win32 diff --git a/src/wsi/win32/mouse.cppm b/src/wsi/win32/mouse.cppm index 41ca6ce01..251b95896 100644 --- a/src/wsi/win32/mouse.cppm +++ b/src/wsi/win32/mouse.cppm @@ -11,16 +11,16 @@ module; export module stormkit.wsi:win32.mouse; +import std; + import stormkit.core; +import stormkit.math.linear; import stormkit.wsi; export namespace stormkit::wsi::win32 { - constexpr auto extract_mouse_button(UINT message, WPARAM w_param, LPARAM l_param) noexcept - -> MouseButton; - constexpr auto extract_mouse_position(HWND handle, - WPARAM w_param, - LPARAM l_param, - bool to_client = true) noexcept -> math::ivec2; + constexpr auto extract_mouse_button(UINT message, WPARAM w_param, LPARAM l_param) noexcept -> MouseButton; + constexpr auto extract_mouse_position(HWND handle, WPARAM w_param, LPARAM l_param, bool to_client = true) noexcept + -> math::ivec2; } // namespace stormkit::wsi::win32 //////////////////////////////////////////////////////////////////// @@ -31,8 +31,7 @@ namespace stormkit::wsi::win32 { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_CONST - constexpr auto extract_mouse_button(UINT message, WPARAM w_param, LPARAM) noexcept - -> MouseButton { + constexpr auto extract_mouse_button(UINT message, WPARAM w_param, LPARAM) noexcept -> MouseButton { switch (message) { case WM_LBUTTONDOWN: [[fallthrough]]; case WM_LBUTTONUP: return MouseButton::LEFT; @@ -54,10 +53,7 @@ namespace stormkit::wsi::win32 { ///////////////////////////////////// ///////////////////////////////////// - constexpr auto extract_mouse_position(HWND handle, - WPARAM, - LPARAM l_param, - bool to_client) noexcept -> math::ivec2 { + constexpr auto extract_mouse_position(HWND handle, WPARAM, LPARAM l_param, bool to_client) noexcept -> math::ivec2 { auto position = POINT { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) }; if (to_client) ScreenToClient(handle, &position); diff --git a/xmake/options.xmake.lua b/xmake/options.xmake.lua index 6029a4c69..20383a48e 100644 --- a/xmake/options.xmake.lua +++ b/xmake/options.xmake.lua @@ -57,7 +57,7 @@ option("log", { default = true, category = "root menu/modules" }) option("math", { default = true, category = "root menu/modules" }) option("entities", { default = false, category = "root menu/modules" }) option("image", { default = true, category = "root menu/modules", deps = { "math", "log" } }) -option("wsi", { default = false, category = "root menu/modules", deps = { "log" } }) +option("wsi", { default = true, category = "root menu/modules", deps = { "log" } }) option("gpu", { default = false, category = "root menu/modules", deps = { "log", "image", "wsi" } }) option("lua", { default = false, category = "root menu/modules", deps = { "log" } }) diff --git a/xmake/targets/wsi.xmake.lua b/xmake/targets/wsi.xmake.lua index add7c89f9..bc812a732 100644 --- a/xmake/targets/wsi.xmake.lua +++ b/xmake/targets/wsi.xmake.lua @@ -105,7 +105,7 @@ target("wsi", function() add_headerfiles(path.join(include_dir, "(stormkit/wsi/**.hpp)")) add_includedirs(include_dir, { public = true }) - add_deps("core", "log") + add_deps("core", "log", "math") add_packages(packages, { public = false }) From b7d0112a57a8118b673dcd2bf30cd0fd151a6cbb Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 27 Sep 2026 19:29:27 +0200 Subject: [PATCH 2/3] . --- modules/stormkit/core/containers/shmbuffer.cppm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/stormkit/core/containers/shmbuffer.cppm b/modules/stormkit/core/containers/shmbuffer.cppm index 2b920e517..2d8439f76 100644 --- a/modules/stormkit/core/containers/shmbuffer.cppm +++ b/modules/stormkit/core/containers/shmbuffer.cppm @@ -7,6 +7,7 @@ module; #include #include #include +#include export module stormkit.core.containers.shmbuffer; @@ -84,7 +85,7 @@ namespace stormkit { inline namespace core { STORMKIT_FORCE_INLINE inline auto shm_buffer::create(usize size, string name, io::access access) noexcept -> system_result { auto out = shm_buffer { PRIVATE }; - out.do_init(size, std::move(name), access); + Try(out.do_init(size, std::move(name), access)); return out; } @@ -93,7 +94,7 @@ namespace stormkit { inline namespace core { STORMKIT_FORCE_INLINE inline auto shm_buffer::allocate(usize size, string name, io::access access) noexcept -> system_result> { auto out = allocate_unsafe(PRIVATE); - out->do_init(size, std::move(name), access); + Try(out->do_init(size, std::move(name), access)); return out; } From 331b2110e1008f64069a4d2862ad711aadd2dd48 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 27 Sep 2026 20:46:59 +0200 Subject: [PATCH 3/3] . --- .../stormkit/core/containers/hash_map.cppm | 22 ++++++++++++++ .../stormkit/core/typesafe/checked_value.cppm | 4 +-- modules/stormkit/math/geometry.cppm | 2 +- src/wsi/common/window_base.cppm | 30 +++++++++++++------ src/wsi/linux/wayland/window.cpp | 15 ++++++---- src/wsi/linux/wayland/window.cppm | 2 +- src/wsi/linux/window.cppm | 4 +-- src/wsi/win32/keyboard.cppm | 8 ++--- src/wsi/win32/monitor.cppm | 4 +-- src/wsi/win32/window.cpp | 6 ++-- src/wsi/win32/window.cppm | 16 +++++----- src/wsi/window.cpp | 16 ++++++---- xmake/targets/wsi.xmake.lua | 10 ++++++- 13 files changed, 95 insertions(+), 44 deletions(-) diff --git a/modules/stormkit/core/containers/hash_map.cppm b/modules/stormkit/core/containers/hash_map.cppm index b27b663a6..e8877980e 100644 --- a/modules/stormkit/core/containers/hash_map.cppm +++ b/modules/stormkit/core/containers/hash_map.cppm @@ -41,6 +41,12 @@ export namespace stormkit { inline namespace core { template constexpr auto make_static_hash_map(std::pair (&&pairs)[N]) noexcept -> static_hash_map; + + template + constexpr auto make_static_hash_map(std::array, N>& pairs) noexcept -> static_hash_map; + + template + constexpr auto make_static_hash_map(std::array, N>&& pairs) noexcept -> static_hash_map; }} // namespace stormkit::core export template @@ -72,4 +78,20 @@ namespace stormkit { inline namespace core { constexpr auto make_static_hash_map(std::pair (&&pairs)[N]) noexcept -> static_hash_map { return frozen::make_unordered_map(std::move(pairs)); } + + ///////////////////////////////////// + ///////////////////////////////////// + template + STORMKIT_FORCE_INLINE + constexpr auto make_static_hash_map(std::array, N>& pairs) noexcept -> static_hash_map { + return frozen::make_unordered_map(pairs); + } + + ///////////////////////////////////// + ///////////////////////////////////// + template + STORMKIT_FORCE_INLINE + constexpr auto make_static_hash_map(std::array, N>&& pairs) noexcept -> static_hash_map { + return frozen::make_unordered_map(std::move(pairs)); + } }} // namespace stormkit::core diff --git a/modules/stormkit/core/typesafe/checked_value.cppm b/modules/stormkit/core/typesafe/checked_value.cppm index 026ec206b..5d635eed8 100644 --- a/modules/stormkit/core/typesafe/checked_value.cppm +++ b/modules/stormkit/core/typesafe/checked_value.cppm @@ -32,7 +32,7 @@ export namespace stormkit { inline namespace core { public: using value_type = T; using reference_type = T&; - using const_reference_type = T&; + using const_reference_type = const meta::remove_const_of&; using copy_param_type = meta::in; using checked_param_type = meta::in; @@ -276,7 +276,7 @@ namespace stormkit { inline namespace core { requires(meta::destructible and meta::unary_predicate) STORMKIT_FORCE_INLINE constexpr checked_value::operator const_reference_type() const noexcept { - return value; + return std::as_const(value); } ///////////////////////////////////// diff --git a/modules/stormkit/math/geometry.cppm b/modules/stormkit/math/geometry.cppm index 30574591f..0092545aa 100644 --- a/modules/stormkit/math/geometry.cppm +++ b/modules/stormkit/math/geometry.cppm @@ -246,7 +246,7 @@ namespace stormkit::math { template STORMKIT_FORCE_INLINE STORMKIT_PURE constexpr auto AABB(const vec2& pos, const bounding_rect& rect) noexcept -> bool { - return pos.x >= rect.left and pos.x <= rect.right and pos.y >= rect.top and pos.y <= rect.bottom; + return pos.x() >= rect.left and pos.x() <= rect.right and pos.y() >= rect.top and pos.y() <= rect.bottom; } //////////////////////////////////////// diff --git a/src/wsi/common/window_base.cppm b/src/wsi/common/window_base.cppm index 32ff04ce7..e9526742e 100644 --- a/src/wsi/common/window_base.cppm +++ b/src/wsi/common/window_base.cppm @@ -7,6 +7,10 @@ module; #include #include +#if defined(STORMKIT_OS_WINDOWS) and not defined(STORMKIT_COMPILER_LIBCPP) + #include +#endif + export module stormkit.wsi:common.window_base; import std; @@ -50,7 +54,7 @@ export namespace stormkit::wsi::common { auto current_monitor() const noexcept -> const Monitor&; auto set_current_monitor(const Monitor& extent) noexcept -> void; - auto set_title(string title) noexcept -> bool; + auto set_title(string&& title) noexcept -> bool; [[nodiscard]] auto title() const noexcept -> const string&; @@ -96,14 +100,18 @@ export namespace stormkit::wsi::common { protected: struct { - bool open = false; - bool minimized = false; - bool active = false; - bool fullscreen = false; - bool visible = false; - math::uextent2 extent; + bool open = false; + bool minimized = false; + bool active = false; + bool fullscreen = false; + bool visible = false; + math::uextent2 extent; +#if defined(STORMKIT_OS_WINDOWS) and not defined(STORMKIT_COMPILER_LIBCPP) + beman::optional::optional current_monitor; +#else std::optional current_monitor; - string title; +#endif + string title; f32 dpi = 1.f; @@ -145,7 +153,11 @@ namespace stormkit::wsi::common { ///////////////////////////////////// STORMKIT_FORCE_INLINE inline auto WindowBase::current_monitor() const noexcept -> const Monitor& { +#if defined(STORMKIT_OS_WINDOWS) and not defined(STORMKIT_COMPILER_LIBCPP) + EXPECTS(m_state.current_monitor != beman::optional::nullopt); +#else EXPECTS(m_state.current_monitor != std::nullopt); +#endif return m_state.current_monitor.value(); } @@ -159,7 +171,7 @@ namespace stormkit::wsi::common { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - inline auto WindowBase::set_title(string title) noexcept -> bool { + inline auto WindowBase::set_title(string&& title) noexcept -> bool { if (not m_state.open) return false; m_state.title = std::move(title); diff --git a/src/wsi/linux/wayland/window.cpp b/src/wsi/linux/wayland/window.cpp index 4527dcb23..7fdbe0d30 100644 --- a/src/wsi/linux/wayland/window.cpp +++ b/src/wsi/linux/wayland/window.cpp @@ -221,9 +221,8 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto Window::set_title(string title) noexcept -> void { - if (!m_state.open) return; - m_title = std::move(title); + auto Window::set_title(string&& title) noexcept -> void { + WindowBase::set_title(std::move(title)); xdg_toplevel_set_title(m_xdg_top_level, stdr::data(m_title)); } @@ -261,7 +260,7 @@ namespace stormkit::wsi::linux::wayland { if (confined) { if (not has_flag_bit(state.flags, wl::PointerState::Flag::CONFINED)) { - state.confined_pointer = wl::ConfinedPointer :: + state.confined_pointer = wl::ConfinedPointer:: create(globals.pointer_constraints, m_surface, pointer, nullptr, ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT); zwp_confined_pointer_v1_add_listener(state.confined_pointer, &wl::g_confined_pointer_listener, &state); @@ -616,8 +615,12 @@ namespace stormkit::wsi::linux::wayland { unchecked_narrow(std::bit_cast(m_shm_buffer->native_handle())), unchecked_narrow(size)); - m_pixel_buffer = wl::Buffer:: - take(wl_shm_pool_create_buffer(m_shm_pool, 0, width, height, unchecked_narrow(stride), WL_SHM_FORMAT_XRGB8888)); + m_pixel_buffer = wl::Buffer::take(wl_shm_pool_create_buffer(m_shm_pool, + 0, + width, + height, + unchecked_narrow(stride), + WL_SHM_FORMAT_XRGB8888)); wl_buffer_add_listener(m_pixel_buffer, &wl::g_buffer_listener, &m_pixel_buffer); } diff --git a/src/wsi/linux/wayland/window.cppm b/src/wsi/linux/wayland/window.cppm index 584fdf680..3dd24970a 100644 --- a/src/wsi/linux/wayland/window.cppm +++ b/src/wsi/linux/wayland/window.cppm @@ -50,7 +50,7 @@ export { auto clear(const ucolor_rgb& color) noexcept -> void; auto fill_framebuffer(array_view colors) noexcept -> void; - auto set_title(string title) noexcept -> void; + auto set_title(string&& title) noexcept -> void; auto set_extent(const math::uextent2& extent) noexcept -> void; auto set_fullscreen(bool fullscreen) noexcept -> void; diff --git a/src/wsi/linux/window.cppm b/src/wsi/linux/window.cppm index 35da13714..f3231867c 100644 --- a/src/wsi/linux/window.cppm +++ b/src/wsi/linux/window.cppm @@ -52,7 +52,7 @@ export namespace stormkit::wsi::linux { auto clear(const ucolor_rgb& color) noexcept -> void; auto fill_framebuffer(array_view colors) noexcept -> void; - auto set_title(string title) noexcept -> void; + auto set_title(string&& title) noexcept -> void; [[nodiscard]] auto title() const noexcept -> const string&; @@ -243,7 +243,7 @@ namespace stormkit::wsi::linux { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - inline auto Window::set_title(string title) noexcept -> void { + inline auto Window::set_title(string&& title) noexcept -> void { switch (m_wm) { case WM::X11: as(m_impl).set_title(std::move(title)); break; case WM::WAYLAND: as(m_impl).set_title(std::move(title)); break; diff --git a/src/wsi/win32/keyboard.cppm b/src/wsi/win32/keyboard.cppm index 6bc7516d0..3e0c9fd40 100644 --- a/src/wsi/win32/keyboard.cppm +++ b/src/wsi/win32/keyboard.cppm @@ -152,13 +152,13 @@ namespace stormkit::wsi::win32 { { VK_NUMPAD9, { Key::NUMPAD_9, '9' } }, }); - constexpr auto KEY_AS_SCANCODE = [] static noexcept -> decltype(auto) { - auto out = array, 111> {}; + constexpr auto KEY_AS_SCANCODE = make_static_hash_map([] static noexcept -> decltype(auto) { + auto out = array, SCANCODE_AS_KEY.size()> {}; auto i = 0_usize; for (const auto& [key, value] : SCANCODE_AS_KEY) out[i++] = std::make_pair(value.first, key); - return make_static_hash_map(std::move(out)); - }(); + return out; + }()); } // namespace ///////////////////////////////////// diff --git a/src/wsi/win32/monitor.cppm b/src/wsi/win32/monitor.cppm index 3f6d0c461..98f15ebcc 100644 --- a/src/wsi/win32/monitor.cppm +++ b/src/wsi/win32/monitor.cppm @@ -47,7 +47,7 @@ namespace stormkit::wsi::win32 { auto load_monitors(HMONITOR native, HDC, LPRECT, LPARAM data) noexcept -> BOOL { if (native == nullptr) return TRUE; - auto& monitors = *std::bit_cast*>(data); + auto& monitors = *reinterpret_cast*>(data); monitors.emplace_back(load_monitor(native)); return TRUE; @@ -59,7 +59,7 @@ namespace stormkit::wsi::win32 { thread_local auto monitors = dynarray {}; if (update or stdr::empty(monitors)) - EnumDisplayMonitors(nullptr, nullptr, load_monitors, std::bit_cast(&monitors)); + EnumDisplayMonitors(nullptr, nullptr, load_monitors, reinterpret_cast(&monitors)); return monitors; } diff --git a/src/wsi/win32/window.cpp b/src/wsi/win32/window.cpp index 2bf934202..0c7893ddc 100644 --- a/src/wsi/win32/window.cpp +++ b/src/wsi/win32/window.cpp @@ -215,10 +215,10 @@ namespace stormkit::wsi::win32 { ///////////////////////////////////// ///////////////////////////////////// - auto Window::set_title(string title) noexcept -> void { - SetWindowTextA(m_window_handle, std::data(title)); - + auto Window::set_title(string&& title) noexcept -> void { WindowBase::set_title(std::move(title)); + + SetWindowTextA(m_window_handle, std::data(m_title)); } ///////////////////////////////////// diff --git a/src/wsi/win32/window.cppm b/src/wsi/win32/window.cppm index 4d1f5088e..ae54a78db 100644 --- a/src/wsi/win32/window.cppm +++ b/src/wsi/win32/window.cppm @@ -34,8 +34,7 @@ export namespace stormkit::wsi::win32 { Window(Window&&) noexcept; auto operator=(Window&&) noexcept -> Window&; - auto open(string title, const math::uextent2& size, WindowFlag flags) noexcept - -> void; + auto open(string title, const math::uextent2& size, WindowFlag flags) noexcept -> void; auto close() noexcept -> void; auto handle_events() noexcept -> void; @@ -43,7 +42,7 @@ export namespace stormkit::wsi::win32 { auto clear(const ucolor_rgb& color) noexcept -> void; auto fill_framebuffer(array_view colors) noexcept -> void; - auto set_title(string title) noexcept -> void; + auto set_title(string&& title) noexcept -> void; auto set_extent(const math::uextent2& extent) noexcept -> void; auto set_fullscreen(bool fullscreen) noexcept -> void; @@ -112,9 +111,8 @@ export namespace stormkit::wsi::win32 { HWND m_window_handle = nullptr; - using Hdc = raii_capsule; - using HBitmap - = raii_capsule; + using Hdc = raii_capsule; + using HBitmap = raii_capsule; struct GDIFrameData { GDIFrameData(); @@ -228,8 +226,10 @@ namespace stormkit::wsi::win32 { ///////////////////////////////////// STORMKIT_FORCE_INLINE inline Window::GDIFrameData::GDIFrameData(GDIFrameData&& other) noexcept - : context { std::move(other.context) }, bitmap { std::move(other.bitmap) }, - pixels_ptr { other.pixels_ptr.load() }, extent { other.extent } { + : context { std::move(other.context) }, + bitmap { std::move(other.bitmap) }, + pixels_ptr { other.pixels_ptr.load() }, + extent { other.extent } { } ///////////////////////////////////// diff --git a/src/wsi/window.cpp b/src/wsi/window.cpp index a5b8c32db..1146063f5 100644 --- a/src/wsi/window.cpp +++ b/src/wsi/window.cpp @@ -63,7 +63,7 @@ namespace stormkit::wsi { ///////////////////////////////////// ///////////////////////////////////// - auto Window::open(string title, const math::uextent2& size, WindowFlag flags) noexcept -> Window { + auto Window::open(string title, meta::in size, WindowFlag flags) noexcept -> Window { auto window = Window {}; window.m_impl->open(std::move(title), size, flags); return window; @@ -71,7 +71,7 @@ namespace stormkit::wsi { ///////////////////////////////////// ///////////////////////////////////// - auto Window::allocate_and_open(string title, const math::uextent2& size, WindowFlag flags) noexcept -> heap_ptr { + auto Window::allocate_and_open(string title, meta::in size, WindowFlag flags) noexcept -> heap_ptr { auto window = allocate_unsafe(Window {}); window->m_impl->open(std::move(title), size, flags); return window; @@ -85,7 +85,7 @@ namespace stormkit::wsi { ///////////////////////////////////// ///////////////////////////////////// - auto Window::clear(const ucolor_rgb& color) noexcept -> void { + auto Window::clear(meta::in color) noexcept -> void { m_impl->clear(color); } @@ -121,7 +121,13 @@ namespace stormkit::wsi { ///////////////////////////////////// ///////////////////////////////////// - auto Window::set_title(string title) noexcept -> void { + auto Window::set_title(const string& title) noexcept -> void { + m_impl->set_title(string { title }); + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto Window::set_title(string&& title) noexcept -> void { m_impl->set_title(std::move(title)); } @@ -133,7 +139,7 @@ namespace stormkit::wsi { ///////////////////////////////////// ///////////////////////////////////// - auto Window::set_extent(const math::uextent2& extent) noexcept -> void { + auto Window::set_extent(meta::in extent) noexcept -> void { m_impl->set_extent(extent); } diff --git a/xmake/targets/wsi.xmake.lua b/xmake/targets/wsi.xmake.lua index bc812a732..e580d181b 100644 --- a/xmake/targets/wsi.xmake.lua +++ b/xmake/targets/wsi.xmake.lua @@ -1,3 +1,8 @@ +local is_libcpp = false +if is_plat("linux") then + if has_config("runtimes") then is_libcpp = get_config("runtimes"):startswith("c++") end +end + if is_plat("linux") then add_requires("libxcb") add_requires("xcb-util-keysyms") @@ -16,6 +21,8 @@ if is_plat("linux") then }) end +if is_plat("windows") and not is_libcpp then add_requires("beman_optional") end + local src_wsi_dir = path.join(src_dir, "wsi") local module_wsi_dir = path.join(module_dir, "wsi") @@ -37,7 +44,7 @@ target("wsi", function() add_rules("wayland.protocols") - on_load(function(target) + on_load("linux", function(target) assert(target:pkg("wayland-protocols")) local wayland_protocols_dir = path.join(target:pkg("wayland-protocols"):installdir() or "/usr", "share", "wayland-protocols") @@ -75,6 +82,7 @@ target("wsi", function() elseif is_plat("windows") then add_files(path.join(src_wsi_dir, "win32/**.cpp"), path.join(src_wsi_dir, "win32/**.cppm")) add_syslinks("User32", "Shell32", "Gdi32", "Shcore", "Gdiplus") + if not is_libcpp then add_packages("beman_optional") end elseif is_plat("macosx") then add_files( path.join(src_wsi_dir, "macos/**.cpp"),