summaryrefslogtreecommitdiff
path: root/src/lib/ecore_x
diff options
context:
space:
mode:
authorthierry E <thierry@substantiel.fr>2017-05-09 10:02:31 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-05-09 10:15:01 -0700
commit71c8f1de27c17cd7cf249af16915295fe6fd7fc6 (patch)
treea131744f77bf92b841c077a0eda799898e37b1cb /src/lib/ecore_x
parentf160d41539431016bc133d912cc596349199d0bf (diff)
ecore_x: handle DPMS state for a more accurate idling evaluation.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib/ecore_x')
-rw-r--r--src/lib/ecore_x/ecore_x_screensaver.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/lib/ecore_x/ecore_x_screensaver.c b/src/lib/ecore_x/ecore_x_screensaver.c
index 8c186ea45e..faaa6256f7 100644
--- a/src/lib/ecore_x/ecore_x_screensaver.c
+++ b/src/lib/ecore_x/ecore_x_screensaver.c
@@ -43,6 +43,8 @@ ecore_x_screensaver_idle_time_get(void)
43{ 43{
44#ifdef ECORE_XSS 44#ifdef ECORE_XSS
45 XScreenSaverInfo *xss; 45 XScreenSaverInfo *xss;
46 unsigned long _idle;
47 int dummy;
46 int idle; 48 int idle;
47 49
48 LOGFN(__FILE__, __LINE__, __FUNCTION__); 50 LOGFN(__FILE__, __LINE__, __FUNCTION__);
@@ -50,8 +52,45 @@ ecore_x_screensaver_idle_time_get(void)
50 XScreenSaverQueryInfo(_ecore_x_disp, 52 XScreenSaverQueryInfo(_ecore_x_disp,
51 RootWindow(_ecore_x_disp, DefaultScreen( 53 RootWindow(_ecore_x_disp, DefaultScreen(
52 _ecore_x_disp)), xss); 54 _ecore_x_disp)), xss);
53 idle = xss->idle / 1000; 55
56 _idle = xss->idle;
54 XFree(xss); 57 XFree(xss);
58 if (DPMSQueryExtension(_ecore_x_disp, &dummy, &dummy))
59 {
60 CARD16 standby, suspend, off;
61 CARD16 state;
62 BOOL onoff;
63
64 if (DPMSCapable(_ecore_x_disp))
65 {
66 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
67 DPMSInfo(_ecore_x_disp, &state, &onoff);
68
69 if (onoff)
70 {
71 switch (state)
72 {
73 case DPMSModeStandby:
74 /* this check is a littlebit paranoid, but be sure */
75 if (_idle < (unsigned) (standby * 1000))
76 _idle += (standby * 1000);
77 break;
78 case DPMSModeSuspend:
79 if (_idle < (unsigned) ((suspend + standby) * 1000))
80 _idle += ((suspend + standby) * 1000);
81 break;
82 case DPMSModeOff:
83 if (_idle < (unsigned) ((off + suspend + standby) * 1000))
84 _idle += ((off + suspend + standby) * 1000);
85 break;
86 case DPMSModeOn:
87 default:
88 break;
89 }
90 }
91 }
92 }
93 idle = _idle / 1000;
55 94
56 return idle; 95 return idle;
57#else 96#else