summaryrefslogtreecommitdiffstats
path: root/krandr
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-09-03 22:46:14 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-09-03 22:46:14 +0000
commit5b3becd0a5f8f20530034d657db5fc16e4001983 (patch)
tree5ddc67a993e0d262cf3a6985328011507c00e78a /krandr
parent5efcb9fb4084eda4226e6a28747a0a7e130cfcc0 (diff)
downloadtdelibs-5b3becd0a5f8f20530034d657db5fc16e4001983.tar.gz
tdelibs-5b3becd0a5f8f20530034d657db5fc16e4001983.zip
Add DPMS support to libkrandr
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1251242 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krandr')
-rw-r--r--krandr/CMakeLists.txt2
-rw-r--r--krandr/libkrandr.cc70
-rw-r--r--krandr/libkrandr.h5
-rw-r--r--krandr/randr.h6
4 files changed, 82 insertions, 1 deletions
diff --git a/krandr/CMakeLists.txt b/krandr/CMakeLists.txt
index 9f1b45755..31ab2a067 100644
--- a/krandr/CMakeLists.txt
+++ b/krandr/CMakeLists.txt
@@ -43,6 +43,6 @@ set( ${target}_SRCS
tde_add_library( ${target} SHARED AUTOMOC
SOURCES ${${target}_SRCS}
VERSION 0.0.95
- LINK kdeui-shared ${XRANDR_LIBRARIES}
+ LINK kdeui-shared ${XRANDR_LIBRARIES} Xext
DESTINATION ${LIB_INSTALL_DIR}
)
diff --git a/krandr/libkrandr.cc b/krandr/libkrandr.cc
index 956328872..182ca7dcf 100644
--- a/krandr/libkrandr.cc
+++ b/krandr/libkrandr.cc
@@ -33,6 +33,8 @@
#include "libkrandr.h"
+#include <X11/extensions/dpms.h>
+
// FIXME
// For now, just use the standalone xrandr program to apply the display settings
#define USE_XRANDR_PROGRAM
@@ -433,6 +435,11 @@ void KRandrSimpleAPI::saveSystemwideDisplayConfiguration(bool enable, TQString p
display_config->writeEntry("AbsYPos", screendata->absolute_y_position);
display_config->writeEntry("CurrentXPixelCount", screendata->current_x_pixel_count);
display_config->writeEntry("CurrentYPixelCount", screendata->current_y_pixel_count);
+ display_config->writeEntry("HasDPMS", screendata->has_dpms);
+ display_config->writeEntry("EnableDPMS", screendata->enable_dpms);
+ display_config->writeEntry("DPMSStandbyDelay", screendata->dpms_standby_delay);
+ display_config->writeEntry("DPMSSuspendDelay", screendata->dpms_suspend_delay);
+ display_config->writeEntry("DPMSPowerDownDelay", screendata->dpms_off_delay);
i++;
}
@@ -510,6 +517,11 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::loadSystemwideDisplayConfiguration(
screendata->absolute_y_position = display_config->readNumEntry("AbsYPos");
screendata->current_x_pixel_count = display_config->readNumEntry("CurrentXPixelCount");
screendata->current_y_pixel_count = display_config->readNumEntry("CurrentYPixelCount");
+ screendata->has_dpms = display_config->readBoolEntry("HasDPMS");
+ screendata->enable_dpms = display_config->readBoolEntry("EnableDPMS");
+ screendata->dpms_standby_delay = display_config->readNumEntry("DPMSStandbyDelay");
+ screendata->dpms_suspend_delay = display_config->readNumEntry("DPMSSuspendDelay");
+ screendata->dpms_off_delay = display_config->readNumEntry("DPMSPowerDownDelay");
}
}
@@ -699,6 +711,7 @@ bool KRandrSimpleAPI::applySystemwideDisplayConfiguration(TQPtrList<SingleScreen
}
applySystemwideDisplayGamma(screenInfoArray);
+ applySystemwideDisplayDPMS(screenInfoArray);
if (test == TRUE) {
int ret = showTestConfigurationDialog();
@@ -877,6 +890,40 @@ void KRandrSimpleAPI::applySystemwideDisplayGamma(TQPtrList<SingleScreenData> sc
}
}
+void KRandrSimpleAPI::applySystemwideDisplayDPMS(TQPtrList<SingleScreenData> screenInfoArray) {
+ int i;
+ Display *randr_display;
+ XRROutputInfo *output_info;
+ ScreenInfo *randr_screen_info;
+ XRRCrtcGamma *gamma;
+
+ SingleScreenData *screendata;
+
+ if (isValid() == true) {
+ randr_display = qt_xdisplay();
+ randr_screen_info = read_screen_info(randr_display);
+ for (i = 0; i < randr_screen_info->n_output; i++) {
+ screendata = screenInfoArray.at(i);
+ output_info = randr_screen_info->outputs[i]->info;
+ CrtcInfo *current_crtc = randr_screen_info->outputs[i]->cur_crtc;
+ if (!current_crtc) {
+ continue;
+ }
+ if (!screendata->has_dpms) {
+ continue;
+ }
+ if (screendata->enable_dpms) {
+ DPMSSetTimeouts(randr_display, screendata->dpms_standby_delay, screendata->dpms_suspend_delay, screendata->dpms_off_delay);
+ DPMSEnable(randr_display);
+ }
+ else {
+ DPMSDisable(randr_display);
+ }
+ }
+ freeScreenInfoStructure(randr_screen_info);
+ }
+}
+
void KRandrSimpleAPI::freeScreenInfoStructure(ScreenInfo* screen_info) {
int i;
@@ -946,6 +993,29 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
}
}
+ // Get DPMS information
+ if (screendata->has_dpms) {
+ CARD16 dpms_standby_delay;
+ CARD16 dpms_suspend_delay;
+ CARD16 dpms_off_delay;
+ screendata->has_dpms = DPMSGetTimeouts(randr_display, &dpms_standby_delay, &dpms_suspend_delay, &dpms_off_delay);
+ screendata->dpms_standby_delay = dpms_standby_delay;
+ screendata->dpms_suspend_delay = dpms_suspend_delay;
+ screendata->dpms_off_delay = dpms_off_delay;
+ if (screendata->has_dpms) {
+ CARD16 power_level;
+ BOOL enable_dpms;
+ screendata->has_dpms = DPMSInfo(randr_display, &power_level, &enable_dpms);
+ screendata->enable_dpms = enable_dpms;
+ }
+ }
+ if (!screendata->has_dpms) {
+ screendata->enable_dpms = false;
+ screendata->dpms_standby_delay = 0;
+ screendata->dpms_suspend_delay = 0;
+ screendata->dpms_off_delay = 0;
+ }
+
if (cur_screen) {
screendata->screen_connected = true;
for (int j = 0; j < cur_screen->numSizes(); j++) {
diff --git a/krandr/libkrandr.h b/krandr/libkrandr.h
index 6ef7a4b8d..f2a60340a 100644
--- a/krandr/libkrandr.h
+++ b/krandr/libkrandr.h
@@ -202,6 +202,11 @@ class KRANDR_EXPORT KRandrSimpleAPI : public RandRDisplay
void applySystemwideDisplayGamma(TQPtrList<SingleScreenData> screenInfoArray);
/**
+ * Applies the DPMS settings contained within the systemwide display configuration screenInfoArray to the hardware
+ */
+ void applySystemwideDisplayDPMS(TQPtrList<SingleScreenData> screenInfoArray);
+
+ /**
* Destroys a screen information object
*/
void destroyScreenInformationObject(TQPtrList<SingleScreenData> screenInfoArray);
diff --git a/krandr/randr.h b/krandr/randr.h
index 9faf9b366..5e77016f2 100644
--- a/krandr/randr.h
+++ b/krandr/randr.h
@@ -59,6 +59,12 @@ struct SingleScreenData {
int absolute_y_position;
int current_x_pixel_count;
int current_y_pixel_count;
+
+ bool has_dpms;
+ bool enable_dpms;
+ unsigned int dpms_standby_delay;
+ unsigned int dpms_suspend_delay;
+ unsigned int dpms_off_delay;
};
class RandRScreen : public TQObject