summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDeon Thomas <PrinceAMD.Elive@Gmail.com>2013-06-26 08:32:42 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-06-26 08:32:42 +0900
commit67df5b4ad1aff39b6792fa77847258c3f14b9b39 (patch)
treefcbaee2f153c99f319b2624217c99eaf254080b3 /src/lib
parentfdbc477f7990f78f69144a26d5990e35057b3317 (diff)
Ecore DPMS Function to get the current dpms power level
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore_x/Ecore_X.h9
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_dpms.c33
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_dpms.c24
3 files changed, 66 insertions, 0 deletions
diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h
index fa10024a27..8aac0e996c 100644
--- a/src/lib/ecore_x/Ecore_X.h
+++ b/src/lib/ecore_x/Ecore_X.h
@@ -398,6 +398,14 @@ typedef enum _Ecore_X_Error_Code
398 ECORE_X_ERROR_CODE_BAD_IMPLEMENTATION = 17, 398 ECORE_X_ERROR_CODE_BAD_IMPLEMENTATION = 17,
399} Ecore_X_Error_Code; 399} Ecore_X_Error_Code;
400 400
401typedef enum _Ecore_X_Dpms_Mode
402{
403 ECORE_X_DPMS_MODE_ON = 0,
404 ECORE_X_DPMS_MODE_STANDBY = 1,
405 ECORE_X_DPMS_MODE_SUSPEND = 2,
406 ECORE_X_DPMS_MODE_OFF = 3
407} Ecore_X_Dpms_Mode;
408
401typedef struct _Ecore_X_Event_Mouse_In Ecore_X_Event_Mouse_In; 409typedef struct _Ecore_X_Event_Mouse_In Ecore_X_Event_Mouse_In;
402typedef struct _Ecore_X_Event_Mouse_Out Ecore_X_Event_Mouse_Out; 410typedef struct _Ecore_X_Event_Mouse_Out Ecore_X_Event_Mouse_Out;
403typedef struct _Ecore_X_Event_Window_Focus_In Ecore_X_Event_Window_Focus_In; 411typedef struct _Ecore_X_Event_Window_Focus_In Ecore_X_Event_Window_Focus_In;
@@ -2371,6 +2379,7 @@ EAPI Eina_Bool ecore_x_dpms_query(void);
2371EAPI Eina_Bool ecore_x_dpms_capable_get(void); 2379EAPI Eina_Bool ecore_x_dpms_capable_get(void);
2372EAPI Eina_Bool ecore_x_dpms_enabled_get(void); 2380EAPI Eina_Bool ecore_x_dpms_enabled_get(void);
2373EAPI void ecore_x_dpms_enabled_set(int enabled); 2381EAPI void ecore_x_dpms_enabled_set(int enabled);
2382EAPI Ecore_X_Dpms_Mode ecore_x_dpms_power_level_get(void);
2374EAPI void ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned int *off); 2383EAPI void ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned int *off);
2375EAPI Eina_Bool ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off); 2384EAPI Eina_Bool ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off);
2376EAPI unsigned int ecore_x_dpms_timeout_standby_get(void); 2385EAPI unsigned int ecore_x_dpms_timeout_standby_get(void);
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_dpms.c b/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
index 98dc7d3d8c..95360e3073 100644
--- a/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
+++ b/src/lib/ecore_x/xcb/ecore_xcb_dpms.c
@@ -319,3 +319,36 @@ ecore_x_dpms_timeout_off_set(unsigned int new_timeout)
319 ecore_x_dpms_timeouts_set(standby, suspend, new_timeout); 319 ecore_x_dpms_timeouts_set(standby, suspend, new_timeout);
320} 320}
321 321
322/**
323 * Check the DPMS power level.
324 * @return @c 0 if DPMS is :In Use
325 * @return @c 1 if DPMS is :Blanked, low power
326 * @return @c 2 if DPMS is :Blanked, lower power
327 * @return @c 3 if DPMS is :Shut off, awaiting activity
328 * @return @c -1 otherwise.
329*/
330EAPI Ecore_X_Dpms_Mode
331ecore_x_dpms_power_level_get(void)
332{
333 Ecore_X_Dpms_Mode ret = -1;
334#ifdef ECORE_XCB_DPMS
335 xcb_dpms_info_cookie_t cookie;
336 xcb_dpms_info_reply_t *reply;
337#endif
338
339 LOGFN(__FILE__, __LINE__, __FUNCTION__);
340 CHECK_XCB_CONN;
341
342 if (!_dpms_avail) return ret;
343
344#ifdef ECORE_XCB_DPMS
345 cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
346 reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
347 if (!reply) return -1;
348
349 ret = reply->power_level;
350 free(reply);
351#endif
352
353 return ret;
354}
diff --git a/src/lib/ecore_x/xlib/ecore_x_dpms.c b/src/lib/ecore_x/xlib/ecore_x_dpms.c
index beb914d863..b3c3e38c4c 100644
--- a/src/lib/ecore_x/xlib/ecore_x_dpms.c
+++ b/src/lib/ecore_x/xlib/ecore_x_dpms.c
@@ -80,6 +80,30 @@ ecore_x_dpms_enabled_get(void)
80} 80}
81 81
82/** 82/**
83 * Check the DPMS power level.
84 * @return @c 0 if DPMS is :In Use
85 * @return @c 1 if DPMS is :Blanked, low power
86 * @return @c 2 if DPMS is :Blanked, lower power
87 * @return @c 3 if DPMS is :Shut off, awaiting activity
88 * @return @c -1 othwhise.
89 */
90
91EAPI Ecore_X_Dpms_Mode
92ecore_x_dpms_power_level_get(void)
93{
94#ifdef ECORE_XDPMS
95 unsigned char state;
96 unsigned short power_lvl;
97
98 LOGFN(__FILE__, __LINE__, __FUNCTION__);
99 DPMSInfo(_ecore_x_disp, &power_lvl, &state);
100 return (int)power_lvl;
101#else
102 return -1;
103#endif
104}
105
106/**
83 * Sets the DPMS state of the display. 107 * Sets the DPMS state of the display.
84 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise. 108 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
85 * @ingroup Ecore_X_DPMS_Group 109 * @ingroup Ecore_X_DPMS_Group