commit 93cc246ab35ba4ab17bd44541a5d6cd25afdba72
parent e65e0bf1fbfd4f05f76c2625644045421c91af61
Author: Dan Callaghan <djc@djc.id.au>
Date: Sat, 6 Nov 2010 17:11:52 +1000
wait for tray icon to appear before attaching notification, to ensure it is positioned correctly
Based on mail-notification-5.4-popup-attach.patch from Fedora:
http://pkgs.fedoraproject.org/gitweb/?p=mail-notification.git;a=blob;f=mail-notification-5.4-popup-attach.patch;h=b8d5f6a09ccd6b7a272acc34cc7c0417afcb7e1d;hb=0a002ddd116bd02343a4f9bbf4d0efdf594557ee
Related to Red Hat bug #608372:
https://bugzilla.redhat.com/show_bug.cgi?id=608372
This delay is (reportedly?) not necessary when using the new
GtkStatusIcon api.
Diffstat:
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/mn-popup.gob b/src/mn-popup.gob
@@ -51,8 +51,10 @@ class MN:Popup from Notify:Notification
"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) {
+ self_wait_for_icon_to_become_ready(self);
g_object_set(self, "attach-widget", mn_shell->icon, NULL);
+ }
g_string_free(body, TRUE);
@@ -63,6 +65,26 @@ class MN:Popup from Notify:Notification
g_signal_connect(self, "closed", G_CALLBACK(self_closed_h), NULL);
}
+ private void wait_for_icon_to_become_ready(self) {
+ 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);
+ }
+
private void
add_actions (self)
{