From ead221211fcb68c14b4c36d1e63572fb5a3a16b2 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Sat, 23 Mar 2002 18:45:57 +0000 Subject: [PATCH] Started implementing event reduction. --- programs/wineconsole/wineconsole.c | 41 ++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index b9d79718482..3ffe9de0557 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -196,8 +196,8 @@ BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len) */ int WINECON_GrabChanges(struct inner_data* data) { - struct console_renderer_event evts[16]; - int i, num; + struct console_renderer_event evts[256]; + int i, num, curs = -1; HANDLE h; SERVER_START_REQ( get_console_renderer_events ) @@ -211,6 +211,43 @@ int WINECON_GrabChanges(struct inner_data* data) if (!num) {Trace(0, "hmm renderer signaled but no events available\n"); return 1;} /* FIXME: should do some event compression here (cursor pos, update) */ + /* step 1: keep only last cursor pos event */ + for (i = num - 1; i >= 0; i--) + { + if (evts[i].event == CONSOLE_RENDERER_CURSOR_POS_EVENT) + { + if (curs == -1) + curs = i; + else + { + memmove(&evts[i], &evts[i+1], (num - i - 1) * sizeof(evts[0])); + num--; + } + } + } + /* step 2: manage update events */ + for (i = 0; i < num - 1; i++) + { + if (evts[i].event == CONSOLE_RENDERER_UPDATE_EVENT && + evts[i+1].event == CONSOLE_RENDERER_UPDATE_EVENT) + { + /* contiguous */ + if (evts[i].u.update.bottom + 1 == evts[i+1].u.update.top) + { + evts[i].u.update.bottom = evts[i+1].u.update.bottom; + memmove(&evts[i+1], &evts[i+2], (num - i - 2) * sizeof(evts[0])); + num--; i--; + } + /* already handled cases */ + else if (evts[i].u.update.top <= evts[i+1].u.update.top && + evts[i].u.update.bottom >= evts[i+1].u.update.bottom) + { + memmove(&evts[i+1], &evts[i+2], (num - i - 2) * sizeof(evts[0])); + num--; i--; + } + } + } + Trace(1, "Change notification:"); for (i = 0; i < num; i++) {