From e365214c51f8673feb293c8175c87c92672666b9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 27 Feb 2014 11:13:08 -0500 Subject: when deciding whether to do a bubble or snap notification, see if the server supports actions. --- src/snap.cpp | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/snap.cpp b/src/snap.cpp index dcad68a..b1a2e51 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -27,6 +27,9 @@ #include #include +#include +#include + #define ALARM_SOUND_FILENAME "/usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg" namespace unity { @@ -177,22 +180,14 @@ void snap_data_destroy_notify(gpointer gdata) delete static_cast(gdata); } -bool server_is_notify_osd(void) +std::set get_server_caps() { - static bool tested = false; - static bool is_notify_osd = false; - - if (G_UNLIKELY(!tested)) - { - gchar* name=nullptr; - notify_get_server_info(&name, nullptr, nullptr, nullptr); - is_notify_osd = !g_strcmp0(name, "notify-osd"); - g_free(name); - - tested = true; - } - - return is_notify_osd; + std::set caps_set; + auto caps_gl = notify_get_server_caps(); + for(auto l=caps_gl; l!=nullptr; l=l->next) + caps_set.insert((const char*)l->data); + g_list_free_full(caps_gl, g_free); + return caps_set; } typedef enum @@ -207,11 +202,22 @@ NotifyMode; NotifyMode get_notify_mode() { - // no real point in showing snap decisions on the desktop... - if (server_is_notify_osd()) - return NOTIFY_MODE_BUBBLE; + static NotifyMode mode; + static bool mode_inited = false; + + if (G_UNLIKELY(!mode_inited)) + { + const auto caps = get_server_caps(); + + if (caps.count("actions")) + mode = NOTIFY_MODE_SNAP; + else + mode = NOTIFY_MODE_BUBBLE; + + mode_inited = true; + } - return NOTIFY_MODE_SNAP; + return mode; } void show_notification (SnapData* data, NotifyMode mode) -- cgit v1.2.3