tiv1: minor fixes for crashes

This commit is contained in:
vaxerski 2023-03-14 13:51:08 +00:00
parent 5dc1a5fec6
commit 0807b8b95f
3 changed files with 9 additions and 1 deletions

View file

@ -371,7 +371,7 @@ void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* pInput, STextInput
return; return;
} }
if (!PINPUT->pWlrInput->current_enabled) { if (!(PINPUT->pWlrInput ? PINPUT->pWlrInput->current_enabled : PINPUT->pV1Input->active)) {
Debug::log(WARN, "Disabled TextInput commit?"); Debug::log(WARN, "Disabled TextInput commit?");
return; return;
} }
@ -486,6 +486,7 @@ void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
else { else {
zwp_text_input_v1_send_leave(ti.pV1Input->resourceImpl); zwp_text_input_v1_send_leave(ti.pV1Input->resourceImpl);
ti.pV1Input->focusedSurface = nullptr; ti.pV1Input->focusedSurface = nullptr;
ti.pV1Input->active = false;
} }
} else { } else {
continue; continue;
@ -500,6 +501,7 @@ void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
else { else {
zwp_text_input_v1_send_enter(ti.pV1Input->resourceImpl, pSurface->resource); zwp_text_input_v1_send_enter(ti.pV1Input->resourceImpl, pSurface->resource);
ti.pV1Input->focusedSurface = pSurface; ti.pV1Input->focusedSurface = pSurface;
ti.pV1Input->active = true;
} }
} else { } else {
setPendingSurface(&ti, pSurface); setPendingSurface(&ti, pSurface);

View file

@ -113,6 +113,8 @@ void CTextInputV1ProtocolManager::removeTI(STextInputV1* pTI) {
// if ((*TI)->resourceImpl) // if ((*TI)->resourceImpl)
// wl_resource_destroy((*TI)->resourceImpl); // wl_resource_destroy((*TI)->resourceImpl);
g_pInputManager->m_sIMERelay.removeTextInput((*TI)->pTextInput);
std::erase_if(m_pClients, [&](const auto& other) { return other.get() == pTI; }); std::erase_if(m_pClients, [&](const auto& other) { return other.get() == pTI; });
} }
@ -131,6 +133,8 @@ static void destroyTI(wl_resource* resource) {
wl_resource_set_user_data(resource, nullptr); wl_resource_set_user_data(resource, nullptr);
} }
g_pInputManager->m_sIMERelay.removeTextInput(TI->pTextInput);
TI->pTextInput->hyprListener_textInputDestroy.emit(nullptr); TI->pTextInput->hyprListener_textInputDestroy.emit(nullptr);
g_pProtocolManager->m_pTextInputV1ProtocolManager->removeTI(TI); g_pProtocolManager->m_pTextInputV1ProtocolManager->removeTI(TI);

View file

@ -24,6 +24,8 @@ struct STextInputV1 {
uint32_t serial = 0; uint32_t serial = 0;
bool active = false;
struct SPendingSurr { struct SPendingSurr {
bool isPending = false; bool isPending = false;
std::string text = ""; std::string text = "";