aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2010-04-25 01:35:42 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2010-04-25 02:44:09 +0800
commitd84744422bb86a38d130259b6ef7ecd41b630ce4 (patch)
tree90f6d024a934f88a0d36f1581867b481d6d86af2 /src
parent9e34e6de9a81e02929cfc65d771a4da6eb348df6 (diff)
downloadgsoc2013-empathy-d84744422bb86a38d130259b6ef7ecd41b630ce4.tar
gsoc2013-empathy-d84744422bb86a38d130259b6ef7ecd41b630ce4.tar.gz
gsoc2013-empathy-d84744422bb86a38d130259b6ef7ecd41b630ce4.tar.bz2
gsoc2013-empathy-d84744422bb86a38d130259b6ef7ecd41b630ce4.tar.lz
gsoc2013-empathy-d84744422bb86a38d130259b6ef7ecd41b630ce4.tar.xz
gsoc2013-empathy-d84744422bb86a38d130259b6ef7ecd41b630ce4.tar.zst
gsoc2013-empathy-d84744422bb86a38d130259b6ef7ecd41b630ce4.zip
Only present and tab switch for new events
Diffstat (limited to 'src')
-rw-r--r--src/empathy-chat-window.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 0c4089ee7..f80223cc8 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include <gdk/gdkx.h>
#include <glib/gi18n.h>
#include <libnotify/notification.h>
@@ -62,6 +63,13 @@
#define DEBUG_FLAG EMPATHY_DEBUG_CHAT
#include <libempathy/empathy-debug.h>
+/* Macro to compare guint32 X timestamps, while accounting for wrapping around
+ */
+#define X_EARLIER_OR_EQL(t1, t2) \
+ ((t1 <= t2 && ((t2 - t1) < G_MAXUINT32/2)) \
+ || (t1 >= t2 && (t1 - t2) > (G_MAXUINT32/2)) \
+ )
+
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatWindow)
typedef struct {
EmpathyChat *current_chat;
@@ -99,6 +107,8 @@ typedef struct {
GtkAction *menu_tabs_left;
GtkAction *menu_tabs_right;
GtkAction *menu_tabs_detach;
+
+ guint32 x_user_action_time;
} EmpathyChatWindowPriv;
static GList *chat_windows = NULL;
@@ -2273,6 +2283,7 @@ empathy_chat_window_present_chat (EmpathyChat *chat,
{
EmpathyChatWindow *window;
EmpathyChatWindowPriv *priv;
+ guint32 x_timestamp;
g_return_if_fail (EMPATHY_IS_CHAT (chat));
@@ -2295,12 +2306,24 @@ empathy_chat_window_present_chat (EmpathyChat *chat,
if (timestamp == EMPATHY_DISPATCHER_NON_USER_ACTION)
return;
+ x_timestamp = CLAMP (timestamp, 0, G_MAXUINT32);
+
priv = GET_PRIV (window);
+
+ /* Don't present or switch tab if the action was earlier then the
+ last actions X time, accounting for overflow and the first ever
+ presentation */
+
+ if (priv->x_user_action_time != 0
+ && X_EARLIER_OR_EQL (x_timestamp, priv->x_user_action_time))
+ return;
+
empathy_chat_window_switch_to_chat (window, chat);
empathy_window_present_with_time (GTK_WINDOW (priv->dialog),
- CLAMP (timestamp, 0, G_MAXUINT32));
+ x_timestamp);
- gtk_widget_grab_focus (chat->input_text_view);
+ gtk_widget_grab_focus (chat->input_text_view);
+ priv->x_user_action_time = x_timestamp;
}
void