diff options
author | Christian Hammond <chipx86@chipx86.com> | 2008-09-26 01:12:47 +0000 |
---|---|---|
committer | Christian Hammond <chipx86@chipx86.com> | 2008-09-26 01:12:47 +0000 |
commit | d5addcc1f46d2a50c32f55e36b0280968f22ded0 (patch) | |
tree | 9746086ead53a6dd9f51d483549cdeccb5dbf5fc /libnotify | |
parent | f4ff83ff20116937f0512781d38e2f3a81222534 (diff) | |
download | libnotify-d5addcc1f46d2a50c32f55e36b0280968f22ded0.tar.gz |
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.
Diffstat (limited to 'libnotify')
-rw-r--r-- | libnotify/notification.c | 46 | ||||
-rw-r--r-- | libnotify/notification.h | 2 |
2 files changed, 48 insertions, 0 deletions
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 <gtk/gtkstatusicon.h> #endif +#include <gdk/gdkx.h> #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); |