summaryrefslogtreecommitdiff
path: root/extra/mail-notification/mail-notification-5.4-popup-attach.patch
blob: b8d5f6a09ccd6b7a272acc34cc7c0417afcb7e1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
@@ -177,6 +177,29 @@
 #undef __GOB_FUNCTION__
 
 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);
+}
+
+
+static void 
 mn_popup_init (MNPopup * o G_GNUC_UNUSED)
 {
 #define __GOB_FUNCTION__ "MN:Popup::init"
@@ -299,8 +322,10 @@
 		 "icon-name", "stock_mail",
 		 NULL);
 
-    if (mn_conf_get_enum_value(MN_TYPE_POPUP_POSITION, MN_CONF_POPUPS_POSITION) == MN_POPUP_POSITION_ATTACHED)
+    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);
+    }
 
     g_string_free(body, TRUE);