From 5235e6046a6a1c924cd2d39edbef0fd8de2a21f8 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 23 Jul 2014 18:58:42 -0500 Subject: handle Screen.keepDisplayOn() returning a cookie whose value is '0' --- src/snap.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/snap.cpp b/src/snap.cpp index a601cae..cf9cbd8 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -30,6 +30,7 @@ #include #include +#include #include // std::call_once() #include #include @@ -484,7 +485,7 @@ private: g_message ("%s response is '%s'", G_STRFUNC, g_variant_print (args, true)); - g_clear_pointer (&self->m_screen_cookie, g_free); + self->m_screen_cookie = NO_SCREEN_COOKIE; g_variant_get (args, "(i)", &self->m_screen_cookie); g_message ("m_screen_cookie is now '%d'", self->m_screen_cookie); @@ -498,6 +499,7 @@ private: if (m_awake_cookie != nullptr) { +g_message ("%s calling clearSysState %s", G_STRFUNC, m_awake_cookie); g_dbus_connection_call (m_system_bus, "com.canonical.powerd", "/com/canonical/powerd", @@ -519,8 +521,9 @@ private: { g_return_if_fail (G_IS_DBUS_CONNECTION(m_system_bus)); - if (m_screen_cookie != 0) + if (m_screen_cookie != NO_SCREEN_COOKIE) { +g_message ("%s calling removeDisplayOnRequest %d", G_STRFUNC, (int)m_screen_cookie); g_dbus_connection_call (m_system_bus, "com.canonical.Unity.Screen", "/com/canonical/Unity/Screen", @@ -534,7 +537,7 @@ private: nullptr, nullptr); - m_screen_cookie = 0; + m_screen_cookie = NO_SCREEN_COOKIE; } } @@ -554,7 +557,9 @@ private: GCancellable * m_cancellable = nullptr; GDBusConnection * m_system_bus = nullptr; char * m_awake_cookie = nullptr; - int32_t m_screen_cookie = 0; + int32_t m_screen_cookie = NO_SCREEN_COOKIE; + + static constexpr int32_t NO_SCREEN_COOKIE { std::numeric_limits::min() }; static constexpr char const * HINT_SNAP {"x-canonical-snap-decisions"}; static constexpr char const * HINT_TINT {"x-canonical-private-button-tint"}; -- cgit v1.2.3