gaim/gaim

ea6922559e5f
Parents ad7d7b3c841f
Children df5ed5c6ff4b
Fix Red Hat bug #bug #159267 for real this time. This is a change
to how our conversation tabs signal that you have new messages.

1. If you get a new IM from someone, and your conversation window is
not focused, then Gaim will switch to the tab containing the new
message.
2. If you have a new IM from someone, but the conversation window is
not focused, the tab will remain red even if it is the "active"
conversation in the window. It will stop being red when the
window receives focus.

I'll apply this to HEAD in a day or three, unless someone wants to
be super cool and do it for me.
--- a/src/conversation.c Wed Jun 01 22:34:31 2005 -0400
+++ b/src/conversation.c Fri Jun 03 01:13:52 2005 -0400
@@ -614,8 +614,6 @@
if (ops != NULL && ops->switch_conversation != NULL)
ops->switch_conversation(win, index);
- gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE);
-
gaim_signal_emit(gaim_conversations_get_handle(),
"conversation-switched", old_conv, conv);
}
@@ -1514,7 +1512,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;
@@ -1525,10 +1529,24 @@
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) &&
+ (!gaim_conv_window_has_focus(win)))
+ {
+ gaim_conv_window_switch_conversation(win, gaim_conversation_get_index(conv));
+ }
}
void
@@ -1768,6 +1786,8 @@
else
return FALSE;
window = gaim_conversation_get_window(conv);
+
+ /* TODO: There's a good chance this is no longer necessary */
if (!gaim_conv_window_has_focus(window)) /* don't change the active conversation if the user is using this window */
gaim_conv_window_switch_conversation(window, gaim_conversation_get_index(conv));
--- a/src/gtkconv.c Wed Jun 01 22:34:31 2005 -0400
+++ b/src/gtkconv.c Fri Jun 03 01:13:52 2005 -0400
@@ -146,6 +146,22 @@
return TRUE;
}
+/*
+ * When a conversation window is focused, we know the user
+ * has looked at it so we know there are no longer unseen
+ * messages.
+ */
+static gint
+focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d)
+{
+ GaimConvWindow *win = (GaimConvWindow *)d;
+ GaimConversation *conv = gaim_conv_window_get_active_conversation(win);
+
+ gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE);
+
+ return FALSE;
+}
+
static gint
close_conv_cb(GtkWidget *w, gpointer d)
{
@@ -2979,7 +2995,11 @@
gtkwin = GAIM_GTK_WINDOW(win);
gtkconv = GAIM_GTK_CONVERSATION(conv);
- gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE);
+ /*
+ * Only set "unseen" to "none" if the window has focus
+ */
+ if (gaim_conv_window_has_focus(win))
+ gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE);
/* Update the menubar */
gray_stuff_out(conv);
@@ -4578,6 +4598,9 @@
g_signal_connect(G_OBJECT(gtkwin->window), "delete_event",
G_CALLBACK(close_win_cb), win);
+ g_signal_connect(G_OBJECT(gtkwin->window), "focus_in_event",
+ G_CALLBACK(focus_win_cb), win);
+
/* Create the notebook. */
gtkwin->notebook = gtk_notebook_new();