From 95d09e4b75646c712c308a68f1b42a8d2c7a40b0 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Tue, 1 Jul 2014 19:39:25 -0400 Subject: [PATCH] fix window resizing bug on some platforms and add -O1 optimization flag --- build/Makefile | 2 +- src/windows.c | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/build/Makefile b/build/Makefile index a161912..1f753cc 100644 --- a/build/Makefile +++ b/build/Makefile @@ -15,7 +15,7 @@ MANFILES = toxic.1 toxic.conf.5 LIBS = libtoxcore ncursesw -CFLAGS = -std=gnu99 -pthread -Wimplicit-function-declaration -Wreturn-type +CFLAGS = -std=gnu99 -pthread -Wimplicit-function-declaration -Wreturn-type -O1 CFLAGS += -DTOXICVER="\"$(VERSION)\"" -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED CFLAGS += -DPACKAGE_DATADIR="\"$(abspath $(DATADIR))\"" CFLAGS += $(USER_CFLAGS) diff --git a/src/windows.c b/src/windows.c index 00c3e33..19a4adf 100644 --- a/src/windows.c +++ b/src/windows.c @@ -315,6 +315,11 @@ void on_window_resize(void) refresh(); clear(); + /* equivalent to LINES and COLS */ + int x2, y2; + getmaxyx(stdscr, y2, x2); + y2 -= 2; + int i; for (i == 0; i < MAX_WINDOWS_NUM; ++i) { @@ -323,19 +328,13 @@ void on_window_resize(void) ToxWindow *w = &windows[i]; - if (windows[i].is_friendlist) { - delwin(w->window); - w->window = newwin(LINES - 2, COLS, 0, 0); - continue; - } - delwin(w->window); - w->window = newwin(LINES - 2, COLS, 0, 0); - - int x2, y2, x, y; - getmaxyx(w->window, y2, x2); + w->window = newwin(y2, x2, 0, 0); w->x = x2; + if (windows[i].is_friendlist) + continue; + if (w->is_groupchat) delwin(w->chatwin->sidebar); else @@ -355,12 +354,10 @@ void on_window_resize(void) } #ifdef _SUPPORT_AUDIO - if (w->chatwin->infobox.active) { delwin(w->chatwin->infobox.win); w->chatwin->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH); } - #endif /* #ifdef _SUPPORT_AUDIO */ scrollok(w->chatwin->history, 0);