18 "WindowManager initialized");
27 GLFWSingleton::terminate();
31 "WindowManager destroyed");
38 "Window with title '{}' already exists", create_info.
title);
43 "Creating window '{}' ({}x{}), for platform {}", create_info.
title, create_info.
width, create_info.
height, get_platform_name());
53 if (window->get_create_info().register_for_processing) {
58 "Created window '{}' - total: {}", create_info.
title,
m_windows.size());
73 const std::string title = window->get_create_info().title;
76 auto it = std::ranges::find(
m_windows, window);
80 "Destroyed window '{}' - remaining: {}", title,
m_windows.size());
83 if (!cleanup_backend) {
95 "Backend resources for window '{}' cleaned up", title);
110 std::vector<std::shared_ptr<Window>> ptrs;
135 [](
const auto& w) {
return w->should_close(); });
140 size_t destroyed_count = 0;
142 std::vector<std::shared_ptr<Window>> to_destroy;
144 if (window->should_close()) {
145 to_destroy.push_back(window);
149 for (
auto& window : to_destroy) {
154 if (destroyed_count > 0) {
156 "Destroyed {} closed window(s)", destroyed_count);
159 return destroyed_count;
167#if defined(GLFW_BACKEND)
172 "GLFW backend not compiled in");
177#if defined(MAYAFLUX_PLATFORM_WINDOWS)
178 return std::make_shared<Win32Window>(create_info,
m_config);
181 "Native Win32 backend not implemented on this platform");
186#if defined(MAYAFLUX_PLATFORM_LINUX)
187 return std::make_shared<WaylandWindow>(create_info,
m_config);
190 "Wayland native backend not compiled in");
196 "Unknown windowing backend: {}",
204 const auto& title = window->get_create_info().title;
211#if defined(GLFW_BACKEND)
233 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::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 (GLFW, SDL)
@ Core
Core engine, backend, subsystems.
auto dispatch_main_sync(Func &&func, Args &&... args) -> decltype(auto)
GraphicsSurfaceInfo surface_info
System-wide configuration for visual stream processing.
@ GLFW
GLFW3 (default, cross-platform)
WindowingBackend windowing_backend
Selected windowing backend.
GraphicsApi requested_api
Selected graphics API for rendering.
std::string title
Window title/identifier.
uint32_t width
Initial window dimensions.
Configuration for creating a single window instance.