From f322639668aa9e0346bb6a3cd8aa290373e23213 Mon Sep 17 00:00:00 2001 From: John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> Date: Thu, 28 Dec 2023 18:03:45 +0100 Subject: [PATCH] Fix chat state updating Previous commits introduced a problem that chat state stopped working, this commit resolves it by updating it on each cycle. --- src/profanity.c | 3 ++- src/ui/inputwin.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/profanity.c b/src/profanity.c index ad352658..09bf29df 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -108,7 +108,7 @@ prof_run(char* log_level, char* account_name, char* config_file, char* log_file, session_init_activity(); mainloop = g_main_loop_new(NULL, TRUE); - g_timeout_add(1000/60, _main_update, NULL); + g_timeout_add(1000 / 60, _main_update, NULL); inp_add_watch(); g_main_loop_run(mainloop); } @@ -133,6 +133,7 @@ _main_update(gpointer data) session_process_events(); iq_autoping_check(); ui_update(); + chat_state_idle(); #ifdef HAVE_GTK tray_update(); #endif diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index f7ce9105..979b0b0a 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -172,18 +172,19 @@ create_input_window(void) } static gboolean -_inp_callback(GIOChannel *source, GIOCondition condition, gpointer data) +_inp_callback(GIOChannel* source, GIOCondition condition, gpointer data) { rl_callback_read_char(); + if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') { + chat_state_activity(); + } + ui_reset_idle_time(); if (!get_password) { // Update the input buffer on screen _inp_write(rl_line_buffer, rl_point); } - // TODO set idle or activity with a timeout - //chat_state_idle(); - //chat_state_activity(); if (inp_line) { ProfWin* window = wins_get_current();