15 "WindowManager initialized");
26 "WindowManager destroyed");
33 "Window with title '{}' already exists", create_info.
title);
48 if (window->get_create_info().register_for_processing) {
53 "Created window '{}' - total: {}", create_info.
title,
m_windows.size());
68 const std::string title = window->get_create_info().title;
71 auto it = std::ranges::find(
m_windows, window);
75 "Destroyed window '{}' - remaining: {}", title,
m_windows.size());
78 if (!cleanup_backend) {
90 "Backend resources for window '{}' cleaned up", title);
105 std::vector<std::shared_ptr<Window>> ptrs;
130 [](
const auto& w) {
return w->should_close(); });
135 size_t destroyed_count = 0;
137 std::vector<std::shared_ptr<Window>> to_destroy;
139 if (window->should_close()) {
140 to_destroy.push_back(window);
144 for (
auto& window : to_destroy) {
149 if (destroyed_count > 0) {
151 "Destroyed {} closed window(s)", destroyed_count);
154 return destroyed_count;
167 "SDL backend not implemented");
172 "Native backend not implemented");
177 "Unknown windowing backend: {}",
185 const auto& title = window->get_create_info().title;
208 std::function<
void()> hook)
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_PRINT(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
static std::string get_platform()
Gets the current GLFW platform (Wayland, X11, etc.)
static void terminate()
Terminates the GLFW library if initialized and no windows remain.
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.
@ SDL
SDL2 (alternative, if implemented)
@ GLFW
GLFW3 (default, cross-platform)
@ NATIVE
Platform-native (Win32/X11/Cocoa, if implemented)
GlfwPreInitConfig glfw_preinit_config
Pre-initialization configuration for GLFW.
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.