IME: fix incorrect popup damage (#5383)

This commit is contained in:
Sungyoon Cho 2024-04-02 20:22:41 +09:00 committed by GitHub
parent 2e5b146e57
commit 04a35891a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 8 deletions

View file

@ -77,8 +77,10 @@ void CInputPopup::damageEntire() {
return;
}
Vector2D pos = OWNER->getSurfaceBoxGlobal().value_or(CBox{0, 0, 0, 0}).pos() + lastBoxLocal.pos();
g_pHyprRenderer->damageBox(pos.x, pos.y, surface.wlr()->current.width, surface.wlr()->current.height);
Vector2D pos = OWNER->getSurfaceBoxGlobal().value_or(CBox{0, 0, 0, 0}).pos() + lastBoxLocal.pos();
CBox global = {pos, lastPopupSize};
g_pHyprRenderer->damageBox(&global);
}
void CInputPopup::damageSurface() {
@ -119,20 +121,23 @@ void CInputPopup::updateBox() {
cursorBoxLocal = {0, 0, (int)parentBox.w, (int)parentBox.h};
}
if (cursorBoxLocal != lastBoxLocal)
Vector2D currentPopupSize = {surface.wlr()->current.width, surface.wlr()->current.height};
if (cursorBoxLocal != lastBoxLocal || currentPopupSize != lastPopupSize)
damageEntire();
CMonitor* pMonitor = g_pCompositor->getMonitorFromVector(parentBox.middle());
if (cursorBoxLocal.y + parentBox.y + surface.wlr()->current.height + cursorBoxLocal.height > pMonitor->vecPosition.y + pMonitor->vecSize.y)
cursorBoxLocal.y -= surface.wlr()->current.height;
if (cursorBoxLocal.y + parentBox.y + currentPopupSize.y + cursorBoxLocal.height > pMonitor->vecPosition.y + pMonitor->vecSize.y)
cursorBoxLocal.y -= currentPopupSize.y;
else
cursorBoxLocal.y += cursorBoxLocal.height;
if (cursorBoxLocal.x + parentBox.x + surface.wlr()->current.width > pMonitor->vecPosition.x + pMonitor->vecSize.x)
cursorBoxLocal.x -= (cursorBoxLocal.x + parentBox.x + surface.wlr()->current.width) - (pMonitor->vecPosition.x + pMonitor->vecSize.x);
if (cursorBoxLocal.x + parentBox.x + currentPopupSize.x > pMonitor->vecPosition.x + pMonitor->vecSize.x)
cursorBoxLocal.x -= (cursorBoxLocal.x + parentBox.x + currentPopupSize.x) - (pMonitor->vecPosition.x + pMonitor->vecSize.x);
lastBoxLocal = cursorBoxLocal;
lastBoxLocal = cursorBoxLocal;
lastPopupSize = currentPopupSize;
wlr_input_popup_surface_v2_send_text_input_rectangle(pWlr, cursorBoxLocal.pWlr());

View file

@ -32,6 +32,7 @@ class CInputPopup {
wlr_input_popup_surface_v2* pWlr = nullptr;
CWLSurface surface;
CBox lastBoxLocal;
Vector2D lastPopupSize;
uint64_t lastMonitor = -1;
DYNLISTENER(mapPopup);