[PATCH v2 3/5] greeter: Make sure text input areas stay inside the lines
Alan Coopersmith
alan.coopersmith at oracle.com
Mon Feb 21 16:56:28 PST 2011
Regression introduced by f8585c60831a8e5ddebce18bdd7e78d217a822c5
broke bounds checking for text displayed in input fields.
Since this makes each TEXT_WIDTH value only be used once, just use
them directly instead of storing the result in a variable.
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
New in v2 of this series.
greeter/Login.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/greeter/Login.c b/greeter/Login.c
index 9fd07c4..f448991 100644
--- a/greeter/Login.c
+++ b/greeter/Login.c
@@ -404,24 +404,21 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC gc)
} else if ((state == LOGIN_PROMPT_ECHO_ON) || (state == LOGIN_TEXT_INFO) ||
((state == LOGIN_PROMPT_ECHO_OFF) && (w->login.echo_passwd == True)))
{
- int textwidth;
int offset = max(cursor, VALUE_SHOW_START(w, promptNum));
int textlen = strlen (text + offset);
- textwidth = TEXT_WIDTH (text, text + offset, textlen);
-
- if (textwidth > (width - curoff)) {
+ if (TEXT_WIDTH (text, text + offset, textlen) > (width - curoff)) {
/* Recalculate amount of text that can fit in field */
offset = VALUE_SHOW_START(w, promptNum);
textlen = strlen (text + offset);
- while ((textlen > 0) && (textwidth > width))
+ while ((textlen > 0) &&
+ (TEXT_WIDTH (text, text + offset, textlen) > width))
{
if (offset < PROMPT_CURSOR(w, promptNum)) {
offset++;
}
textlen--;
- textwidth = TEXT_WIDTH (text, text + offset, textlen);
}
VALUE_SHOW_START(w, promptNum) = offset;
--
1.7.3.2
More information about the xorg-devel
mailing list