tsm: screen: fix cleaning buffers on resize
authorDavid Herrmann <dh.herrmann@googlemail.com>
Thu, 27 Sep 2012 10:26:30 +0000 (12:26 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Thu, 27 Sep 2012 10:26:30 +0000 (12:26 +0200)
There is some nasty bug where we do not correctly clean buffers when
resizing. So we now clear the whole offscreen region on resize to go sure
everything is clean.

Note that cells can pretty much move everywhere during their
offscreen-life so this is a quite sophisticated task to keep track which
cells are clean and which not. Therefore, simply clean all of them when
taking them on-screen.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/tsm_screen.c

index 3f4b920..fc96576 100644 (file)
@@ -552,9 +552,20 @@ int tsm_screen_resize(struct tsm_screen *con, unsigned int x,
        }
 
        /* When resizing, we need to reset all the new cells, otherwise, the old
-        * data that was written there will reoccur on the screen. */
-       for (j = 0; j < y; ++j) {
-               for (i = con->size_x; i < x; ++i)
+        * data that was written there will reoccur on the screen.
+        * TODO: we overwrite way to much here; most of it should already be
+        * cleaned. Maybe it does more sense cleaning when _allocating_ or when
+        * _shrinking_, then we never clean twice (for performance reasons). */
+       for (j = 0; j < con->line_num; ++j) {
+               if (j >= con->size_y)
+                       i = 0;
+               else
+                       i = con->size_x;
+               if (x < con->lines[j]->size)
+                       width = x;
+               else
+                       width = con->lines[j]->size;
+               for (; i < width; ++i)
                        cell_init(con, &con->lines[j]->cells[i]);
        }