Dmitry Butskoy e7e551c
diff -Nrbu mail-notification-5.4/build/src/mn-popup.c mail-notification-5.4-OK/build/src/mn-popup.c
Dmitry Butskoy e7e551c
--- mail-notification-5.4/build/src/mn-popup.c	2008-05-22 19:47:49.000000000 +0400
Dmitry Butskoy e7e551c
+++ mail-notification-5.4-OK/build/src/mn-popup.c	2010-10-11 17:42:32.000000000 +0400
Dmitry Butskoy e7e551c
@@ -177,6 +177,29 @@
Dmitry Butskoy e7e551c
 #undef __GOB_FUNCTION__
Dmitry Butskoy e7e551c
 
Dmitry Butskoy e7e551c
 static void 
Dmitry Butskoy e7e551c
+mn_popup_wait_for_icon_to_become_ready (void)
Dmitry Butskoy e7e551c
+{
Dmitry Butskoy e7e551c
+    int x, y;
Dmitry Butskoy e7e551c
+    int count = 0;
Dmitry Butskoy e7e551c
+
Dmitry Butskoy e7e551c
+    /* When the tray icon is created, it can still take some time before
Dmitry Butskoy e7e551c
+     * it has arrived at the correct position. This is especially the case
Dmitry Butskoy e7e551c
+     * on KDE environments. To work around this, add a little delay of at
Dmitry Butskoy e7e551c
+     * most 2 seconds before showing a popup which is attached to the notification */
Dmitry Butskoy e7e551c
+    do {
Dmitry Butskoy e7e551c
+        gdk_window_get_origin (gtk_widget_get_window (mn_shell->icon), &x, &y);
Dmitry Butskoy e7e551c
+
Dmitry Butskoy e7e551c
+        if (x != 0 || y != 0) {
Dmitry Butskoy e7e551c
+            break;
Dmitry Butskoy e7e551c
+        }
Dmitry Butskoy e7e551c
+
Dmitry Butskoy e7e551c
+        g_usleep(G_USEC_PER_SEC / 10);
Dmitry Butskoy e7e551c
+        count++;
Dmitry Butskoy e7e551c
+    } while (count < 20);
Dmitry Butskoy e7e551c
+}
Dmitry Butskoy e7e551c
+
Dmitry Butskoy e7e551c
+
Dmitry Butskoy e7e551c
+static void 
Dmitry Butskoy e7e551c
 mn_popup_init (MNPopup * o G_GNUC_UNUSED)
Dmitry Butskoy e7e551c
 {
Dmitry Butskoy e7e551c
 #define __GOB_FUNCTION__ "MN:Popup::init"
Dmitry Butskoy e7e551c
@@ -299,8 +322,10 @@
Dmitry Butskoy e7e551c
 		 "icon-name", "stock_mail",
Dmitry Butskoy e7e551c
 		 NULL);
Dmitry Butskoy e7e551c
 
Dmitry Butskoy e7e551c
-    if (mn_conf_get_enum_value(MN_TYPE_POPUP_POSITION, MN_CONF_POPUPS_POSITION) == MN_POPUP_POSITION_ATTACHED)
Dmitry Butskoy e7e551c
+    if (mn_conf_get_enum_value(MN_TYPE_POPUP_POSITION, MN_CONF_POPUPS_POSITION) == MN_POPUP_POSITION_ATTACHED) {
Dmitry Butskoy e7e551c
+      mn_popup_wait_for_icon_to_become_ready();
Dmitry Butskoy e7e551c
       g_object_set(self, "attach-widget", mn_shell->icon, NULL);
Dmitry Butskoy e7e551c
+    }
Dmitry Butskoy e7e551c
 
Dmitry Butskoy e7e551c
     g_string_free(body, TRUE);
Dmitry Butskoy e7e551c