From 46a29a2798e273aeed727eaa0b1dfa48e21436a7 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 24 Aug 2011 03:09:50 +0000 Subject: Enhance libkrandr further git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1249200 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- krandr/libkrandr.cc | 45 +++++++++++++++++++++++++++++++++++++++++---- krandr/libkrandr.h | 8 +++++++- krandr/randr.cpp | 1 - 3 files changed, 48 insertions(+), 6 deletions(-) (limited to 'krandr') 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 screenInfoArray; screenInfoArray = loadSystemwideDisplayConfiguration(profilename, kde_confdir); - applySystemwideDisplayConfiguration(screenInfoArray, FALSE); + if (screenInfoArray.count() > 0) { + applySystemwideDisplayConfiguration(screenInfoArray, FALSE); + } + ret = primaryScreenOffsetFromTLC(screenInfoArray); destroyScreenInformationObject(screenInfoArray); } + + return ret; } TQPtrList KRandrSimpleAPI::loadSystemwideDisplayConfiguration(TQString profilename, TQString kde_confdir) { @@ -460,7 +467,7 @@ TQPtrList KRandrSimpleAPI::loadSystemwideDisplayConfiguration( KSimpleConfig* display_config = new KSimpleConfig( filename ); - TQStringList grouplist; + TQStringList grouplist = display_config->groupList(); SingleScreenData *screendata; TQPtrList 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 screenInfoArray, bool test) { int i; int j; @@ -773,6 +782,28 @@ void KRandrSimpleAPI::ensureMonitorDataConsistency(TQPtrList s } } +TQPoint KRandrSimpleAPI::primaryScreenOffsetFromTLC(TQPtrList screenInfoArray) { + int i; + SingleScreenData *screendata; + int numberOfScreens = screenInfoArray.count(); + + int primary_offset_x = 0; + int primary_offset_y = 0; + for (i=0;iabsolute_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 KRandrSimpleAPI::readCurrentDisplayConfiguration() { // Discover display information int i; @@ -833,7 +864,13 @@ TQPtrList 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 @@ -194,6 +195,11 @@ class KRANDR_EXPORT KRandrSimpleAPI : public RandRDisplay */ void destroyScreenInformationObject(TQPtrList screenInfoArray); + /** + * Returns the offset of the primary screen's Top Left Corner + */ + TQPoint primaryScreenOffsetFromTLC(TQPtrList screenInfoArray); + /** * Ensures that the data contained within screenInfoArray is self consistent */ 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) { -- cgit v1.2.1