diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-03-09 13:47:00 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2013-03-09 13:47:00 +0100 |
commit | 9f0bb1262d66fac1f2ca308bde470924e8c48328 (patch) | |
tree | c0a937fa38607da9730fcecd9a3d7f66685dea7b /src | |
parent | 40f6811a072baedebad20fdd805ed091df899308 (diff) |
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 <dh.herrmann@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/kmscon_terminal.c | 28 |
1 files changed, 28 insertions, 0 deletions
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); |