aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-05-04 20:20:15 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-05-04 20:20:15 +0800
commitbb4750da5ff85a61e8e9d4643fc63fbefe34a1c0 (patch)
tree5104009c41478f4672ad3deab29c03b50e54df3b /src
parent046792f3fd596574132fe1d6217dd1877bffe743 (diff)
parent61de8fbbea5d8d096aafcaa8c2b8093d0f349c87 (diff)
downloadgsoc2013-empathy-bb4750da5ff85a61e8e9d4643fc63fbefe34a1c0.tar
gsoc2013-empathy-bb4750da5ff85a61e8e9d4643fc63fbefe34a1c0.tar.gz
gsoc2013-empathy-bb4750da5ff85a61e8e9d4643fc63fbefe34a1c0.tar.bz2
gsoc2013-empathy-bb4750da5ff85a61e8e9d4643fc63fbefe34a1c0.tar.lz
gsoc2013-empathy-bb4750da5ff85a61e8e9d4643fc63fbefe34a1c0.tar.xz
gsoc2013-empathy-bb4750da5ff85a61e8e9d4643fc63fbefe34a1c0.tar.zst
gsoc2013-empathy-bb4750da5ff85a61e8e9d4643fc63fbefe34a1c0.zip
Merge branch 'timestamp-615976'
Diffstat (limited to 'src')
-rw-r--r--src/empathy-call-window.c3
-rw-r--r--src/empathy-chat-manager.c5
-rw-r--r--src/empathy-chat-window.c48
-rw-r--r--src/empathy-chat-window.h3
-rw-r--r--src/empathy-event-manager.c19
-rw-r--r--src/empathy-main-window.c3
-rw-r--r--src/empathy-new-chatroom-dialog.c3
-rw-r--r--src/empathy.c9
8 files changed, 79 insertions, 14 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 943e2cd0f..153da4689 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -2387,7 +2387,8 @@ start_call (EmpathyCallWindow *self)
EmpathyCallWindowPriv *priv = GET_PRIV (self);
priv->call_started = TRUE;
- empathy_call_handler_start_call (priv->handler);
+ empathy_call_handler_start_call (priv->handler,
+ gtk_get_current_event_time ());
if (empathy_call_handler_has_initial_video (priv->handler))
{
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c
index 01506f52e..97d210c84 100644
--- a/src/empathy-chat-manager.c
+++ b/src/empathy-chat-manager.c
@@ -199,10 +199,11 @@ connection_ready_cb (TpConnection *connection,
if (error == NULL)
{
if (data->room)
- empathy_dispatcher_join_muc (connection, data->id, NULL, NULL);
+ empathy_dispatcher_join_muc (connection, data->id,
+ EMPATHY_DISPATCHER_NON_USER_ACTION, NULL, NULL);
else
empathy_dispatcher_chat_with_contact_id (connection, data->id,
- NULL, NULL);
+ EMPATHY_DISPATCHER_NON_USER_ACTION, NULL, NULL);
g_signal_emit (self, signals[CHATS_CHANGED], 0,
g_queue_get_length (priv->queue));
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 6e80bb458..d47e942f5 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,9 @@ typedef struct {
GtkAction *menu_tabs_left;
GtkAction *menu_tabs_right;
GtkAction *menu_tabs_detach;
+
+ /* Last user action time we acted upon to show a tab */
+ guint32 x_user_action_time;
} EmpathyChatWindowPriv;
static GList *chat_windows = NULL;
@@ -1682,7 +1693,7 @@ chat_window_drag_data_received (GtkWidget *widget,
if (connection) {
empathy_dispatcher_chat_with_contact_id (
- connection, contact_id, NULL, NULL);
+ connection, contact_id, gtk_get_current_event_time (), NULL, NULL);
}
g_strfreev (strv);
@@ -1704,7 +1715,8 @@ chat_window_drag_data_received (GtkWidget *widget,
}
/* Added to take care of any outstanding chat events */
- empathy_chat_window_present_chat (chat);
+ empathy_chat_window_present_chat (chat,
+ EMPATHY_DISPATCHER_NON_USER_ACTION);
/* We should return TRUE to remove the data when doing
* GDK_ACTION_MOVE, but we don't here otherwise it has
@@ -2267,10 +2279,12 @@ empathy_chat_window_find_chat (TpAccount *account,
}
void
-empathy_chat_window_present_chat (EmpathyChat *chat)
+empathy_chat_window_present_chat (EmpathyChat *chat,
+ gint64 timestamp)
{
EmpathyChatWindow *window;
EmpathyChatWindowPriv *priv;
+ guint32 x_timestamp;
g_return_if_fail (EMPATHY_IS_CHAT (chat));
@@ -2281,16 +2295,40 @@ empathy_chat_window_present_chat (EmpathyChat *chat)
window = empathy_chat_window_get_default (empathy_chat_is_room (chat));
if (!window) {
window = empathy_chat_window_new ();
+ gtk_widget_show_all (GET_PRIV (window)->dialog);
}
empathy_chat_window_add_chat (window, chat);
}
+ /* Don't force the window to show itself when it wasn't
+ * an action by the user
+ */
+ if (timestamp == EMPATHY_DISPATCHER_NON_USER_ACTION)
+ return;
+
priv = GET_PRIV (window);
+
+ if (timestamp == EMPATHY_DISPATCHER_CURRENT_TIME) {
+ x_timestamp = GDK_CURRENT_TIME;
+ } else {
+ x_timestamp = CLAMP (timestamp, 0, G_MAXUINT32);
+ /* Don't present or switch tab if the action was earlier than 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;
+
+ priv->x_user_action_time = x_timestamp;
+ }
+
empathy_chat_window_switch_to_chat (window, chat);
- empathy_window_present (GTK_WINDOW (priv->dialog));
+ empathy_window_present_with_time (GTK_WINDOW (priv->dialog),
+ x_timestamp);
- gtk_widget_grab_focus (chat->input_text_view);
+ gtk_widget_grab_focus (chat->input_text_view);
}
void
diff --git a/src/empathy-chat-window.h b/src/empathy-chat-window.h
index 93ffcc53a..4cbd2094a 100644
--- a/src/empathy-chat-window.h
+++ b/src/empathy-chat-window.h
@@ -72,7 +72,8 @@ void empathy_chat_window_switch_to_chat (EmpathyChatWindow *window
gboolean empathy_chat_window_has_focus (EmpathyChatWindow *window);
EmpathyChat * empathy_chat_window_find_chat (TpAccount *account,
const gchar *id);
-void empathy_chat_window_present_chat (EmpathyChat *chat);
+void empathy_chat_window_present_chat (EmpathyChat *chat,
+ gint64 timestamp);
void empathy_chat_window_get_nb_chats (EmpathyChatWindow *window,
guint *nb_rooms,
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index c4ab4ad78..841883d06 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -228,6 +228,12 @@ event_manager_add (EmpathyEventManager *manager,
static void
event_channel_process_func (EventPriv *event)
{
+ gint64 timestamp = gtk_get_current_event_time ();
+ if (timestamp == GDK_CURRENT_TIME)
+ timestamp = EMPATHY_DISPATCHER_CURRENT_TIME;
+
+ empathy_dispatch_operation_set_user_action_time (event->approval->operation,
+ timestamp);
empathy_dispatch_operation_approve (event->approval->operation);
}
@@ -235,6 +241,12 @@ static void
event_text_channel_process_func (EventPriv *event)
{
EmpathyTpChat *tp_chat;
+ gint64 timestamp = gtk_get_current_event_time ();
+ if (timestamp == GDK_CURRENT_TIME)
+ timestamp = EMPATHY_DISPATCHER_CURRENT_TIME;
+
+ empathy_dispatch_operation_set_user_action_time (event->approval->operation,
+ timestamp);
if (event->approval->handler != 0)
{
@@ -527,6 +539,7 @@ invite_dialog_response_cb (GtkDialog *dialog,
TpChannel *channel;
TpHandle self_handle;
GArray *members;
+ gint64 timestamp;
gtk_widget_destroy (GTK_WIDGET (approval->dialog));
approval->dialog = NULL;
@@ -556,6 +569,12 @@ invite_dialog_response_cb (GtkDialog *dialog,
tp_cli_channel_interface_group_call_add_members (channel, -1, members,
"", NULL, NULL, NULL, NULL);
+ timestamp = gtk_get_current_event_time ();
+ if (timestamp == GDK_CURRENT_TIME)
+ timestamp = EMPATHY_DISPATCHER_CURRENT_TIME;
+
+ empathy_dispatch_operation_set_user_action_time (approval->operation,
+ timestamp);
empathy_dispatch_operation_approve (approval->operation);
g_array_free (members, TRUE);
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 51d0ec9ef..6826ee534 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -908,7 +908,8 @@ main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
if (connection != NULL) {
DEBUG ("Requesting channel for '%s'", room);
- empathy_dispatcher_join_muc (connection, room, NULL, NULL);
+ empathy_dispatcher_join_muc (connection, room,
+ gtk_get_current_event_time (), NULL, NULL);
}
}
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index 7c330b22c..50b5f5d82 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -732,7 +732,8 @@ new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
}
DEBUG ("Requesting channel for '%s'", room_name);
- empathy_dispatcher_join_muc (connection, room_name, NULL, NULL);
+ empathy_dispatcher_join_muc (connection, room_name,
+ gtk_get_current_event_time (), NULL, NULL);
g_free (room_name);
}
diff --git a/src/empathy.c b/src/empathy.c
index 637778d47..5dcf035e3 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -133,7 +133,8 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
* (a GtkNotebook) when we'll call empathy_chat_window_present_chat */
}
- empathy_chat_window_present_chat (chat);
+ empathy_chat_window_present_chat (chat,
+ empathy_dispatch_operation_get_user_action_time (operation));
empathy_dispatch_operation_claim (operation);
}
@@ -481,7 +482,8 @@ account_status_changed_cb (TpAccount *account,
return;
empathy_dispatcher_join_muc (conn,
- empathy_chatroom_get_room (room), NULL, NULL);
+ empathy_chatroom_get_room (room), EMPATHY_DISPATCHER_NON_USER_ACTION,
+ NULL, NULL);
}
static void
@@ -529,7 +531,8 @@ account_manager_chatroom_ready_cb (GObject *source_object,
else
{
empathy_dispatcher_join_muc (conn,
- empathy_chatroom_get_room (room), NULL, NULL);
+ empathy_chatroom_get_room (room),
+ EMPATHY_DISPATCHER_NON_USER_ACTION, NULL, NULL);
}
}