MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Surface.cpp
Go to the documentation of this file.
1#include "Surface.hpp"
2
6
8
10 : m_window_ownership(std::make_shared<WindowOwnership>(std::move(config.window)))
11 , m_layer(std::move(config.layer))
12 , m_ctx(std::move(config.ctx))
13{
14 const bool detach = config.should_detach_on_close();
15
16 auto close_ownership = m_window_ownership;
17 auto close_layer = m_layer;
18 auto* event_source = &close_ownership->window->get_event_source();
19
20 m_ctx->on_close(0, [ownership = std::move(close_ownership), layer = std::move(close_layer), event_source, detach, on_close = std::move(config.on_close)]() {
21 if (on_close)
22 on_close();
23
24 if (detach) {
25 if (layer)
26 internal::atelier().bridge().stop_sync(*layer);
27
28 event_source->defer([ownership]() { ownership->window.reset(); });
29 }
30 });
31}
32
33} // namespace MayaFlux::Portal::Forma
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:159
std::shared_ptr< Context > m_ctx
Definition Surface.hpp:331
std::shared_ptr< Layer > m_layer
Definition Surface.hpp:330
Surface(SurfaceConfig config)
Construct a Surface from a SurfaceConfig.
Definition Surface.cpp:9
std::shared_ptr< WindowOwnership > m_window_ownership
Definition Surface.hpp:329
bool should_detach_on_close() const noexcept
Whether the built-in detach behavior actually runs.
Definition Surface.hpp:67
std::function< void()> on_close
Runs in addition to, never instead of, the built-in close handling.
Definition Surface.hpp:64
The single argument every Surface-creating function in this module takes, at every level of abstracti...
Definition Surface.hpp:26