//
// Created by sebastian on 02.08.26.
//

#include "InputContextStack.h"


void engine::InputContextStack::push(std::shared_ptr<InputContext> context) {
    if (!m_stack.empty()) m_stack.back()->onDeactivate();
    context->onActivate();
    m_stack.push_back(std::move(context));
}

void engine::InputContextStack::pop() {
    if (m_stack.empty()) return;
    m_stack.back()->onDeactivate();
    m_stack.pop_back();
    if (!m_stack.empty()) m_stack.back()->onActivate();
}


bool engine::InputContextStack::isActive(const InputContext &context) const {
    return !m_stack.empty() && m_stack.back().get() == &context;
}
