17 "WindowManager initialized");
26 "WindowManager destroyed");
33 "Window with title '{}' already exists", create_info.
title);
38 "Creating window '{}' ({}x{}), for platform {}", create_info.
title, create_info.
width, create_info.
height, get_platform_name());
45 if (!
window->get_native_handle()) {
47 "Window '{}' has no native handle after creation, discarding", create_info.
title);
54 if (
window->get_create_info().register_for_processing) {
59 "Created window '{}' - total: {}", create_info.
title,
m_windows.size());
74 const std::string title =
window->get_create_info().title;
81 "Destroyed window '{}' - remaining: {}", title,
m_windows.size());
84 if (!cleanup_backend) {
96 "Backend resources for window '{}' cleaned up", title);
111 std::vector<std::shared_ptr<Window>> ptrs;
136 [](
const auto& w) {
return w->should_close(); });
141 size_t destroyed_count = 0;
143 std::vector<std::shared_ptr<Window>> to_destroy;
145 if (
window->should_close()) {
146 to_destroy.push_back(
window);
150 for (
auto&
window : to_destroy) {
155 if (destroyed_count > 0) {
157 "Destroyed {} closed window(s)", destroyed_count);
160 return destroyed_count;
168#if defined(MAYAFLUX_PLATFORM_WINDOWS)
169 return std::make_shared<Win32Window>(create_info,
m_config);
172 "Native Win32 backend not implemented on this platform");
177#if defined(MAYAFLUX_PLATFORM_LINUX)
178 return std::make_shared<WaylandWindow>(create_info,
m_config);
181 "Native Wayland backend not implemented on this platform");
186#if defined(MAYAFLUX_PLATFORM_MACOS)
187 return std::make_shared<CocoaWindow>(create_info,
m_config);
190 "Native Cocoa backend not implemented on this platform");
196 "Unknown windowing backend: {}",
204 const auto& title =
window->get_create_info().title;
226 std::function<
void()> hook)
#define MF_INFO(comp, ctx,...)
#define MF_LOG(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::weak_ptr< Core::Window > window
std::shared_ptr< Window > get_window(size_t index) const
Gets window by index.
std::atomic< bool > m_terminate
bool process()
Process windows for one frame.
std::mutex m_hooks_mutex
Mutex for protecting m_windows and m_window_lookup.
std::vector< std::shared_ptr< Window > > get_windows() const
Gets all active windows.
std::vector< std::shared_ptr< Window > > m_windows
std::shared_ptr< Window > find_window(const std::string &title) const
Finds window by title.
WindowManager(const GlobalGraphicsConfig &config)
Constructs WindowManager with global graphics config.
std::shared_ptr< Window > create_window_internal(const WindowCreateInfo &create_info)
Factory for creating backend-specific windows.
bool any_window_should_close() const
Checks if any window should close.
void register_frame_hook(const std::string &name, std::function< void()> hook)
Register a hook that runs every frame.
size_t destroy_closed_windows()
Destroys all windows that should close.
void remove_from_lookup(const std::shared_ptr< Window > &window)
Removes window from lookup table.
std::shared_ptr< Window > create_window(const WindowCreateInfo &create_info)
Creates a new window.
GlobalGraphicsConfig m_config
std::unordered_map< std::string, std::function< void()> > m_frame_hooks
Calls all registered frame hooks.
std::unordered_map< std::string, std::weak_ptr< Window > > m_window_lookup
bool destroy_window_by_title(const std::string &title)
Destroys a window by title.
std::vector< std::shared_ptr< Window > > m_processing_windows
size_t window_count() const
Gets number of active windows.
void unregister_frame_hook(const std::string &name)
Unregister a previously registered frame hook.
void destroy_window(const std::shared_ptr< Window > &window, bool cleanup_backend=false)
Destroys a window by pointer.
@ WindowingSubsystem
Windowing system operations (Win32, Wayland, Cocoa)
@ Core
Core engine, backend, subsystems.
auto dispatch_main_sync(Func &&func, Args &&... args) -> decltype(auto)
WindowingBackend windowing_backend
Selected windowing backend.
std::string title
Window title/identifier.
uint32_t width
Initial window dimensions.
Configuration for creating a single window instance.