Skip to content

Returned ID is wrong with replaces_id if original notification is gone

The notification spec says:

If replaces_id is not 0, the returned value is the same value as replaces_id.

However, xfce4-notifyd does:

    if(replaces_id
       && (window = g_tree_lookup(xndaemon->active_notifications,
                                  GUINT_TO_POINTER(replaces_id))))
    {
        // [...]
        OUT_id = replaces_id;
    } else {
        // [...]
        g_tree_insert(xndaemon->active_notifications,
                      GUINT_TO_POINTER(OUT_id), window);
        // [...]
    }

thus allocating a new ID if replace_id was given but the notification isn't shown anymore.

This can be reproduced by doing

gdbus call --session \
           --dest org.freedesktop.Notifications \
           --object-path /org/freedesktop/Notifications \
           --method org.freedesktop.Notifications.Notify \
           -- \
           my_app_name \
           0 \
           gtk-dialog-info \
           "The Summary" \
           "Here's the body of the notification" \
           '[]' \
           {} \
           -1

and then waiting until the notification is gone, and invoking the same call again with the previously returned ID instead of 0.

Edited by Florian Bruhin