diff --git a/NEWS b/NEWS index 6e44447..0e52dc6 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,9 @@ version 0.4.5: Rocha. * Added support for sending the closed reason in the "closed" signal handler. (Ticket #139) + * Added support for sending the status icon XID to the notification + daemon. This will allow better position tracking for context + notifications. Patch by Colin Walters. * Fixed a breakage where we were including gtkversion.h directly. version 0.4.4 (27-February-2007): diff --git a/libnotify/notification.c b/libnotify/notification.c index 0f8260e..2de4768 100644 --- a/libnotify/notification.c +++ b/libnotify/notification.c @@ -31,6 +31,7 @@ # define HAVE_STATUS_ICON # include #endif +#include #define CHECK_DBUS_VERSION(major, minor) \ (DBUS_MAJOR_VER > (major) || \ @@ -396,6 +397,13 @@ notify_notification_finalize(GObject *object) G_OBJECT_CLASS(parent_class)->finalize(object); } +static GtkWidget * +get_internal_tray_icon (GtkStatusIcon *status) +{ + /* This function is a temporary hack */ + return GTK_WIDGET (*((GtkWidget**)(status->priv))); +} + static void _notify_notification_update_applet_hints(NotifyNotification *n) { @@ -407,6 +415,18 @@ _notify_notification_update_applet_hints(NotifyNotification *n) if (priv->status_icon != NULL) { GdkRectangle rect; + GtkWidget *internal_tray = get_internal_tray_icon (priv->status_icon); + GdkWindow *window; + + // TODO: this is sort of a hack, but we need a window ID to send along + gtk_widget_realize (internal_tray); + window = internal_tray->window; + + if (window != NULL) + { + guint32 xid = GDK_WINDOW_XID (window); + notify_notification_set_hint_uint32(n, "window-xid", xid); + } if (!gtk_status_icon_get_geometry(priv->status_icon, &screen, &rect, NULL)) @@ -1003,6 +1023,32 @@ notify_notification_set_hint_int32(NotifyNotification *notification, g_strdup(key), hint_value); } + +/** + * notify_notification_set_hint_uint32: + * @notification: The notification. + * @key: The hint. + * @value: The hint's value. + * + * Sets a hint with an unsigned 32-bit integer value. + */ +void +notify_notification_set_hint_uint32(NotifyNotification *notification, + const gchar *key, guint value) +{ + GValue *hint_value; + + g_return_if_fail(notification != NULL); + g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification)); + g_return_if_fail(key != NULL && *key != '\0'); + + hint_value = g_new0(GValue, 1); + g_value_init(hint_value, G_TYPE_UINT); + g_value_set_uint(hint_value, value); + g_hash_table_insert(notification->priv->hints, + g_strdup(key), hint_value); +} + /** * notify_notification_set_hint_double: * @notification: The notification. diff --git a/libnotify/notification.h b/libnotify/notification.h index d5ca193..bd21010 100644 --- a/libnotify/notification.h +++ b/libnotify/notification.h @@ -127,6 +127,8 @@ void notify_notification_set_icon_from_pixbuf(NotifyNotification *notification, void notify_notification_set_hint_int32(NotifyNotification *notification, const gchar *key, gint value); +void notify_notification_set_hint_uint32(NotifyNotification *notification, + const gchar *key, guint value); void notify_notification_set_hint_double(NotifyNotification *notification, const gchar *key, gdouble value);