summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-01-21 09:20:15 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-01-21 09:20:15 +0200
commitc1001c3ab6e6b0aa42cb4dfeec501845a0091e99 (patch)
treeab76d4139d23d83cbc7b99efb1e4c1b4e0a1723e /src
parent0593bbdf2286e88222316bfd0b5f6b348c60ea73 (diff)
InputWidget: Fixed hang if widget is very narrrow
Diffstat (limited to 'src')
-rw-r--r--src/ui/inputwidget.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 9261da0c..aa55f3f0 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -742,15 +742,17 @@ static void startOrStopCursorTimer_InputWidget_(iInputWidget *d, int doStart) {
742#else /* using a system-provided text control */ 742#else /* using a system-provided text control */
743 743
744static void updateAllLinesAndResizeHeight_InputWidget_(iInputWidget *d) { 744static void updateAllLinesAndResizeHeight_InputWidget_(iInputWidget *d) {
745 /* Rewrap the buffered text and resize accordingly. */ 745 if (width_Widget(d) >= minWidth_InputWidget_) {
746 iWrapText wt = wrap_InputWidget_(d, 0); 746 /* Rewrap the buffered text and resize accordingly. */
747 /* TODO: Set max lines limit for WrapText. */ 747 iWrapText wt = wrap_InputWidget_(d, 0);
748 const int height = measure_WrapText(&wt, d->font).bounds.size.y; 748 /* TODO: Set max lines limit for WrapText. */
749 /* We use this to store the number wrapped lines for determining widget height. */ 749 const int height = measure_WrapText(&wt, d->font).bounds.size.y;
750 d->visWrapLines.start = 0; 750 /* We use this to store the number wrapped lines for determining widget height. */
751 d->visWrapLines.end = iMax(d->minWrapLines, 751 d->visWrapLines.start = 0;
752 iMin(d->maxWrapLines, height / lineHeight_Text(d->font))); 752 d->visWrapLines.end = iMax(d->minWrapLines,
753 updateMetrics_InputWidget_(d); 753 iMin(d->maxWrapLines, height / lineHeight_Text(d->font)));
754 updateMetrics_InputWidget_(d);
755 }
754} 756}
755 757
756#endif 758#endif