From 9f0bb1262d66fac1f2ca308bde470924e8c48328 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sat, 9 Mar 2013 13:47:00 +0100 Subject: [PATCH] terminal: clear unused margins on each frame If the terminal screen is smaller than the real screen, we never paint to the margins. This doesn't hurt as long as we never resize the terminal. The uterm layer clears all framebuffers during allocation. However, uterm behavior may change and our terminal may get resized (eg., during hotplugging) so we really should clear all the margins. We now clear them on every frame as it is a trivial task. However, if we speed up rendering, we should probably set a "needs_clear" flag that simply clears the framebuffer. Signed-off-by: David Herrmann --- src/kmscon_terminal.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/kmscon_terminal.c b/src/kmscon_terminal.c index e476df6..d917fc7 100644 --- a/src/kmscon_terminal.c +++ b/src/kmscon_terminal.c @@ -85,6 +85,33 @@ struct kmscon_terminal { struct kmscon_font *bold_font; }; +static void do_clear_margins(struct screen *scr) +{ + unsigned int w, h, sw, sh; + struct uterm_mode *mode; + int dw, dh; + + mode = uterm_display_get_current(scr->disp); + if (!mode) + return; + + sw = uterm_mode_get_width(mode); + sh = uterm_mode_get_height(mode); + w = scr->txt->font->attr.width * scr->txt->cols; + h = scr->txt->font->attr.height * scr->txt->rows; + dw = sw - w; + dh = sh - h; + + if (dw > 0) + uterm_display_fill(scr->disp, 0, 0, 0, + w, 0, + dw, h); + if (dh > 0) + uterm_display_fill(scr->disp, 0, 0, 0, + 0, h, + sw, dh); +} + static void do_redraw_screen(struct screen *scr) { int ret; @@ -93,6 +120,7 @@ static void do_redraw_screen(struct screen *scr) return; scr->pending = false; + do_clear_margins(scr); tsm_screen_draw(scr->term->console, kmscon_text_prepare_cb, kmscon_text_draw_cb, kmscon_text_render_cb, scr->txt); ret = uterm_display_swap(scr->disp, false);