mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 11:45:58 +01:00
IME: fix race condition on closing window (#5455)
This commit is contained in:
parent
1596e2d1f7
commit
04d067d78b
3 changed files with 26 additions and 20 deletions
|
@ -160,6 +160,25 @@ void CInputMethodRelay::updateAllPopups() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInputMethodRelay::activateIME(CTextInput* pInput) {
|
||||||
|
if (!m_pWLRIME)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
||||||
|
commitIMEState(pInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInputMethodRelay::deactivateIME(CTextInput* pInput) {
|
||||||
|
if (!m_pWLRIME)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!m_pWLRIME->active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
||||||
|
commitIMEState(pInput);
|
||||||
|
}
|
||||||
|
|
||||||
void CInputMethodRelay::commitIMEState(CTextInput* pInput) {
|
void CInputMethodRelay::commitIMEState(CTextInput* pInput) {
|
||||||
if (!m_pWLRIME)
|
if (!m_pWLRIME)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -20,6 +20,8 @@ class CInputMethodRelay {
|
||||||
|
|
||||||
wlr_input_method_v2* m_pWLRIME = nullptr;
|
wlr_input_method_v2* m_pWLRIME = nullptr;
|
||||||
|
|
||||||
|
void activateIME(CTextInput* pInput);
|
||||||
|
void deactivateIME(CTextInput* pInput);
|
||||||
void commitIMEState(CTextInput* pInput);
|
void commitIMEState(CTextInput* pInput);
|
||||||
void removeTextInput(CTextInput* pInput);
|
void removeTextInput(CTextInput* pInput);
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,8 @@ void CTextInput::initCallbacks() {
|
||||||
hyprListener_textInputDestroy.initCallback(
|
hyprListener_textInputDestroy.initCallback(
|
||||||
isV3() ? &pWlrInput->events.destroy : &pV1Input->sDestroy,
|
isV3() ? &pWlrInput->events.destroy : &pV1Input->sDestroy,
|
||||||
[this](void* owner, void* data) {
|
[this](void* owner, void* data) {
|
||||||
if (pWlrInput && pWlrInput->current_enabled && g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
if (pWlrInput && pWlrInput->current_enabled && focusedSurface())
|
||||||
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
g_pInputManager->m_sIMERelay.deactivateIME(this);
|
||||||
|
|
||||||
g_pInputManager->m_sIMERelay.commitIMEState(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
hyprListener_textInputCommit.removeCallback();
|
hyprListener_textInputCommit.removeCallback();
|
||||||
hyprListener_textInputDestroy.removeCallback();
|
hyprListener_textInputDestroy.removeCallback();
|
||||||
|
@ -72,8 +69,7 @@ void CTextInput::onEnabled(wlr_surface* surfV1) {
|
||||||
enter(pSurface);
|
enter(pSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
g_pInputManager->m_sIMERelay.activateIME(this);
|
||||||
g_pInputManager->m_sIMERelay.commitIMEState(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextInput::onDisabled() {
|
void CTextInput::onDisabled() {
|
||||||
|
@ -91,11 +87,7 @@ void CTextInput::onDisabled() {
|
||||||
hyprListener_surfaceDestroyed.removeCallback();
|
hyprListener_surfaceDestroyed.removeCallback();
|
||||||
hyprListener_surfaceUnmapped.removeCallback();
|
hyprListener_surfaceUnmapped.removeCallback();
|
||||||
|
|
||||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME->active)
|
g_pInputManager->m_sIMERelay.deactivateIME(this);
|
||||||
return;
|
|
||||||
|
|
||||||
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
|
||||||
g_pInputManager->m_sIMERelay.commitIMEState(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextInput::onCommit() {
|
void CTextInput::onCommit() {
|
||||||
|
@ -203,14 +195,7 @@ void CTextInput::leave() {
|
||||||
|
|
||||||
setFocusedSurface(nullptr);
|
setFocusedSurface(nullptr);
|
||||||
|
|
||||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME)
|
g_pInputManager->m_sIMERelay.deactivateIME(this);
|
||||||
return;
|
|
||||||
|
|
||||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME->active)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
|
||||||
g_pInputManager->m_sIMERelay.commitIMEState(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_surface* CTextInput::focusedSurface() {
|
wlr_surface* CTextInput::focusedSurface() {
|
||||||
|
|
Loading…
Reference in a new issue