wlt: terminal: draw background-margin when maximized
authorDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 1 Oct 2012 13:02:54 +0000 (15:02 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Mon, 1 Oct 2012 13:02:54 +0000 (15:02 +0200)
When maximized, we might have a small margin as we do not snap to
grid-sizes. Therefore, we need to correctly draw the background color for
these margins.

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

index 11d1c9f..07c6d47 100644 (file)
@@ -169,11 +169,43 @@ static int draw_cell(struct tsm_screen *scr,
        return 0;
 }
 
+static void draw_background(struct wlt_terminal *term)
+{
+       uint8_t *dst;
+       uint32_t *line;
+       unsigned int i, j, w, h;
+
+       /* when maximized, we might have a right and bottom border. So draw
+        * a black background for everything beyond grid-size.
+        * TODO: we should catch the color from tsm_screen instead of using
+        * black background by default. */
+       w = term->buffer.width;
+       w /= term->font_normal->attr.width;
+       w *= term->font_normal->attr.width;
+
+       h = term->buffer.height;
+       h /= term->font_normal->attr.height;
+       h *= term->font_normal->attr.height;
+
+       dst = term->buffer.data;
+       for (i = 0; i < term->buffer.height; ++i) {
+               line = (uint32_t*)dst;
+               if (i >= h)
+                       j = 0;
+               else
+                       j = w;
+               for ( ; j < term->buffer.width; ++j)
+                       line[j] = 0xff << 24;
+               dst += term->buffer.stride;
+       }
+}
+
 static void widget_redraw(struct wlt_widget *widget, unsigned int flags,
                          void *data)
 {
        struct wlt_terminal *term = data;
 
+       draw_background(term);
        tsm_screen_draw(term->scr, NULL, draw_cell, NULL, term);
 }