summaryrefslogtreecommitdiffstats
path: root/tderandr
diff options
context:
space:
mode:
Diffstat (limited to 'tderandr')
-rw-r--r--tderandr/CMakeLists.txt2
-rw-r--r--tderandr/Mainpage.dox1
-rw-r--r--tderandr/Makefile.am2
-rw-r--r--tderandr/ktimerdialog.cpp6
-rw-r--r--tderandr/ktimerdialog.h2
-rw-r--r--tderandr/libtderandr.cpp (renamed from tderandr/libtderandr.cc)133
-rw-r--r--tderandr/libtderandr.h9
-rw-r--r--tderandr/randr.cpp150
-rw-r--r--tderandr/randr.h11
9 files changed, 159 insertions, 157 deletions
diff --git a/tderandr/CMakeLists.txt b/tderandr/CMakeLists.txt
index e52da4c17..fd269a65c 100644
--- a/tderandr/CMakeLists.txt
+++ b/tderandr/CMakeLists.txt
@@ -37,7 +37,7 @@ install( FILES
set( target tderandr )
set( ${target}_SRCS
- randr.cpp lowlevel_randr.c ktimerdialog.cpp libtderandr.cc
+ randr.cpp lowlevel_randr.c ktimerdialog.cpp libtderandr.cpp
)
tde_add_library( ${target} SHARED AUTOMOC
diff --git a/tderandr/Mainpage.dox b/tderandr/Mainpage.dox
index c173d52aa..4d4979894 100644
--- a/tderandr/Mainpage.dox
+++ b/tderandr/Mainpage.dox
@@ -15,4 +15,3 @@ Timothy Pearson \<kb9vqf@pearsoncomputing.net\>
// DOXYGEN_REFERENCES = tdecore tdeui
// DOXYGEN_SET_PROJECT_NAME = KRandr
-// vim:ts=4:sw=4:expandtab:filetype=doxygen
diff --git a/tderandr/Makefile.am b/tderandr/Makefile.am
index 9a8e1cf37..433a30c57 100644
--- a/tderandr/Makefile.am
+++ b/tderandr/Makefile.am
@@ -9,7 +9,7 @@ libtderandrincludedir = $(includedir)/libtderandr
libtderandrinclude_HEADERS = randr.h lowlevel_randr.h ktimerdialog.h libtderandr.h
lib_LTLIBRARIES = libtderandr.la
-libtderandr_la_SOURCES = randr.cpp lowlevel_randr.c ktimerdialog.cpp libtderandr.cc
+libtderandr_la_SOURCES = randr.cpp lowlevel_randr.c ktimerdialog.cpp libtderandr.cpp
METASOURCES = AUTO
libtderandr_la_LDFLAGS = $(KDE_MT_LDFLAGS) -version-info 0:95 -no-undefined
diff --git a/tderandr/ktimerdialog.cpp b/tderandr/ktimerdialog.cpp
index eba497372..766d4ae50 100644
--- a/tderandr/ktimerdialog.cpp
+++ b/tderandr/ktimerdialog.cpp
@@ -56,8 +56,8 @@ KTimerDialog::KTimerDialog( int msec, TimerStyle style, TQWidget *parent,
if ( buttonMask & Cancel )
buttonOnTimeout = Cancel;
- connect( totalTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( slotInternalTimeout() ) );
- connect( updateTimer, TQT_SIGNAL( timeout() ), TQT_SLOT( slotUpdateTime() ) );
+ connect( totalTimer, TQ_SIGNAL( timeout() ), TQ_SLOT( slotInternalTimeout() ) );
+ connect( updateTimer, TQ_SIGNAL( timeout() ), TQ_SLOT( slotUpdateTime() ) );
// create the widgets
mainWidget = new TQVBox( this, "mainWidget" );
@@ -98,7 +98,7 @@ void KTimerDialog::setMainWidget( TQWidget *widget )
if ( widget->parentWidget() != mainWidget ) {
widget->reparent( newWidget, 0, TQPoint(0,0) );
} else {
- newWidget->insertChild( TQT_TQOBJECT(widget) );
+ newWidget->insertChild( widget );
}
timerWidget->reparent( newWidget, 0, TQPoint(0, 0) );
diff --git a/tderandr/ktimerdialog.h b/tderandr/ktimerdialog.h
index 965a72393..0d844a27f 100644
--- a/tderandr/ktimerdialog.h
+++ b/tderandr/ktimerdialog.h
@@ -44,7 +44,7 @@ class TQLabel;
*/
class KTimerDialog : public KDialogBase
{
- Q_OBJECT
+ TQ_OBJECT
public:
diff --git a/tderandr/libtderandr.cc b/tderandr/libtderandr.cpp
index eb7e96f9a..94828e434 100644
--- a/tderandr/libtderandr.cc
+++ b/tderandr/libtderandr.cpp
@@ -1,4 +1,4 @@
-/* libtderandr.cc - class KRandr that makes it easy to use XRandr in KDE
+/* libtderandr.cpp - class KRandr that makes it easy to use XRandr in KDE
This file is part of KRandr 0.9.5
Copyright (C) 2010 Timothy Pearson
LibKRandr's homepage : http://www.trinitydesktop.org
@@ -31,6 +31,8 @@
#include <tdemessagebox.h>
#include <tdeapplication.h>
+#include <kdebug.h>
+
#include <stdlib.h>
#include <unistd.h>
#include <cmath>
@@ -78,14 +80,14 @@ TQString capitalizeString(TQString in) {
}
TQString KRandrSimpleAPI::getIccFileName(TQString profileName, TQString screenName, TQString kde_confdir) {
- KSimpleConfig *t_config = NULL;
- KSimpleConfig *t_systemconfig = NULL;
+ TDESimpleConfig *t_config = NULL;
+ TDESimpleConfig *t_systemconfig = NULL;
int t_numberOfProfiles;
TQStringList t_cfgProfiles;
TQString retval;
if ((profileName != NULL) && (profileName != "")) {
- t_config = new KSimpleConfig( TQString::fromLatin1( "kiccconfigrc" ));
+ t_config = new TDESimpleConfig( TQString::fromLatin1( "kiccconfigrc" ));
t_config->setGroup(NULL);
if (t_config->readBoolEntry("EnableICC", false) == true) {
t_config->setGroup(profileName);
@@ -97,7 +99,7 @@ TQString KRandrSimpleAPI::getIccFileName(TQString profileName, TQString screenNa
delete t_config;
}
else {
- t_systemconfig = new KSimpleConfig( kde_confdir + TQString("/kicc/kiccconfigrc") );
+ t_systemconfig = new TDESimpleConfig( kde_confdir + TQString("/kicc/kiccconfigrc") );
t_systemconfig->setGroup(NULL);
if (t_systemconfig->readBoolEntry("EnableICC", false) == true) {
retval = t_systemconfig->readEntry("ICCFile");
@@ -264,12 +266,12 @@ TQString KRandrSimpleAPI::applyIccConfiguration(TQString profileName, TQString k
Display *randr_display;
ScreenInfo *randr_screen_info;
XRROutputInfo *output_info;
- KSimpleConfig *t_config;
+ TDESimpleConfig *t_config;
int screenNumber = 0;
TQString errorstr = "";
- t_config = new KSimpleConfig( TQString::fromLatin1( "kiccconfigrc" ));
+ t_config = new TDESimpleConfig( TQString::fromLatin1( "kiccconfigrc" ));
// Find all screens
if (isValid() == true) {
@@ -371,9 +373,9 @@ TQByteArray KRandrSimpleAPI::getEDID(int card, TQString displayname) {
TQString KRandrSimpleAPI::getCurrentProfile () {
TQString profileName;
- KSimpleConfig *t_config;
+ TDESimpleConfig *t_config;
- t_config = new KSimpleConfig( TQString::fromLatin1( "kiccconfigrc" ));
+ t_config = new TDESimpleConfig( TQString::fromLatin1( "kiccconfigrc" ));
profileName = t_config->readEntry("CurrentProfile");
delete t_config;
return profileName;
@@ -457,7 +459,7 @@ void KRandrSimpleAPI::saveDisplayConfiguration(bool enable, bool applyonstart, T
filename = "displayglobals";
filename.prepend(kde_confdir.append("/"));
- KSimpleConfig* display_config = new KSimpleConfig( filename );
+ TDESimpleConfig* display_config = new TDESimpleConfig( filename );
display_config->setGroup("General");
display_config->writeEntry("EnableDisplayControl", enable);
display_config->writeEntry("ApplySettingsOnStart", applyonstart);
@@ -471,7 +473,7 @@ void KRandrSimpleAPI::saveDisplayConfiguration(bool enable, bool applyonstart, T
}
filename.prepend(kde_confdir.append("/displayconfig/"));
- display_config = new KSimpleConfig( filename );
+ display_config = new TDESimpleConfig( filename );
i=0;
SingleScreenData *screendata;
@@ -537,7 +539,7 @@ TQPoint KRandrSimpleAPI::applyDisplayConfiguration(TQString profilename, TQStrin
TQPtrList<SingleScreenData> screenInfoArray;
screenInfoArray = loadDisplayConfiguration(profilename, kde_confdir);
if (screenInfoArray.count() > 0) {
- applyDisplayConfiguration(screenInfoArray, FALSE, kde_confdir);
+ applyDisplayConfiguration(screenInfoArray, false, kde_confdir);
}
destroyScreenInformationObject(screenInfoArray);
screenInfoArray = readCurrentDisplayConfiguration();
@@ -559,7 +561,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::loadDisplayConfiguration(TQString p
}
filename.prepend(kde_confdir.append("/displayconfig/"));
- KSimpleConfig* display_config = new KSimpleConfig( filename );
+ TDESimpleConfig* display_config = new TDESimpleConfig( filename );
TQStringList grouplist = display_config->groupList();
SingleScreenData *screendata;
@@ -610,17 +612,16 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::loadDisplayConfiguration(TQString p
int KRandrSimpleAPI::getHardwareRotationFlags(SingleScreenData* screendata) {
int rotationFlags = 0;
- TQString rotationDesired = *screendata->rotations.at(screendata->current_rotation_index);
- if (rotationDesired == ROTATION_0_DEGREES_STRING) {
+ if (screendata->current_rotation_index == ROTATION_0_DEGREES_INDEX) {
rotationFlags = rotationFlags | RandRScreen::Rotate0;
}
- else if (rotationDesired == ROTATION_90_DEGREES_STRING) {
+ else if (screendata->current_rotation_index == ROTATION_90_DEGREES_INDEX) {
rotationFlags = rotationFlags | RandRScreen::Rotate90;
}
- else if (rotationDesired == ROTATION_180_DEGREES_STRING) {
+ else if (screendata->current_rotation_index == ROTATION_180_DEGREES_INDEX) {
rotationFlags = rotationFlags | RandRScreen::Rotate180;
}
- else if (rotationDesired == ROTATION_270_DEGREES_STRING) {
+ else if (screendata->current_rotation_index == ROTATION_270_DEGREES_INDEX) {
rotationFlags = rotationFlags | RandRScreen::Rotate270;
}
if (screendata->has_x_flip) {
@@ -645,11 +646,11 @@ bool KRandrSimpleAPI::applyDisplayConfiguration(TQPtrList<SingleScreenData> scre
SingleScreenData *screendata;
TQPtrList<SingleScreenData> oldconfig;
- if (test == TRUE) {
+ if (test) {
oldconfig = readCurrentDisplayConfiguration();
}
- if (isValid() == true) {
+ if (isValid()) {
#ifdef USE_XRANDR_PROGRAM
// Assemble the command string for xrandr
TQString command;
@@ -667,10 +668,10 @@ bool KRandrSimpleAPI::applyDisplayConfiguration(TQPtrList<SingleScreenData> scre
command.append(TQString(" --pos %1x%2").arg(screendata->absolute_x_position).arg(screendata->absolute_y_position));
command.append(TQString(" --refresh %1").arg(atoi((*screendata->refresh_rates.at(screendata->current_refresh_rate_index)).ascii())));
command.append(TQString(" --gamma %1:%2:%3").arg(screendata->gamma_red).arg(screendata->gamma_green).arg(screendata->gamma_blue));
- if (screendata->current_rotation_index == 0) command.append(" --rotate ").append("normal");
- if (screendata->current_rotation_index == 1) command.append(" --rotate ").append("left");
- if (screendata->current_rotation_index == 2) command.append(" --rotate ").append("inverted");
- if (screendata->current_rotation_index == 3) command.append(" --rotate ").append("right");
+ if (screendata->current_rotation_index == ROTATION_0_DEGREES_INDEX) command.append(" --rotate ").append("normal");
+ if (screendata->current_rotation_index == ROTATION_90_DEGREES_INDEX) command.append(" --rotate ").append("left");
+ if (screendata->current_rotation_index == ROTATION_180_DEGREES_INDEX) command.append(" --rotate ").append("inverted");
+ if (screendata->current_rotation_index == ROTATION_270_DEGREES_INDEX) command.append(" --rotate ").append("right");
if ((screendata->has_x_flip == 0) && (screendata->has_y_flip == 0)) command.append(" --reflect ").append("normal");
if ((screendata->has_x_flip == 1) && (screendata->has_y_flip == 0)) command.append(" --reflect ").append("x");
if ((screendata->has_x_flip == 0) && (screendata->has_y_flip == 1)) command.append(" --reflect ").append("y");
@@ -702,7 +703,7 @@ bool KRandrSimpleAPI::applyDisplayConfiguration(TQPtrList<SingleScreenData> scre
if(xrandr_command_output.startsWith("xrandr: Failed to get size of gamma for output")) {
KMessageBox::sorry(0, xrandr_command_output, i18n("Setting gamma failed."));
} else if (xrandr_command_output != "") {
- applyDisplayConfiguration(oldconfig, FALSE, kde_confdir);
+ applyDisplayConfiguration(oldconfig, false, kde_confdir);
accepted = false;
destroyScreenInformationObject(oldconfig);
KMessageBox::sorry(0, xrandr_command_output, i18n("XRandR encountered a problem"));
@@ -803,10 +804,10 @@ bool KRandrSimpleAPI::applyDisplayConfiguration(TQPtrList<SingleScreenData> scre
applySystemWideIccConfiguration(kde_confdir);
applyIccConfiguration(current_icc_profile, kde_confdir);
- if (test == TRUE) {
+ if (test) {
int ret = showTestConfigurationDialog();
if (!ret) {
- applyDisplayConfiguration(oldconfig, FALSE, kde_confdir);
+ applyDisplayConfiguration(oldconfig, false, kde_confdir);
accepted = false;
}
destroyScreenInformationObject(oldconfig);
@@ -961,7 +962,7 @@ HotPlugRulesList KRandrSimpleAPI::getHotplugRules(TQString kde_confdir) {
filename = "displayglobals";
filename.prepend(kde_confdir.append("/"));
- KSimpleConfig* display_config = new KSimpleConfig( filename );
+ TDESimpleConfig* display_config = new TDESimpleConfig( filename );
TQStringList grouplist = display_config->groupList();
for ( TQStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) {
@@ -986,7 +987,7 @@ void KRandrSimpleAPI::saveHotplugRules(HotPlugRulesList rules, TQString kde_conf
filename = "displayglobals";
filename.prepend(kde_confdir.append("/"));
- KSimpleConfig* display_config = new KSimpleConfig( filename );
+ TDESimpleConfig* display_config = new TDESimpleConfig( filename );
TQStringList grouplist = display_config->groupList();
for ( TQStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) {
if (!(*it).startsWith("Hotplug-Rule")) {
@@ -1010,7 +1011,7 @@ void KRandrSimpleAPI::saveHotplugRules(HotPlugRulesList rules, TQString kde_conf
bool KRandrSimpleAPI::getDisplayConfigurationEnabled(TQString kde_confdir) {
TQString filename = "displayglobals";
filename.prepend(kde_confdir.append("/"));
- KSimpleConfig* display_config = new KSimpleConfig( filename );
+ TDESimpleConfig* display_config = new TDESimpleConfig( filename );
display_config->setGroup("General");
bool enabled = display_config->readBoolEntry("EnableDisplayControl", false);
delete display_config;
@@ -1021,7 +1022,7 @@ bool KRandrSimpleAPI::getDisplayConfigurationEnabled(TQString kde_confdir) {
bool KRandrSimpleAPI::getDisplayConfigurationStartupAutoApplyEnabled(TQString kde_confdir) {
TQString filename = "displayglobals";
filename.prepend(kde_confdir.append("/"));
- KSimpleConfig* display_config = new KSimpleConfig( filename );
+ TDESimpleConfig* display_config = new TDESimpleConfig( filename );
display_config->setGroup("General");
bool applyonstart = display_config->readBoolEntry("ApplySettingsOnStart", false);
delete display_config;
@@ -1032,7 +1033,7 @@ bool KRandrSimpleAPI::getDisplayConfigurationStartupAutoApplyEnabled(TQString kd
TQString KRandrSimpleAPI::getDisplayConfigurationStartupAutoApplyName(TQString kde_confdir) {
TQString filename = "displayglobals";
filename.prepend(kde_confdir.append("/"));
- KSimpleConfig* display_config = new KSimpleConfig( filename );
+ TDESimpleConfig* display_config = new TDESimpleConfig( filename );
display_config->setGroup("General");
TQString profilename = display_config->readEntry("StartupProfileName", "");
delete display_config;
@@ -1096,7 +1097,6 @@ void KRandrSimpleAPI::applyHotplugRules(TQString kde_confdir) {
}
void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoArray) {
- int i;
Display *randr_display;
XRROutputInfo *output_info;
ScreenInfo *randr_screen_info;
@@ -1107,37 +1107,35 @@ void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoAr
if (isValid() == true) {
randr_display = tqt_xdisplay();
randr_screen_info = read_screen_info(randr_display);
- for (i = 0; i < screenInfoArray.count(); i++) {
+ for (int i = 0; i < screenInfoArray.count(); 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;
}
- // vvvvvvvvv This chunk of code is borrowed from xrandr vvvvvvvvvv
+ // vvvvvvvvv This chunk of code is based on code from the function set_gamma() of xrandr vvvvvvvvvv
int size = XRRGetCrtcGammaSize(randr_display, current_crtc->id);
- if (!size) {
+ if (size <= 0 || size > 65536) {
+ kdWarning() << "Gamma correction table has wrong size." << endl;
continue;
}
gamma = XRRAllocGamma(size);
if (!gamma) {
+ kdWarning() << "Gamma allocation failed." << endl;
continue;
}
- for (i = 0; i < size; i++) {
- if (screendata->gamma_red == 1.0)
- gamma->red[i] = i << 8;
- else
- gamma->red[i] = (pow((double)i/(double)(size-1), (double)screendata->gamma_red) * (double)(size-1)*256);
-
- if (screendata->gamma_green == 1.0)
- gamma->green[i] = i << 8;
- else
- gamma->green[i] = (pow((double)i/(double)(size-1), (double)screendata->gamma_green) * (double)(size-1)*256);
-
- if (screendata->gamma_blue == 1.0)
- gamma->blue[i] = i << 8;
- else
- gamma->blue[i] = (pow((double)i/(double)(size-1), (double)screendata->gamma_blue) * (double)(size-1)*256);
+ for (int j = 0; j < size; j++) {
+ if (size == 1) {
+ gamma->red[j] = 0.0;
+ gamma->green[j] = 0.0;
+ gamma->blue[j] = 0.0;
+ }
+ else {
+ gamma->red[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_red), 1.0) * 65535.0;
+ gamma->green[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_green), 1.0) * 65535.0;
+ gamma->blue[j] = fmin(pow((double)j / (double)(size - 1), screendata->gamma_blue), 1.0) * 65535.0;
+ }
}
XRRSetCrtcGamma(randr_display, current_crtc->id, gamma);
free(gamma);
@@ -1308,30 +1306,30 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
// RandRScreen::ReflectX
// RandRScreen::ReflectY
- screendata->rotations.append(i18n(ROTATION_0_DEGREES_STRING));
- screendata->rotations.append(i18n(ROTATION_90_DEGREES_STRING));
- screendata->rotations.append(i18n(ROTATION_180_DEGREES_STRING));
- screendata->rotations.append(i18n(ROTATION_270_DEGREES_STRING));
+ screendata->rotations.append(i18n("0 degrees"));
+ screendata->rotations.append(i18n("90 degrees"));
+ screendata->rotations.append(i18n("180 degrees"));
+ screendata->rotations.append(i18n("270 degrees"));
screendata->supports_transformations = (cur_screen->rotations() != RandRScreen::Rotate0);
if (screendata->supports_transformations) {
screendata->current_orientation_mask = cur_screen->proposedRotation();
switch (screendata->current_orientation_mask & RandRScreen::RotateMask) {
case RandRScreen::Rotate0:
- screendata->current_rotation_index = 0;
+ screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
break;
case RandRScreen::Rotate90:
- screendata->current_rotation_index = 1;
+ screendata->current_rotation_index = ROTATION_90_DEGREES_INDEX;
break;
case RandRScreen::Rotate180:
- screendata->current_rotation_index = 2;
+ screendata->current_rotation_index = ROTATION_180_DEGREES_INDEX;
break;
case RandRScreen::Rotate270:
- screendata->current_rotation_index = 3;
+ screendata->current_rotation_index = ROTATION_270_DEGREES_INDEX;
break;
default:
// Shouldn't hit this one
Q_ASSERT(screendata->current_orientation_mask & RandRScreen::RotateMask);
- screendata->current_rotation_index = 0;
+ screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
break;
}
screendata->has_x_flip = (screendata->current_orientation_mask & RandRScreen::ReflectX);
@@ -1340,7 +1338,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
else {
screendata->has_x_flip = false;
screendata->has_y_flip = false;
- screendata->current_rotation_index = 0;
+ screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
}
// Determine if this display is primary and/or extended
@@ -1381,8 +1379,13 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
//int slot = 127;
int slot = 7;
int size = XRRGetCrtcGammaSize(randr_display, current_crtc->id);
- if(size>0) {
- XRRCrtcGamma *gammastruct = XRRGetCrtcGamma (randr_display, current_crtc->id);
+ XRRCrtcGamma *gammastruct = XRRGetCrtcGamma (randr_display, current_crtc->id);
+ if (size == 1) {
+ screendata->gamma_red = 0.0;
+ screendata->gamma_green = 0.0;
+ screendata->gamma_blue = 0.0;
+ }
+ else if (size > 1) {
screendata->gamma_red = log(gammastruct->red[slot]/((size-1.0)*256.0))/log(slot/(size-1.0));
screendata->gamma_green = log(gammastruct->green[slot]/((size-1.0)*256.0))/log(slot/(size-1.0));
screendata->gamma_blue = log(gammastruct->blue[slot]/((size-1.0)*256.0))/log(slot/(size-1.0));
@@ -1413,7 +1416,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
screendata->gamma_green = 2.2;
screendata->gamma_blue = 2.2;
- screendata->current_rotation_index = 0;
+ screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
screendata->current_orientation_mask = 0;
screendata->has_x_flip = false;
screendata->has_y_flip = false;
@@ -1455,7 +1458,7 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
screendata->gamma_green = 2.2;
screendata->gamma_blue = 2.2;
- screendata->current_rotation_index = 0;
+ screendata->current_rotation_index = ROTATION_0_DEGREES_INDEX;
screendata->current_orientation_mask = 0;
screendata->has_x_flip = false;
screendata->has_y_flip = false;
diff --git a/tderandr/libtderandr.h b/tderandr/libtderandr.h
index 0e07ad96e..106821f85 100644
--- a/tderandr/libtderandr.h
+++ b/tderandr/libtderandr.h
@@ -32,14 +32,9 @@
#include <tqfile.h>
#include <tdeconfig.h>
-#include <ksimpleconfig.h>
+#include <tdesimpleconfig.h>
#include <tdelibs_export.h>
-#define ROTATION_0_DEGREES_STRING "0 degrees"
-#define ROTATION_90_DEGREES_STRING "90 degrees"
-#define ROTATION_180_DEGREES_STRING "180 degrees"
-#define ROTATION_270_DEGREES_STRING "270 degrees"
-
/**
* Simple API covering most of the uses of libtderandr.
*
@@ -258,7 +253,7 @@ class TDERANDR_EXPORT KRandrSimpleAPI : public RandRDisplay
* If test is true, the new configuration will be loaded for a short period of time, then reverted automatically
* Returns true if configuration was accepted; false if not
*/
- bool applyDisplayConfiguration(TQPtrList<SingleScreenData> screenInfoArray, bool test=TRUE, TQString kde_confdir="");
+ bool applyDisplayConfiguration(TQPtrList<SingleScreenData> screenInfoArray, bool test=true, TQString kde_confdir="");
/**
* Applies the gamma contained within the systemwide display configuration screenInfoArray to the hardware
diff --git a/tderandr/randr.cpp b/tderandr/randr.cpp
index c72dcd651..3dfce4589 100644
--- a/tderandr/randr.cpp
+++ b/tderandr/randr.cpp
@@ -63,7 +63,7 @@ SingleScreenData::SingleScreenData()
gamma_green = 0.0;
gamma_blue = 0.0;
- current_rotation_index = 0;
+ current_rotation_index = ROTATION_0_DEGREES_INDEX;
current_orientation_mask = 0;
has_x_flip = false;
has_y_flip = false;
@@ -102,7 +102,7 @@ public:
XRRScreenConfiguration* config;
};
-KDE_EXPORT RandRScreen::RandRScreen(int screenIndex)
+TDE_EXPORT RandRScreen::RandRScreen(int screenIndex)
: d(new RandRScreenPrivate())
, m_screen(screenIndex)
, m_shownDialog(NULL)
@@ -111,12 +111,12 @@ KDE_EXPORT RandRScreen::RandRScreen(int screenIndex)
setOriginal();
}
-KDE_EXPORT RandRScreen::~RandRScreen()
+TDE_EXPORT RandRScreen::~RandRScreen()
{
delete d;
}
-KDE_EXPORT void RandRScreen::loadSettings()
+TDE_EXPORT void RandRScreen::loadSettings()
{
if (d->config) {
XRRFreeScreenConfigInfo(d->config);
@@ -176,14 +176,14 @@ KDE_EXPORT void RandRScreen::loadSettings()
}
}
-KDE_EXPORT void RandRScreen::setOriginal()
+TDE_EXPORT void RandRScreen::setOriginal()
{
m_originalSize = m_currentSize;
m_originalRotation = m_currentRotation;
m_originalRefreshRate = m_currentRefreshRate;
}
-KDE_EXPORT bool RandRScreen::applyProposed()
+TDE_EXPORT bool RandRScreen::applyProposed()
{
//kdDebug() << k_funcinfo << " size " << (SizeID)proposedSize() << ", rotation " << proposedRotation() << ", refresh " << refreshRateIndexToHz(proposedSize(), proposedRefreshRate()) << endl;
@@ -227,7 +227,7 @@ KDE_EXPORT bool RandRScreen::applyProposed()
return false;
}
-KDE_EXPORT bool RandRScreen::applyProposedAndConfirm()
+TDE_EXPORT bool RandRScreen::applyProposedAndConfirm()
{
if (proposedChanged()) {
setOriginal();
@@ -246,7 +246,7 @@ KDE_EXPORT bool RandRScreen::applyProposedAndConfirm()
return true;
}
-KDE_EXPORT bool RandRScreen::confirm()
+TDE_EXPORT bool RandRScreen::confirm()
{
// uncomment the line below and edit out the KTimerDialog stuff to get
// a version which works on today's tdelibs (no accept dialog is presented)
@@ -254,7 +254,7 @@ KDE_EXPORT bool RandRScreen::confirm()
// FIXME remember to put the dialog on the right screen
KTimerDialog acceptDialog ( 15000, KTimerDialog::CountDown,
- TDEApplication::kApplication()->mainWidget(),
+ tdeApp->mainWidget(),
"mainKTimerDialog",
true,
i18n("Confirm Display Setting Change"),
@@ -274,25 +274,25 @@ KDE_EXPORT bool RandRScreen::confirm()
KDialog::centerOnScreen(&acceptDialog, m_screen);
m_shownDialog = &acceptDialog;
- connect( m_shownDialog, TQT_SIGNAL( destroyed()), this, TQT_SLOT( shownDialogDestroyed()));
- connect( kapp->desktop(), TQT_SIGNAL( resized(int)), this, TQT_SLOT( desktopResized()));
+ connect( m_shownDialog, TQ_SIGNAL( destroyed()), this, TQ_SLOT( shownDialogDestroyed()));
+ connect( tdeApp->desktop(), TQ_SIGNAL( resized(int)), this, TQ_SLOT( desktopResized()));
return acceptDialog.exec();
}
-KDE_EXPORT void RandRScreen::shownDialogDestroyed()
+TDE_EXPORT void RandRScreen::shownDialogDestroyed()
{
m_shownDialog = NULL;
- disconnect( kapp->desktop(), TQT_SIGNAL( resized(int)), this, TQT_SLOT( desktopResized()));
+ disconnect( tdeApp->desktop(), TQ_SIGNAL( resized(int)), this, TQ_SLOT( desktopResized()));
}
-KDE_EXPORT void RandRScreen::desktopResized()
+TDE_EXPORT void RandRScreen::desktopResized()
{
if( m_shownDialog != NULL )
KDialog::centerOnScreen(m_shownDialog, m_screen);
}
-KDE_EXPORT TQString RandRScreen::changedMessage() const
+TDE_EXPORT TQString RandRScreen::changedMessage() const
{
if (currentRefreshRate() == -1)
return i18n("New configuration:\nResolution: %1 x %2\nOrientation: %3")
@@ -307,24 +307,24 @@ KDE_EXPORT TQString RandRScreen::changedMessage() const
.arg(currentRefreshRateDescription());
}
-KDE_EXPORT bool RandRScreen::changedFromOriginal() const
+TDE_EXPORT bool RandRScreen::changedFromOriginal() const
{
return m_currentSize != m_originalSize || m_currentRotation != m_originalRotation || m_currentRefreshRate != m_originalRefreshRate;
}
-KDE_EXPORT void RandRScreen::proposeOriginal()
+TDE_EXPORT void RandRScreen::proposeOriginal()
{
m_proposedSize = m_originalSize;
m_proposedRotation = m_originalRotation;
m_proposedRefreshRate = m_originalRefreshRate;
}
-KDE_EXPORT bool RandRScreen::proposedChanged() const
+TDE_EXPORT bool RandRScreen::proposedChanged() const
{
return m_currentSize != m_proposedSize || m_currentRotation != m_proposedRotation || m_currentRefreshRate != m_proposedRefreshRate;
}
-KDE_EXPORT TQString RandRScreen::rotationName(int rotation, bool pastTense, bool capitalised)
+TDE_EXPORT TQString RandRScreen::rotationName(int rotation, bool pastTense, bool capitalised)
{
if (!pastTense)
switch (rotation) {
@@ -378,7 +378,7 @@ KDE_EXPORT TQString RandRScreen::rotationName(int rotation, bool pastTense, bool
}
}
-KDE_EXPORT TQPixmap RandRScreen::rotationIcon(int rotation) const
+TDE_EXPORT TQPixmap RandRScreen::rotationIcon(int rotation) const
{
// Adjust icons for current screen orientation
if (!(m_currentRotation & RR_Rotate_0) && rotation & (RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)) {
@@ -417,7 +417,7 @@ KDE_EXPORT TQPixmap RandRScreen::rotationIcon(int rotation) const
}
}
-KDE_EXPORT TQString RandRScreen::currentRotationDescription() const
+TDE_EXPORT TQString RandRScreen::currentRotationDescription() const
{
TQString ret = rotationName(m_currentRotation & RotateMask);
@@ -433,7 +433,7 @@ KDE_EXPORT TQString RandRScreen::currentRotationDescription() const
return ret;
}
-KDE_EXPORT int RandRScreen::rotationIndexToDegree(int rotation) const
+TDE_EXPORT int RandRScreen::rotationIndexToDegree(int rotation) const
{
switch (rotation & RotateMask) {
case RR_Rotate_90:
@@ -450,7 +450,7 @@ KDE_EXPORT int RandRScreen::rotationIndexToDegree(int rotation) const
}
}
-KDE_EXPORT int RandRScreen::rotationDegreeToIndex(int degree) const
+TDE_EXPORT int RandRScreen::rotationDegreeToIndex(int degree) const
{
switch (degree) {
case 90:
@@ -467,27 +467,27 @@ KDE_EXPORT int RandRScreen::rotationDegreeToIndex(int degree) const
}
}
-KDE_EXPORT int RandRScreen::currentPixelWidth() const
+TDE_EXPORT int RandRScreen::currentPixelWidth() const
{
return m_pixelSizes[m_currentSize].width();
}
-KDE_EXPORT int RandRScreen::currentPixelHeight() const
+TDE_EXPORT int RandRScreen::currentPixelHeight() const
{
return m_pixelSizes[m_currentSize].height();
}
-KDE_EXPORT int RandRScreen::currentMMWidth() const
+TDE_EXPORT int RandRScreen::currentMMWidth() const
{
return m_pixelSizes[m_currentSize].width();
}
-KDE_EXPORT int RandRScreen::currentMMHeight() const
+TDE_EXPORT int RandRScreen::currentMMHeight() const
{
return m_pixelSizes[m_currentSize].height();
}
-KDE_EXPORT TQStringList RandRScreen::refreshRates(int size) const
+TDE_EXPORT TQStringList RandRScreen::refreshRates(int size) const
{
int nrates;
TQStringList ret;
@@ -514,22 +514,22 @@ KDE_EXPORT TQStringList RandRScreen::refreshRates(int size) const
return ret;
}
-KDE_EXPORT TQString RandRScreen::refreshRateDirectDescription(int rate) const
+TDE_EXPORT TQString RandRScreen::refreshRateDirectDescription(int rate) const
{
return i18n("Refresh rate in Hertz (Hz)", "%1 Hz").arg(rate);
}
-KDE_EXPORT TQString RandRScreen::refreshRateIndirectDescription(int size, int index) const
+TDE_EXPORT TQString RandRScreen::refreshRateIndirectDescription(int size, int index) const
{
return i18n("Refresh rate in Hertz (Hz)", "%1 Hz").arg(refreshRateIndexToHz(size, index));
}
-KDE_EXPORT TQString RandRScreen::refreshRateDescription(int size, int index) const
+TDE_EXPORT TQString RandRScreen::refreshRateDescription(int size, int index) const
{
return refreshRates(size)[index];
}
-KDE_EXPORT bool RandRScreen::proposeRefreshRate(int index)
+TDE_EXPORT bool RandRScreen::proposeRefreshRate(int index)
{
if (index >= 0 && (int)refreshRates(proposedSize()).count() > index) {
m_proposedRefreshRate = index;
@@ -539,22 +539,22 @@ KDE_EXPORT bool RandRScreen::proposeRefreshRate(int index)
return false;
}
-KDE_EXPORT int RandRScreen::currentRefreshRate() const
+TDE_EXPORT int RandRScreen::currentRefreshRate() const
{
return m_currentRefreshRate;
}
-KDE_EXPORT TQString RandRScreen::currentRefreshRateDescription() const
+TDE_EXPORT TQString RandRScreen::currentRefreshRateDescription() const
{
return refreshRateIndirectDescription(m_currentSize, m_currentRefreshRate);
}
-KDE_EXPORT int RandRScreen::proposedRefreshRate() const
+TDE_EXPORT int RandRScreen::proposedRefreshRate() const
{
return m_proposedRefreshRate;
}
-KDE_EXPORT int RandRScreen::refreshRateHzToIndex(int size, int hz) const
+TDE_EXPORT int RandRScreen::refreshRateHzToIndex(int size, int hz) const
{
int nrates;
short* rates = XRRRates(tqt_xdisplay(), m_screen, (SizeID)size, &nrates);
@@ -570,7 +570,7 @@ KDE_EXPORT int RandRScreen::refreshRateHzToIndex(int size, int hz) const
return -1;
}
-KDE_EXPORT int RandRScreen::refreshRateIndexToHz(int size, int index) const
+TDE_EXPORT int RandRScreen::refreshRateIndexToHz(int size, int index) const
{
int nrates;
short* rates = XRRRates(tqt_xdisplay(), m_screen, (SizeID)size, &nrates);
@@ -585,22 +585,22 @@ KDE_EXPORT int RandRScreen::refreshRateIndexToHz(int size, int index) const
return rates[index];
}
-KDE_EXPORT int RandRScreen::numSizes() const
+TDE_EXPORT int RandRScreen::numSizes() const
{
return m_pixelSizes.count();
}
-KDE_EXPORT const TQSize& RandRScreen::pixelSize(int index) const
+TDE_EXPORT const TQSize& RandRScreen::pixelSize(int index) const
{
return m_pixelSizes[index];
}
-KDE_EXPORT const TQSize& RandRScreen::mmSize(int index) const
+TDE_EXPORT const TQSize& RandRScreen::mmSize(int index) const
{
return m_mmSizes[index];
}
-KDE_EXPORT int RandRScreen::sizeIndex(TQSize pixelSize) const
+TDE_EXPORT int RandRScreen::sizeIndex(TQSize pixelSize) const
{
for (uint i = 0; i < m_pixelSizes.count(); i++)
if (m_pixelSizes[i] == pixelSize)
@@ -609,37 +609,37 @@ KDE_EXPORT int RandRScreen::sizeIndex(TQSize pixelSize) const
return -1;
}
-KDE_EXPORT int RandRScreen::rotations() const
+TDE_EXPORT int RandRScreen::rotations() const
{
return m_rotations;
}
-KDE_EXPORT int RandRScreen::currentRotation() const
+TDE_EXPORT int RandRScreen::currentRotation() const
{
return m_currentRotation;
}
-KDE_EXPORT int RandRScreen::currentSize() const
+TDE_EXPORT int RandRScreen::currentSize() const
{
return m_currentSize;
}
-KDE_EXPORT int RandRScreen::proposedRotation() const
+TDE_EXPORT int RandRScreen::proposedRotation() const
{
return m_proposedRotation;
}
-KDE_EXPORT void RandRScreen::proposeRotation(int newRotation)
+TDE_EXPORT void RandRScreen::proposeRotation(int newRotation)
{
m_proposedRotation = newRotation & OrientationMask;
}
-KDE_EXPORT int RandRScreen::proposedSize() const
+TDE_EXPORT int RandRScreen::proposedSize() const
{
return m_proposedSize;
}
-KDE_EXPORT bool RandRScreen::proposeSize(int newSize)
+TDE_EXPORT bool RandRScreen::proposeSize(int newSize)
{
if ((int)m_pixelSizes.count() > newSize) {
m_proposedSize = newSize;
@@ -649,7 +649,7 @@ KDE_EXPORT bool RandRScreen::proposeSize(int newSize)
return false;
}
-KDE_EXPORT void RandRScreen::load(TDEConfig& config)
+TDE_EXPORT void RandRScreen::load(TDEConfig& config)
{
config.setGroup(TQString("Screen%1").arg(m_screen));
@@ -659,7 +659,7 @@ KDE_EXPORT void RandRScreen::load(TDEConfig& config)
proposeRotation(rotationDegreeToIndex(config.readNumEntry("rotation", 0)) + (config.readBoolEntry("reflectX") ? ReflectX : 0) + (config.readBoolEntry("reflectY") ? ReflectY : 0));
}
-KDE_EXPORT void RandRScreen::save(TDEConfig& config) const
+TDE_EXPORT void RandRScreen::save(TDEConfig& config) const
{
config.setGroup(TQString("Screen%1").arg(m_screen));
config.writeEntry("width", currentPixelWidth());
@@ -670,7 +670,7 @@ KDE_EXPORT void RandRScreen::save(TDEConfig& config) const
config.writeEntry("reflectY", (bool)(currentRotation() & ReflectMask) == ReflectY);
}
-KDE_EXPORT RandRDisplay::RandRDisplay()
+TDE_EXPORT RandRDisplay::RandRDisplay()
: m_valid(true)
{
// Check extension
@@ -713,76 +713,76 @@ KDE_EXPORT RandRDisplay::RandRDisplay()
setCurrentScreen(TQApplication::desktop()->primaryScreen());
}
-KDE_EXPORT bool RandRDisplay::isValid() const
+TDE_EXPORT bool RandRDisplay::isValid() const
{
return m_valid;
}
-KDE_EXPORT const TQString& RandRDisplay::errorCode() const
+TDE_EXPORT const TQString& RandRDisplay::errorCode() const
{
return m_errorCode;
}
-KDE_EXPORT int RandRDisplay::eventBase() const
+TDE_EXPORT int RandRDisplay::eventBase() const
{
return m_eventBase;
}
-KDE_EXPORT int RandRDisplay::screenChangeNotifyEvent() const
+TDE_EXPORT int RandRDisplay::screenChangeNotifyEvent() const
{
return m_eventBase + RRScreenChangeNotify;
}
-KDE_EXPORT int RandRDisplay::errorBase() const
+TDE_EXPORT int RandRDisplay::errorBase() const
{
return m_errorBase;
}
-KDE_EXPORT const TQString& RandRDisplay::version() const
+TDE_EXPORT const TQString& RandRDisplay::version() const
{
return m_version;
}
-KDE_EXPORT void RandRDisplay::setCurrentScreen(int index)
+TDE_EXPORT void RandRDisplay::setCurrentScreen(int index)
{
m_currentScreenIndex = index;
m_currentScreen = m_screens.at(m_currentScreenIndex);
Q_ASSERT(m_currentScreen);
}
-KDE_EXPORT int RandRDisplay::screenIndexOfWidget(TQWidget* widget)
+TDE_EXPORT int RandRDisplay::screenIndexOfWidget(TQWidget* widget)
{
int ret = TQApplication::desktop()->screenNumber(widget);
return ret != -1 ? ret : TQApplication::desktop()->primaryScreen();
}
-KDE_EXPORT int RandRDisplay::currentScreenIndex() const
+TDE_EXPORT int RandRDisplay::currentScreenIndex() const
{
return m_currentScreenIndex;
}
-KDE_EXPORT void RandRDisplay::refresh()
+TDE_EXPORT void RandRDisplay::refresh()
{
for (RandRScreen* s = m_screens.first(); s; s = m_screens.next())
s->loadSettings();
}
-KDE_EXPORT int RandRDisplay::numScreens() const
+TDE_EXPORT int RandRDisplay::numScreens() const
{
return m_numScreens;
}
-KDE_EXPORT RandRScreen* RandRDisplay::screen(int index)
+TDE_EXPORT RandRScreen* RandRDisplay::screen(int index)
{
return m_screens.at(index);
}
-KDE_EXPORT RandRScreen* RandRDisplay::currentScreen()
+TDE_EXPORT RandRScreen* RandRDisplay::currentScreen()
{
return m_currentScreen;
}
-KDE_EXPORT bool RandRDisplay::loadDisplay(TDEConfig& config, bool loadScreens)
+TDE_EXPORT bool RandRDisplay::loadDisplay(TDEConfig& config, bool loadScreens)
{
if (loadScreens)
for (RandRScreen* s = m_screens.first(); s; s = m_screens.next())
@@ -791,19 +791,19 @@ KDE_EXPORT bool RandRDisplay::loadDisplay(TDEConfig& config, bool loadScreens)
return applyOnStartup(config);
}
-KDE_EXPORT bool RandRDisplay::applyOnStartup(TDEConfig& config)
+TDE_EXPORT bool RandRDisplay::applyOnStartup(TDEConfig& config)
{
config.setGroup("Display");
return config.readBoolEntry("ApplyOnStartup", false);
}
-KDE_EXPORT bool RandRDisplay::syncTrayApp(TDEConfig& config)
+TDE_EXPORT bool RandRDisplay::syncTrayApp(TDEConfig& config)
{
config.setGroup("Display");
return config.readBoolEntry("SyncTrayApp", false);
}
-KDE_EXPORT void RandRDisplay::saveDisplay(TDEConfig& config, bool applyOnStartup, bool syncTrayApp)
+TDE_EXPORT void RandRDisplay::saveDisplay(TDEConfig& config, bool applyOnStartup, bool syncTrayApp)
{
Q_ASSERT(!config.isReadOnly());
@@ -815,7 +815,7 @@ KDE_EXPORT void RandRDisplay::saveDisplay(TDEConfig& config, bool applyOnStartup
s->save(config);
}
-KDE_EXPORT void RandRDisplay::applyProposed(bool confirm)
+TDE_EXPORT void RandRDisplay::applyProposed(bool confirm)
{
for (int screenIndex = 0; screenIndex < numScreens(); screenIndex++) {
if (screen(screenIndex)->proposedChanged()) {
@@ -827,7 +827,7 @@ KDE_EXPORT void RandRDisplay::applyProposed(bool confirm)
}
}
-KDE_EXPORT bool RandRDisplay::showTestConfigurationDialog()
+TDE_EXPORT bool RandRDisplay::showTestConfigurationDialog()
{
RandRScreen* firstScreen = screen(0);
if (firstScreen) {
@@ -838,7 +838,7 @@ KDE_EXPORT bool RandRDisplay::showTestConfigurationDialog()
}
}
-KDE_EXPORT bool RandRScreen::showTestConfigurationDialog()
+TDE_EXPORT bool RandRScreen::showTestConfigurationDialog()
{
// uncomment the line below and edit out the KTimerDialog stuff to get
// a version which works on today's tdelibs (no accept dialog is presented)
@@ -846,7 +846,7 @@ KDE_EXPORT bool RandRScreen::showTestConfigurationDialog()
// FIXME remember to put the dialog on the right screen
KTimerDialog acceptDialog ( 15000, KTimerDialog::CountDown,
- TDEApplication::kApplication()->mainWidget(),
+ tdeApp->mainWidget(),
"mainKTimerDialog",
true,
i18n("Confirm Display Settings"),
@@ -866,13 +866,13 @@ KDE_EXPORT bool RandRScreen::showTestConfigurationDialog()
KDialog::centerOnScreen(&acceptDialog, 0);
m_shownDialog = &acceptDialog;
- connect( m_shownDialog, TQT_SIGNAL( destroyed()), this, TQT_SLOT( shownDialogDestroyed()));
- connect( kapp->desktop(), TQT_SIGNAL( resized(int)), this, TQT_SLOT( desktopResized()));
+ connect( m_shownDialog, TQ_SIGNAL( destroyed()), this, TQ_SLOT( shownDialogDestroyed()));
+ connect( tdeApp->desktop(), TQ_SIGNAL( resized(int)), this, TQ_SLOT( desktopResized()));
return acceptDialog.exec();
}
-KDE_EXPORT int RandRScreen::pixelCount( int index ) const
+TDE_EXPORT int RandRScreen::pixelCount( int index ) const
{
TQSize sz = pixelSize(index);
return sz.width() * sz.height();
diff --git a/tderandr/randr.h b/tderandr/randr.h
index 9683f6b9b..36e87badd 100644
--- a/tderandr/randr.h
+++ b/tderandr/randr.h
@@ -26,6 +26,11 @@
#include <tdecmodule.h>
#include <tdeconfig.h>
+#define ROTATION_0_DEGREES_INDEX 0
+#define ROTATION_90_DEGREES_INDEX 1
+#define ROTATION_180_DEGREES_INDEX 2
+#define ROTATION_270_DEGREES_INDEX 3
+
class KTimerDialog;
class RandRScreenPrivate;
@@ -95,7 +100,7 @@ class TDERANDR_EXPORT SingleScreenData {
class RandRScreen : public TQObject
{
- Q_OBJECT
+ TQ_OBJECT
public:
enum orientations {
@@ -292,8 +297,8 @@ private:
ScreenList m_screens;
bool m_valid;
- QString m_errorCode;
- QString m_version;
+ TQString m_errorCode;
+ TQString m_version;
int m_eventBase;
int m_errorBase;