From: David Herrmann Date: Sun, 30 Sep 2012 21:38:30 +0000 (+0200) Subject: tsm: screen: fix moving cursor when scrolling during resize X-Git-Tag: kmscon-7~444 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf319380ef7779e66e7e1b50400f874644638ccb;p=platform%2Fupstream%2Fkmscon.git tsm: screen: fix moving cursor when scrolling during resize If we scroll the screen during resize to keep the screen-content constant, we should also move the cursor position. Otherwise, the application has an inconsistent state. Signed-off-by: David Herrmann --- diff --git a/src/tsm_screen.c b/src/tsm_screen.c index 3a20313..9f900c9 100644 --- a/src/tsm_screen.c +++ b/src/tsm_screen.c @@ -500,7 +500,7 @@ int tsm_screen_resize(struct tsm_screen *con, unsigned int x, unsigned int y) { struct line **cache; - unsigned int i, j, width; + unsigned int i, j, width, diff; int ret; bool *tab_ruler; @@ -593,8 +593,14 @@ int tsm_screen_resize(struct tsm_screen *con, unsigned int x, con->cursor_x = con->size_x - 1; /* scroll buffer if screen height shrinks */ - if (con->size_y != 0 && y < con->size_y) - screen_scroll_up(con, con->size_y - y); + if (con->size_y != 0 && y < con->size_y) { + diff = con->size_y - y; + screen_scroll_up(con, diff); + if (con->cursor_y > diff) + con->cursor_y -= diff; + else + con->cursor_y = 0; + } con->size_y = y; con->margin_bottom = con->size_y - 1;