popup: flip above the pointer at the bottom edge

Without a caret the popup sat at pointer+10 and was clamped upward at
the bottom of the work area, covering the pointer; it now goes above the
pointer like it goes above a caret.
This commit is contained in:
2026-08-16 21:36:31 +09:00
parent 45c6be7e1b
commit 6b1de2df4f
2 changed files with 4 additions and 0 deletions

View File

@@ -259,6 +259,8 @@ popupposition(Caret *caret, int pointerx, int pointery, Area *area,
}else{
px = (vlong)pointerx + 10;
py = (vlong)pointery + 10;
if(py + h > bottom)
py = (vlong)pointery - 10 - h;
}
xmax = max(right - w, area->x);
ymax = max(bottom - h, area->y);

View File

@@ -108,6 +108,8 @@ popup_layout(struct ct *t)
popupposition(&caret, 2000, 50, &area, 100, 60, &x, &y);
CT_EQ_INT(t, 2010, x);
CT_EQ_INT(t, 60, y);
popupposition(&caret, 2000, 900, &area, 100, 60, &x, &y);
CT_EQ_INT(t, 830, y); /* above the pointer, not over it */
caret.valid = 1;
caret.x = 2100;
caret.y = 80;