From 0df8b8beff8aeeae072beee8fc3ed69f9d132fb2 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 29 Apr 2015 22:10:32 +0100 Subject: [PATCH] Return new window on new chat win event --- src/command/commands.c | 14 ++++++-------- src/event/ui_events.c | 5 ++--- src/event/ui_events.h | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/command/commands.c b/src/command/commands.c index 44069693..f583fa44 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1332,11 +1332,10 @@ cmd_msg(gchar **args, struct cmd_help_t help) return TRUE; } else { ProfWin *window = (ProfWin*)wins_get_chat(barejid); - if (window) { - ui_ev_focus_win(window); - } else { - ui_ev_new_chat_win(barejid); + if (!window) { + window = ui_ev_new_chat_win(barejid); } + ui_ev_focus_win(window); #ifdef HAVE_LIBOTR if (otr_is_secure(barejid)) { @@ -4171,11 +4170,10 @@ cmd_otr(gchar **args, struct cmd_help_t help) } ProfWin *window = (ProfWin*)wins_get_chat(barejid); - if (window) { - ui_ev_focus_win(window); - } else { - ui_ev_new_chat_win(barejid); + if (!window) { + window = ui_ev_new_chat_win(barejid); } + ui_ev_focus_win(window); if (ui_current_win_is_otr()) { ui_current_print_formatted_line('!', 0, "You are already in an OTR session."); diff --git a/src/event/ui_events.c b/src/event/ui_events.c index c079c0e6..5e16cc43 100644 --- a/src/event/ui_events.c +++ b/src/event/ui_events.c @@ -40,9 +40,8 @@ ui_ev_focus_win(ProfWin *win) ui_switch_win(win); } -void +ProfWin* ui_ev_new_chat_win(const char * const barejid) { - ProfWin *win = ui_new_chat_win(barejid); - ui_switch_win(win); + return ui_new_chat_win(barejid); } \ No newline at end of file diff --git a/src/event/ui_events.h b/src/event/ui_events.h index 77017d2c..9e2dc7ee 100644 --- a/src/event/ui_events.h +++ b/src/event/ui_events.h @@ -36,6 +36,6 @@ #define UI_EVENTS_H void ui_ev_focus_win(ProfWin *win); -void ui_ev_new_chat_win(const char * const barejid); +ProfWin* ui_ev_new_chat_win(const char * const barejid); #endif \ No newline at end of file