diff src/conversation.c @ 10971:57e3e958ff49

[gaim-migrate @ 12796] This commit includes the changes I made to oldstatus to make urgent notification/taskbar flashing more sensible (auto- tab switching), the changes to notify.c so that tab switching doesn't reset the counters, and the changes and translations for gaim.desktop committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 06 Jun 2005 01:40:46 +0000
parents ee4ca56ed8a5
children 2b772e7094ef
line wrap: on
line diff
--- a/src/conversation.c	Sun Jun 05 02:57:14 2005 +0000
+++ b/src/conversation.c	Mon Jun 06 01:40:46 2005 +0000
@@ -533,8 +533,6 @@
 	if (ops != NULL && ops->switch_conversation != NULL)
 		ops->switch_conversation(win, conv);
 
-	gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE);
-
 	gaim_signal_emit(gaim_conversations_get_handle(),
 					 "conversation-switched", old_conv, conv);
 }
@@ -1362,7 +1360,13 @@
 			gaim_conv_im_set_typing_state(GAIM_CONV_IM(conv), GAIM_NOT_TYPING);
 	}
 
-	if (gaim_conv_window_get_active_conversation(win) != conv) {
+	if (gaim_conv_window_has_focus(win) &&
+		gaim_conv_window_get_active_conversation(win) == conv)
+	{
+		unseen = GAIM_UNSEEN_NONE;
+	}
+	else
+	{
 		if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK ||
 				gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK)
 			unseen = GAIM_UNSEEN_NICK;
@@ -1373,10 +1377,25 @@
 		else
 			unseen = GAIM_UNSEEN_TEXT;
 	}
-	else
-		unseen = GAIM_UNSEEN_NONE;
 
 	gaim_conversation_set_unseen(conv, unseen);
+
+	/*
+	 * If we received an IM, and the GaimConvWindow is not active,
+	 * then make this conversation the active tab in this GaimConvWindow.
+	 *
+	 * We do this so that, when the user comes back to the conversation
+	 * window, the first thing they'll see is the new message.  This is
+	 * especially important when the IM window is flashing in their
+	 * taskbar--we want the title of the window to be set to the name
+	 * of the person that IMed them most recently.
+	 */
+	if ((gaim_conversation_get_type(conv) == GAIM_CONV_IM) &&
+		(flags & (GAIM_MESSAGE_RECV | GAIM_MESSAGE_ERROR)) &&
+		(!gaim_conv_window_has_focus(win)))
+	{
+		gaim_conv_window_switch_conversation(win, conv);
+	}
 }
 
 void
@@ -1620,6 +1639,7 @@
 	/*
 	 * Change the active conversation to this conversation unless the
 	 * user is already using this window.
+	 * TODO: There's a good chance this is no longer necessary
 	 */
 	if (!gaim_conv_window_has_focus(window))
 		gaim_conv_window_switch_conversation(window, conv);