Skip to content

Commit

Permalink
IME: fix incorrect popup damage (#5383)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungyoonc authored Apr 2, 2024
1 parent 2e5b146 commit 04a3589
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/managers/input/InputMethodPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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());

Expand Down
1 change: 1 addition & 0 deletions src/managers/input/InputMethodPopup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 04a3589

Please sign in to comment.