diff --git a/src/line_info.c b/src/line_info.c index 655d0d5..1e2fd21 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -209,6 +209,10 @@ void line_info_add(ToxWindow *self, uint8_t *tmstmp, uint8_t *name1, uint8_t *na void line_info_print(ToxWindow *self) { ChatContext *ctx = self->chatwin; + + if (ctx == NULL) + return; + WINDOW *win = ctx->history; ctx->hst->queue = 0; diff --git a/src/main.c b/src/main.c index 975902d..c85c57a 100644 --- a/src/main.c +++ b/src/main.c @@ -453,8 +453,10 @@ void *thread_winref(void *data) { Tox *m = (Tox *) data; - while (true) + while (true) { draw_active_window(m); + refresh_inactive_windows(); + } } int main(int argc, char *argv[]) diff --git a/src/windows.c b/src/windows.c index 564da15..903ff22 100644 --- a/src/windows.c +++ b/src/windows.c @@ -417,7 +417,7 @@ void draw_active_window(Tox *m) ltr = isprint(ch); #endif - if (!ltr && (ch == T_KEY_NEXT || ch == T_KEY_PREV) ) { + if (!ltr && (ch == T_KEY_NEXT || ch == T_KEY_PREV)) { set_next_window((int) ch); } else { pthread_mutex_lock(&Winthread.lock); @@ -426,6 +426,22 @@ void draw_active_window(Tox *m) } } +/* refresh inactive windows to prevent scrolling bugs. + call at least once per second */ +void refresh_inactive_windows(void) +{ + int i; + + for (i = 0; i < MAX_WINDOWS_NUM; ++i) { + ToxWindow *a = &windows[i]; + + if (!a->active || a == active_window || a->is_prompt) /* if prompt doesn't have scroll mode */ + continue; + + line_info_print(a); + } +} + int get_num_active_windows(void) { return num_active_windows;