MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ move_focus()

void MayaFlux::Portal::Forma::Context::move_focus ( std::optional< uint32_t > target,
glm::vec2 ndc )
private

Definition at line 287 of file Context.cpp.

288{
289 using Type = Core::WindowEventType;
290
291 m_focused = target;
292
293 while (true) {
294 if (const auto pending = std::exchange(m_focus_pending, std::nullopt)) {
295 if (pending->type == Type::WINDOW_FOCUS_LOST || m_focused == pending->id)
296 dispatch(pending->id, pending->type, pending->ndc);
297 continue;
298 }
299
301 return;
302
303 if (m_focus_notified) {
304 const uint32_t lost = *std::exchange(m_focus_notified, std::nullopt);
305 m_focus_pending = FocusNotice { .id = lost, .type = Type::WINDOW_FOCUS_LOST, .ndc = ndc };
306 const auto it = m_callbacks.find(lost);
307 if (it != m_callbacks.end())
308 notify(it->second.focus_lost, lost);
309 } else {
310 const uint32_t gained = *m_focused;
311 m_focus_notified = gained;
312 m_focus_pending = FocusNotice { .id = gained, .type = Type::WINDOW_FOCUS_GAINED, .ndc = ndc };
313 const auto it = m_callbacks.find(gained);
314 if (it != m_callbacks.end())
315 notify(it->second.focus_gained, gained);
316 }
317 }
318}
std::optional< FocusNotice > m_focus_pending
Definition Context.hpp:514
std::optional< uint32_t > m_focus_notified
Definition Context.hpp:513
std::unordered_map< uint32_t, ElementCallbacks > m_callbacks
Definition Context.hpp:471
void dispatch(uint32_t id, Core::WindowEventType type, glm::vec2 ndc, Core::WindowEvent::EventData data={}, std::optional< IO::MouseButtons > button=std::nullopt, std::optional< IO::Keys > key=std::nullopt)
Definition Context.cpp:728
std::optional< uint32_t > m_focused
Definition Context.hpp:499
WindowEventType
Types of window and input events.
Focus notifications run user code that may move focus again, so move_focus() tracks what it has told ...
Definition Context.hpp:508

References dispatch(), m_callbacks, m_focus_notified, m_focus_pending, and m_focused.

Referenced by clear_focus(), handle_press(), set_focus(), and unbind().

Here is the call graph for this function:
Here is the caller graph for this function: