mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-25 04:33:03 +01:00
Fix regression causing typing notifications to break
Also a small refactor so we use less duplicate code and reduce mutex usage
This commit is contained in:
parent
66e4c590dc
commit
d02ac24de8
58
src/chat.c
58
src/chat.c
@ -1270,9 +1270,16 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChatContext *ctx = self->chatwin;
|
ChatContext *ctx = self->chatwin;
|
||||||
|
StatusBar *statusbar = self->stb;
|
||||||
|
|
||||||
pthread_mutex_lock(&Winthread.lock);
|
pthread_mutex_lock(&Winthread.lock);
|
||||||
|
|
||||||
line_info_print(self);
|
line_info_print(self);
|
||||||
|
|
||||||
|
Tox_Connection connection = statusbar->connection;
|
||||||
|
Tox_User_Status status = statusbar->status;
|
||||||
|
const bool is_typing = Friends.list[self->num].is_typing;
|
||||||
|
|
||||||
pthread_mutex_unlock(&Winthread.lock);
|
pthread_mutex_unlock(&Winthread.lock);
|
||||||
|
|
||||||
wclear(ctx->linewin);
|
wclear(ctx->linewin);
|
||||||
@ -1283,14 +1290,6 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
|
|||||||
|
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
|
||||||
/* Draw status bar */
|
|
||||||
StatusBar *statusbar = self->stb;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&Winthread.lock);
|
|
||||||
Tox_Connection connection = statusbar->connection;
|
|
||||||
Tox_User_Status status = statusbar->status;
|
|
||||||
pthread_mutex_unlock(&Winthread.lock);
|
|
||||||
|
|
||||||
wmove(statusbar->topline, 0, 0);
|
wmove(statusbar->topline, 0, 0);
|
||||||
|
|
||||||
wattron(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
wattron(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
||||||
@ -1318,13 +1317,13 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wattron(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
wattron(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
||||||
wprintw(statusbar->topline, "]");
|
wprintw(statusbar->topline, "] ");
|
||||||
wattroff(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
wattroff(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
||||||
|
|
||||||
if (status != TOX_USER_STATUS_NONE) {
|
const char *status_text = "ERROR";
|
||||||
const char *status_text = "ERROR";
|
int colour = BAR_TEXT;
|
||||||
int colour = MAGENTA;
|
|
||||||
|
|
||||||
|
if (connection != TOX_CONNECTION_NONE) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case TOX_USER_STATUS_AWAY:
|
case TOX_USER_STATUS_AWAY:
|
||||||
colour = STATUS_AWAY;
|
colour = STATUS_AWAY;
|
||||||
@ -1339,9 +1338,11 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colour != BAR_TEXT) {
|
||||||
wattron(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
wattron(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
||||||
wprintw(statusbar->topline, " [");
|
wprintw(statusbar->topline, "[");
|
||||||
wattroff(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
wattroff(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
||||||
|
|
||||||
wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
|
wattron(statusbar->topline, COLOR_PAIR(colour) | A_BOLD);
|
||||||
@ -1351,30 +1352,23 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
|
|||||||
wattron(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
wattron(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
||||||
wprintw(statusbar->topline, "] ");
|
wprintw(statusbar->topline, "] ");
|
||||||
wattroff(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
wattroff(statusbar->topline, COLOR_PAIR(BAR_ACCENT));
|
||||||
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&Winthread.lock);
|
if (is_typing) {
|
||||||
const bool is_typing = Friends.list[self->num].is_typing;
|
wattron(statusbar->topline, A_BOLD | COLOR_PAIR(BAR_NOTIFY));
|
||||||
pthread_mutex_unlock(&Winthread.lock);
|
|
||||||
|
|
||||||
if (is_typing) {
|
|
||||||
wattron(statusbar->topline, A_BOLD | COLOR_PAIR(BAR_NOTIFY));
|
|
||||||
} else {
|
|
||||||
wattron(statusbar->topline, COLOR_PAIR(BAR_TEXT));
|
|
||||||
}
|
|
||||||
|
|
||||||
wprintw(statusbar->topline, "%s", statusbar->nick);
|
|
||||||
|
|
||||||
if (is_typing) {
|
|
||||||
wattroff(statusbar->topline, A_BOLD | COLOR_PAIR(BAR_NOTIFY));
|
|
||||||
} else {
|
|
||||||
wattroff(statusbar->topline, A_BOLD | COLOR_PAIR(BAR_TEXT));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
wattron(statusbar->topline, COLOR_PAIR(BAR_TEXT));
|
wattron(statusbar->topline, COLOR_PAIR(BAR_TEXT));
|
||||||
wprintw(statusbar->topline, " %s", statusbar->nick);
|
|
||||||
wattroff(statusbar->topline, COLOR_PAIR(BAR_TEXT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wprintw(statusbar->topline, "%s", statusbar->nick);
|
||||||
|
|
||||||
|
if (is_typing) {
|
||||||
|
wattroff(statusbar->topline, A_BOLD | COLOR_PAIR(BAR_NOTIFY));
|
||||||
|
} else {
|
||||||
|
wattroff(statusbar->topline, A_BOLD | COLOR_PAIR(BAR_TEXT));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Reset statusbar->statusmsg on window resize */
|
/* Reset statusbar->statusmsg on window resize */
|
||||||
if (x2 != self->x) {
|
if (x2 != self->x) {
|
||||||
char statusmsg[TOX_MAX_STATUS_MESSAGE_LENGTH] = {'\0'};
|
char statusmsg[TOX_MAX_STATUS_MESSAGE_LENGTH] = {'\0'};
|
||||||
|
Loading…
Reference in New Issue
Block a user