From ff11a8111973ba4aa5b842555b22da64814705ab Mon Sep 17 00:00:00 2001 From: Adam Boardman Date: Sun, 20 May 2018 17:40:03 +0100 Subject: [PATCH] Updated to use existing API's as dim state is not needed --- include/mce_display.h | 1 - spec/com.canonical.Unity.Screen.xml | 9 ++++---- src/mce_display.c | 32 ++++++++++------------------- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/include/mce_display.h b/include/mce_display.h index 7a8c496..4828fdf 100644 --- a/include/mce_display.h +++ b/include/mce_display.h @@ -43,7 +43,6 @@ G_BEGIN_DECLS typedef enum mce_display_state { MCE_DISPLAY_STATE_OFF, - MCE_DISPLAY_STATE_DIM, MCE_DISPLAY_STATE_ON } MCE_DISPLAY_STATE; diff --git a/spec/com.canonical.Unity.Screen.xml b/spec/com.canonical.Unity.Screen.xml index 3f53311..2e153d0 100644 --- a/spec/com.canonical.Unity.Screen.xml +++ b/spec/com.canonical.Unity.Screen.xml @@ -4,11 +4,12 @@ "http://standards.freedesktop.org/dbus/1.0/introspect.dtd"> - - + + - - + + + diff --git a/src/mce_display.c b/src/mce_display.c index 918a830..9dd513a 100644 --- a/src/mce_display.c +++ b/src/mce_display.c @@ -59,10 +59,9 @@ enum mce_display_signal { #define SIGNAL_STATE_CHANGED_NAME "mce-display-state-changed" #define MCE_DISPLAY_OFF_STRING "off" -#define MCE_DISPLAY_DIM_STRING "dim" #define MCE_DISPLAY_ON_STRING "on" -#define MCE_DISPLAY_SIG "displayStatusInd" +#define MCE_DISPLAY_SIG "DisplayPowerStateChange" static guint mce_display_signals[SIGNAL_COUNT] = { 0 }; @@ -81,19 +80,11 @@ static void mce_display_status_update( MceDisplay* self, - const char* status) + int32_t status) { - MCE_DISPLAY_STATE state; + MCE_DISPLAY_STATE state = status; MceDisplayPriv* priv = self->priv; - if (!g_strcmp0(status, MCE_DISPLAY_OFF_STRING)) { - state = MCE_DISPLAY_STATE_OFF; - } else if (!g_strcmp0(status, MCE_DISPLAY_DIM_STRING)) { - state = MCE_DISPLAY_STATE_DIM; - } else { - GASSERT(!g_strcmp0(status, MCE_DISPLAY_ON_STRING)); - state = MCE_DISPLAY_STATE_ON; - } if (self->state != state) { self->state = state; g_signal_emit(self, mce_display_signals[SIGNAL_STATE_CHANGED], 0); @@ -112,14 +103,13 @@ mce_display_status_query_done( gpointer arg) { GError* error = NULL; - char* status = NULL; + int32_t status = 0; MceDisplay* self = MCE_DISPLAY(arg); - if (com_canonical_unity_screen_call_get_display_status_finish( + if (com_canonical_unity_screen_call_get_display_power_state_finish( COM_CANONICAL_UNITY_SCREEN(proxy), &status, result, &error)) { - GDEBUG("Display is currently %s", status); + GDEBUG("Display is currently %d", status); mce_display_status_update(self, status); - g_free(status); } else { /* * We could retry but it's probably not worth the trouble @@ -135,12 +125,12 @@ mce_display_status_query_done( static void -mce_display_status_ind( +mce_display_power_state_change( ComCanonicalUnityScreen* proxy, - const char* status, + int32_t status, gpointer arg) { - GDEBUG("Display is %s", status); + GDEBUG("Display is %d", status); mce_display_status_update(MCE_DISPLAY(arg), status); } @@ -160,10 +150,10 @@ mce_display_status_query( */ if (proxy->signal && !priv->display_status_ind_id) { priv->display_status_ind_id = g_signal_connect(proxy->signal, - MCE_DISPLAY_SIG, G_CALLBACK(mce_display_status_ind), self); + MCE_DISPLAY_SIG, G_CALLBACK(mce_display_power_state_change), self); } if (proxy->request && proxy->valid) { - com_canonical_unity_screen_call_get_display_status(proxy->request, NULL, + com_canonical_unity_screen_call_get_display_power_state(proxy->request, NULL, mce_display_status_query_done, mce_display_ref(self)); } }