fix root mouse/key release
This commit is contained in:
25
src/node.cpp
25
src/node.cpp
@@ -565,8 +565,11 @@ bool Node::is_child(Node* o) const
|
|||||||
|
|
||||||
void Node::mouse_capture()
|
void Node::mouse_capture()
|
||||||
{
|
{
|
||||||
auto& c = root()->current_mouse_capture;
|
auto root = App::I->layout.get_ref("main");
|
||||||
auto& s = root()->m_capture_stack;
|
if (!root) return;
|
||||||
|
|
||||||
|
auto& c = root->current_mouse_capture;
|
||||||
|
auto& s = root->m_capture_stack;
|
||||||
|
|
||||||
// already owner of capture
|
// already owner of capture
|
||||||
if (c.get() == this || std::find_if(s.begin(), s.end(),
|
if (c.get() == this || std::find_if(s.begin(), s.end(),
|
||||||
@@ -607,8 +610,11 @@ void Node::mouse_release()
|
|||||||
if (!m_parent)
|
if (!m_parent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto& c = root()->current_mouse_capture;
|
auto root = App::I->layout.get_ref("main");
|
||||||
auto& s = root()->m_capture_stack;
|
if (!root) return;
|
||||||
|
|
||||||
|
auto& c = root->current_mouse_capture;
|
||||||
|
auto& s = root->m_capture_stack;
|
||||||
|
|
||||||
s.erase(std::remove_if(s.begin(), s.end(),
|
s.erase(std::remove_if(s.begin(), s.end(),
|
||||||
[this](const auto& a) { return a.get() == this; }), s.end());
|
[this](const auto& a) { return a.get() == this; }), s.end());
|
||||||
@@ -633,13 +639,20 @@ void Node::key_capture()
|
|||||||
if (!m_parent)
|
if (!m_parent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
root()->current_key_capture = shared_from_this();
|
auto root = App::I->layout.get_ref("main");
|
||||||
|
if (!root) return;
|
||||||
|
|
||||||
|
root->current_key_capture = shared_from_this();
|
||||||
m_key_captured = true;
|
m_key_captured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::key_release()
|
void Node::key_release()
|
||||||
{
|
{
|
||||||
root()->current_key_capture = nullptr;
|
auto root = App::I->layout.get_ref("main");
|
||||||
|
if (!root) return;
|
||||||
|
|
||||||
|
if (root->current_key_capture.get() == this)
|
||||||
|
root->current_key_capture = nullptr;
|
||||||
m_key_captured = false;
|
m_key_captured = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user