Fix up ecore_x_dpms...formatting, removed the static int's for dpms version

as they are not used anywhere other than the init function. Added traps for
dpms_available before calling any dpms functions.


SVN revision: 28687
This commit is contained in:
Christopher Michael 2007-03-13 09:30:17 +00:00
parent 54d6fba5d5
commit c537ed8e3c
1 changed files with 21 additions and 37 deletions

View File

@ -4,17 +4,14 @@
#include "ecore_x_private.h" #include "ecore_x_private.h"
static int _dpms_available; static int _dpms_available;
#ifdef ECORE_XDPMS
static int _dpms_major, _dpms_minor;
#endif
void void
_ecore_x_dpms_init(void) _ecore_x_dpms_init(void)
{ {
#ifdef ECORE_XDPMS #ifdef ECORE_XDPMS
int _dpms_major, _dpms_minor;
_dpms_major = 1; _dpms_major = 1;
_dpms_minor = 0; _dpms_minor = 0;
@ -27,15 +24,12 @@ _ecore_x_dpms_init(void)
#endif #endif
} }
/** /**
* @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
* *
* Functions related to the X DPMS extension. * Functions related to the X DPMS extension.
*/ */
/** /**
* Checks if the X DPMS extension is available on the server. * Checks if the X DPMS extension is available on the server.
* @return @c 1 if the X DPMS extension is available, @c 0 otherwise. * @return @c 1 if the X DPMS extension is available, @c 0 otherwise.
@ -55,10 +49,10 @@ ecore_x_dpms_query(void)
EAPI int EAPI int
ecore_x_dpms_capable_get(void) ecore_x_dpms_capable_get(void)
{ {
if (!_dpms_available) return 0;
return DPMSCapable(_ecore_x_disp); return DPMSCapable(_ecore_x_disp);
} }
/** /**
* Checks the DPMS state of the display. * Checks the DPMS state of the display.
* @return @c 1 if DPMS is enabled, @c 0 otherwise. * @return @c 1 if DPMS is enabled, @c 0 otherwise.
@ -70,11 +64,11 @@ ecore_x_dpms_enabled_get(void)
unsigned char state; unsigned char state;
unsigned short power_lvl; unsigned short power_lvl;
if (!_dpms_available) return 0;
DPMSInfo(_ecore_x_disp, &power_lvl, &state); DPMSInfo(_ecore_x_disp, &power_lvl, &state);
return state; return state;
} }
/** /**
* Sets the DPMS state of the display. * Sets the DPMS state of the display.
* @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise. * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
@ -83,13 +77,13 @@ ecore_x_dpms_enabled_get(void)
EAPI void EAPI void
ecore_x_dpms_enabled_set(int enabled) ecore_x_dpms_enabled_set(int enabled)
{ {
if (!_dpms_available) return;
if (enabled) if (enabled)
DPMSEnable(_ecore_x_disp); DPMSEnable(_ecore_x_disp);
else else
DPMSDisable(_ecore_x_disp); DPMSDisable(_ecore_x_disp);
} }
/** /**
* Gets the timeouts. The values are in unit of seconds. * Gets the timeouts. The values are in unit of seconds.
* @param standby Amount of time of inactivity before standby mode will be invoked. * @param standby Amount of time of inactivity before standby mode will be invoked.
@ -100,10 +94,11 @@ ecore_x_dpms_enabled_set(int enabled)
EAPI void EAPI void
ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned int *off) ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned int *off)
{ {
DPMSGetTimeouts(_ecore_x_disp, (unsigned short *)standby, (unsigned short *)suspend, (unsigned short *)off); if (!_dpms_available) return;
DPMSGetTimeouts(_ecore_x_disp, (unsigned short *)standby,
(unsigned short *)suspend, (unsigned short *)off);
} }
/** /**
* Sets the timeouts. The values are in unit of seconds. * Sets the timeouts. The values are in unit of seconds.
* @param standby Amount of time of inactivity before standby mode will be invoked. * @param standby Amount of time of inactivity before standby mode will be invoked.
@ -114,13 +109,10 @@ ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned
EAPI int EAPI int
ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off) ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off)
{ {
return DPMSSetTimeouts(_ecore_x_disp, if (!_dpms_available) return 0;
standby, return DPMSSetTimeouts(_ecore_x_disp, standby, suspend, off);
suspend,
off);
} }
/** /**
* Returns the amount of time of inactivity before standby mode is invoked. * Returns the amount of time of inactivity before standby mode is invoked.
* @return The standby timeout value. * @return The standby timeout value.
@ -131,11 +123,11 @@ ecore_x_dpms_timeout_standby_get()
{ {
unsigned short standby, suspend, off; unsigned short standby, suspend, off;
if (!_dpms_available) return 0;
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
return standby; return standby;
} }
/** /**
* Returns the amount of time of inactivity before the second level of * Returns the amount of time of inactivity before the second level of
* power saving is invoked. * power saving is invoked.
@ -147,11 +139,11 @@ ecore_x_dpms_timeout_suspend_get()
{ {
unsigned short standby, suspend, off; unsigned short standby, suspend, off;
if (!_dpms_available) return 0;
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
return suspend; return suspend;
} }
/** /**
* Returns the amount of time of inactivity before the third and final * Returns the amount of time of inactivity before the third and final
* level of power saving is invoked. * level of power saving is invoked.
@ -163,11 +155,11 @@ ecore_x_dpms_timeout_off_get()
{ {
unsigned short standby, suspend, off; unsigned short standby, suspend, off;
if (!_dpms_available) return 0;
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
return off; return off;
} }
/** /**
* Sets the standby timeout (in unit of seconds). * Sets the standby timeout (in unit of seconds).
* @param new_standby Amount of time of inactivity before standby mode will be invoked. * @param new_standby Amount of time of inactivity before standby mode will be invoked.
@ -178,14 +170,11 @@ ecore_x_dpms_timeout_standby_set(unsigned int new_timeout)
{ {
unsigned short standby, suspend, off; unsigned short standby, suspend, off;
if (!_dpms_available) return;
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
DPMSSetTimeouts(_ecore_x_disp, DPMSSetTimeouts(_ecore_x_disp, new_timeout, suspend, off);
new_timeout,
suspend,
off);
} }
/** /**
* Sets the suspend timeout (in unit of seconds). * Sets the suspend timeout (in unit of seconds).
* @param suspend Amount of time of inactivity before the screen is placed into suspend mode. * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
@ -196,14 +185,11 @@ ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout)
{ {
unsigned short standby, suspend, off; unsigned short standby, suspend, off;
if (!_dpms_available) return;
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
DPMSSetTimeouts(_ecore_x_disp, DPMSSetTimeouts(_ecore_x_disp, standby, new_timeout, off);
standby,
new_timeout,
off);
} }
/** /**
* Sets the off timeout (in unit of seconds). * Sets the off timeout (in unit of seconds).
* @param off Amount of time of inactivity before the monitor is shut off. * @param off Amount of time of inactivity before the monitor is shut off.
@ -214,9 +200,7 @@ ecore_x_dpms_timeout_off_set(unsigned int new_timeout)
{ {
unsigned short standby, suspend, off; unsigned short standby, suspend, off;
if (!_dpms_available) return;
DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off); DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
DPMSSetTimeouts(_ecore_x_disp, DPMSSetTimeouts(_ecore_x_disp, standby, suspend, new_timeout);
standby,
suspend,
new_timeout);
} }