Enhance libkrandr further

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1249200 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent af3a602ab3
commit 46a29a2798

@ -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);

@ -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<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
*/

@ -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) {

Loading…
Cancel
Save