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