Skip to content

Commit

Permalink
fixup SDL2 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 27, 2014
1 parent cb5a9a0 commit fafb03b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/notifications.cpp
Expand Up @@ -10,7 +10,13 @@
#include <cstdlib>
#include <list>

#include "SDL_version.h"

#if SDL_VERSION_ATLEAST(2,0,0)
#define NO_NOTIFICATIONS // It seems that SDL_active does not exist and I don't know what the analogue was
#else
#include "SDL_active.h"
#endif

#ifdef HAVE_LIBDBUS
#include <dbus/dbus.h>
Expand All @@ -35,6 +41,14 @@ using boost::uint32_t;

namespace notifications
{
#if !(defined(HAVE_LIBDBUS) || defined(HAVE_GROWL) || defined(_WIN32))
#define NO_NOTIFICATIONS
#endif

#if defined(NO_NOTIFICATIONS)
void send_notification(const std::string& /*owner*/, const std::string& /*message*/)
{}
#else

#ifdef HAVE_LIBDBUS
/** Use KDE 4 notifications. */
Expand Down Expand Up @@ -170,17 +184,13 @@ static uint32_t send_dbus_notification(DBusConnection *connection, uint32_t repl
if (kde_style) return 0;
return id;
}
#endif
#endif // end #if LIB_DBUS

#if defined(HAVE_LIBDBUS) || defined(HAVE_GROWL) || defined(_WIN32)
// Still in #if !defined NO_NOTIFICATIONS
void send_notification(const std::string& owner, const std::string& message)
{
if (preferences::get("disable_notifications", false)) { return; }
#else
void send_notification(const std::string& /*owner*/, const std::string& /*message*/)
{
#endif
#if defined(HAVE_LIBDBUS) || defined(HAVE_GROWL) || defined(_WIN32)

Uint8 app_state = SDL_GetAppState();

// Do not show notifications when the window is visible...
Expand All @@ -191,7 +201,6 @@ void send_notification(const std::string& /*owner*/, const std::string& /*messag
return;
}
}
#endif

#ifdef HAVE_LIBDBUS
DBusConnection *connection = get_dbus_connection();
Expand Down Expand Up @@ -260,5 +269,6 @@ void send_notification(const std::string& /*owner*/, const std::string& /*messag
windows_tray_notification::show(notification_title, notification_message);
#endif
}
#endif //end #else !defined(NO_NOTIFICATIONS)

} //end namespace notifications

0 comments on commit fafb03b

Please sign in to comment.