summaryrefslogtreecommitdiffstats
path: root/krandr
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-24 03:09:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-24 03:09:50 +0000
commit46a29a2798e273aeed727eaa0b1dfa48e21436a7 (patch)
treecdd95bc965f4a6977c48c111feb9084f6f52e4ff /krandr
parentaf3a602ab34a4d1c0d146f6fe4696b1acdbd9f0d (diff)
downloadtdelibs-46a29a2798e273aeed727eaa0b1dfa48e21436a7.tar.gz
tdelibs-46a29a2798e273aeed727eaa0b1dfa48e21436a7.zip
Enhance libkrandr further
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1249200 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krandr')
-rw-r--r--krandr/libkrandr.cc45
-rw-r--r--krandr/libkrandr.h8
-rw-r--r--krandr/randr.cpp1
3 files changed, 48 insertions, 6 deletions
diff --git a/krandr/libkrandr.cc b/krandr/libkrandr.cc
index 63ac06e62..cf4aa124d 100644
--- a/krandr/libkrandr.cc
+++ b/krandr/libkrandr.cc
@@ -433,7 +433,9 @@ void KRandrSimpleAPI::saveSystemwideDisplayConfiguration(bool enable, TQString p
delete display_config;
}
-void KRandrSimpleAPI::applySystemwideDisplayConfiguration(TQString profilename, TQString kde_confdir) {
+TQPoint KRandrSimpleAPI::applySystemwideDisplayConfiguration(TQString profilename, TQString kde_confdir) {
+ TQPoint ret;
+
TQString filename = "displayglobals";
filename.prepend(kde_confdir.append("/"));
KSimpleConfig* display_config = new KSimpleConfig( filename );
@@ -444,9 +446,14 @@ void KRandrSimpleAPI::applySystemwideDisplayConfiguration(TQString profilename,
if (enabled) {
TQPtrList<SingleScreenData> screenInfoArray;
screenInfoArray = loadSystemwideDisplayConfiguration(profilename, kde_confdir);
- applySystemwideDisplayConfiguration(screenInfoArray, FALSE);
+ if (screenInfoArray.count() > 0) {
+ applySystemwideDisplayConfiguration(screenInfoArray, FALSE);
+ }
+ ret = primaryScreenOffsetFromTLC(screenInfoArray);
destroyScreenInformationObject(screenInfoArray);
}
+
+ return ret;
}
TQPtrList<SingleScreenData> KRandrSimpleAPI::loadSystemwideDisplayConfiguration(TQString profilename, TQString kde_confdir) {
@@ -460,7 +467,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::loadSystemwideDisplayConfiguration(
KSimpleConfig* display_config = new KSimpleConfig( filename );
- TQStringList grouplist;
+ TQStringList grouplist = display_config->groupList();
SingleScreenData *screendata;
TQPtrList<SingleScreenData> screenInfoArray;
for ( TQStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) {
@@ -522,6 +529,8 @@ int KRandrSimpleAPI::getHardwareRotationFlags(SingleScreenData* screendata) {
return rotationFlags;
}
+#define USE_XRANDR_PROGRAM
+
bool KRandrSimpleAPI::applySystemwideDisplayConfiguration(TQPtrList<SingleScreenData> screenInfoArray, bool test) {
int i;
int j;
@@ -773,6 +782,28 @@ void KRandrSimpleAPI::ensureMonitorDataConsistency(TQPtrList<SingleScreenData> s
}
}
+TQPoint KRandrSimpleAPI::primaryScreenOffsetFromTLC(TQPtrList<SingleScreenData> screenInfoArray) {
+ int i;
+ SingleScreenData *screendata;
+ int numberOfScreens = screenInfoArray.count();
+
+ int primary_offset_x = 0;
+ int primary_offset_y = 0;
+ for (i=0;i<numberOfScreens;i++) {
+ screendata = screenInfoArray.at(i);
+ if (screendata->absolute_x_position < primary_offset_x) {
+ primary_offset_x = screendata->absolute_x_position;
+ }
+ if (screendata->absolute_y_position < primary_offset_y) {
+ primary_offset_y = screendata->absolute_y_position;
+ }
+ }
+ primary_offset_x = primary_offset_x * (-1);
+ primary_offset_y = primary_offset_y * (-1);
+
+ return TQPoint(primary_offset_x, primary_offset_y);
+}
+
TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
// Discover display information
int i;
@@ -833,7 +864,13 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
for (int j = 0; j < cur_screen->numSizes(); j++) {
screendata->resolutions.append(i18n("%1 x %2").tqarg(cur_screen->pixelSize(j).width()).tqarg(cur_screen->pixelSize(j).height()));
}
- screendata->current_resolution_index = cur_screen->proposedSize();
+ screendata->current_resolution_index = 0;
+ if (current_crtc) {
+ screendata->current_resolution_index = screendata->resolutions.findIndex(i18n("%1 x %2").tqarg(current_crtc->info->width).tqarg(current_crtc->info->height));
+ }
+ if (screendata->current_resolution_index < 0) {
+ screendata->current_resolution_index = cur_screen->proposedSize();
+ }
// Get refresh rates
TQStringList rr = cur_screen->refreshRates(screendata->current_resolution_index);
diff --git a/krandr/libkrandr.h b/krandr/libkrandr.h
index 352d821c0..a56f46daa 100644
--- a/krandr/libkrandr.h
+++ b/krandr/libkrandr.h
@@ -179,8 +179,9 @@ class KRANDR_EXPORT KRandrSimpleAPI : public RandRDisplay
/**
* Applies the systemwide display configuration screenInfoArray from the specified profile
* If profilename is empty, the default profile is utilized
+ * Returns the offset of the primary screen's top left corner
*/
- void applySystemwideDisplayConfiguration(TQString profilename, TQString kde_confdir);
+ TQPoint applySystemwideDisplayConfiguration(TQString profilename, TQString kde_confdir);
/**
* Applies the systemwide display configuration screenInfoArray to the hardware
@@ -195,6 +196,11 @@ class KRANDR_EXPORT KRandrSimpleAPI : public RandRDisplay
void destroyScreenInformationObject(TQPtrList<SingleScreenData> screenInfoArray);
/**
+ * Returns the offset of the primary screen's Top Left Corner
+ */
+ TQPoint primaryScreenOffsetFromTLC(TQPtrList<SingleScreenData> screenInfoArray);
+
+ /**
* Ensures that the data contained within screenInfoArray is self consistent
*/
void ensureMonitorDataConsistency(TQPtrList<SingleScreenData> screenInfoArray);
diff --git a/krandr/randr.cpp b/krandr/randr.cpp
index 2e3a30eee..45f89dc08 100644
--- a/krandr/randr.cpp
+++ b/krandr/randr.cpp
@@ -73,7 +73,6 @@ void RandRScreen::loadSettings()
XRRFreeScreenConfigInfo(d->config);
d->config = XRRGetScreenInfo(qt_xdisplay(), RootWindow(qt_xdisplay(), m_screen));
- Q_ASSERT(d->config);
Rotation rotation;
if (d->config) {