The HAPPY NEW YEAR commit
authorCesare Tirabassi <norsetto@ubuntu.com>
Thu, 31 Dec 2009 22:49:02 +0000 (23:49 +0100)
committerCesare Tirabassi <norsetto@ubuntu.com>
Sat, 2 Jan 2010 13:45:12 +0000 (14:45 +0100)
This should close sf #2850092.
Basically, before this change, for strings which includes
SECRIT_MULTILINE_CHAR the computed maximum substring width was getting
summed to the width of the last substring.
The old behaviour is kept but for the case of strings including
SECRIT_MULTILINE_CHAR, for which now the maximum width of all substrings
is taken.
I don't think this will break anything else but blame me if it does ...
(cherry picked from commit 72bbe51a8c323702db76094e27266e67cc1ba5b5)

src/conky.c

index 991f14c..048e976 100644 (file)
@@ -2619,6 +2619,8 @@ static long current_color;
 static int text_size_updater(char *s, int special_index)
 {
        int w = 0;
+       int lw;
+       int contain_SECRIT_MULTILINE_CHAR = 0;
        char *p;
 
        if ((output_methods & TO_X) == 0)
@@ -2667,7 +2669,7 @@ static int text_size_updater(char *s, int special_index)
                        special_index++;
                        s = p + 1;
                } else if (*p == SECRIT_MULTILINE_CHAR) {
-                       int lw;
+                       contain_SECRIT_MULTILINE_CHAR = 1;
                        *p = '\0';
                        lw = get_string_width(s);
                        *p = SECRIT_MULTILINE_CHAR;
@@ -2677,7 +2679,13 @@ static int text_size_updater(char *s, int special_index)
                }
                p++;
        }
-       w += get_string_width(s);
+       /* Check also last substring if string contains SECRIT_MULTILINE_CHAR */
+       if (contain_SECRIT_MULTILINE_CHAR) {
+               lw = get_string_width(s);
+               w = lw > w ? lw : w;
+       } else {
+               w += get_string_width(s);
+       }
        if (w > text_width) {
                text_width = w;
        }