Browse Source

Add profile support to displayconfig and krandrtray

Add automatic display hotplug profile switch support to krandrtray
tags/r14.0.0
Timothy Pearson 7 years ago
parent
commit
a35fdc9c4d
9 changed files with 725 additions and 112 deletions
  1. +539
    -74
      kcontrol/displayconfig/displayconfig.cpp
  2. +21
    -3
      kcontrol/displayconfig/displayconfig.h
  3. +127
    -2
      kcontrol/displayconfig/displayconfigbase.ui
  4. +2
    -0
      kcontrol/iccconfig/iccconfig.cpp
  5. +26
    -31
      kcontrol/randr/krandrtray.cpp
  6. +1
    -0
      kcontrol/randr/krandrtray.h
  7. +7
    -0
      kicker/kicker/core/container_extension.cpp
  8. +1
    -1
      tdeinit/displayconfig.cpp
  9. +1
    -1
      tdm/kfrontend/kgapp.cpp

+ 539
- 74
kcontrol/displayconfig/displayconfig.cpp View File

@@ -436,7 +436,7 @@ void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id,
DraggableMonitor *monitor = static_cast<DraggableMonitor*>(TQT_TQWIDGET(monitors.at( i )));
if (monitor->screen_id == monitor_id) {
moved_monitor = monitor;
screendata = m_screenInfoArray.at(moved_monitor->screen_id);
screendata = m_screenInfoArray[activeProfileName].at(moved_monitor->screen_id);
}
}
}
@@ -466,7 +466,7 @@ void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id,

// Find the primary monitor
for (i=0;i<numberOfScreens;i++) {
screendata = m_screenInfoArray.at(i);
screendata = m_screenInfoArray[activeProfileName].at(i);
if (screendata->is_primary)
j=i;
}
@@ -498,7 +498,7 @@ void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id,
int offset_x = toffset_x / base->monitorPhyArrange->resize_factor;
int offset_y = toffset_y / base->monitorPhyArrange->resize_factor;

screendata = m_screenInfoArray.at(monitor_id);
screendata = m_screenInfoArray[activeProfileName].at(monitor_id);
screendata->absolute_x_position = offset_x;
screendata->absolute_y_position = offset_y;
}
@@ -630,7 +630,7 @@ void KDisplayConfig::moveMonitor(DraggableMonitor* monitor, int realx, int realy
// Find the primary monitor
primary_found = false;
for (i=0;i<numberOfScreens;i++) {
screendata = m_screenInfoArray.at(i);
screendata = m_screenInfoArray[activeProfileName].at(i);
if (screendata->is_primary) {
j=i;
primary_found = true;
@@ -704,7 +704,7 @@ int KDisplayConfig::realResolutionSliderValue() {
unsigned int j;
SingleScreenData *screendata;

screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->monitorDisplaySelectDD->currentItem());
TQStringList sortedList = screendata->resolutions;
sortedList = sortResolutions(sortedList);

@@ -723,7 +723,7 @@ void KDisplayConfig::setRealResolutionSliderValue(int index) {
unsigned int j;
SingleScreenData *screendata;

screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->monitorDisplaySelectDD->currentItem());
TQStringList sortedList = screendata->resolutions;
sortedList = sortResolutions(sortedList);

@@ -740,7 +740,7 @@ void KDisplayConfig::setRealResolutionSliderValue(int index) {
/**** KDisplayConfig ****/

KDisplayConfig::KDisplayConfig(TQWidget *parent, const char *name, const TQStringList &)
: KCModule(KDisplayCFactory::instance(), parent, name), iccTab(0), m_randrsimple(0), m_gammaApplyTimer(0)
: KCModule(KDisplayCFactory::instance(), parent, name), iccTab(0), m_randrsimple(0), activeProfileName(""), m_gammaApplyTimer(0)
{
TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(deviceChanged(TDEGenericDevice*)));
@@ -769,6 +769,8 @@ KDisplayConfig::KDisplayConfig(TQWidget *parent, const char *name, const TQStrin
connect(m_gammaApplyTimer, SIGNAL(timeout()), this, SLOT(applyGamma()));

base = new DisplayConfigBase(this);
profileRulesGrid = new TQGridLayout(base->profileRulesGridWidget, 1, 1, KDialog::marginHint());

layout->addWidget(base);

if (getuid() != 0) {
@@ -789,6 +791,16 @@ KDisplayConfig::KDisplayConfig(TQWidget *parent, const char *name, const TQStrin

connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(changed()));
connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(processLockoutControls()));
connect(base->addProfileButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(addProfile()));
connect(base->renameProfileButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(renameProfile()));
connect(base->deleteProfileButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(deleteProfile()));
connect(base->activateProfileButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(activateProfile()));
connect(base->reloadProfileButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(reloadProfileFromDisk()));
connect(base->saveProfileButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(saveProfile()));
connect(base->startupDisplayProfileList, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changed()));
connect(base->startupDisplayProfileList, TQT_SIGNAL(activated(int)), this, TQT_SLOT(selectDefaultProfile(int)));
connect(base->displayProfileList, TQT_SIGNAL(activated(int)), this, TQT_SLOT(selectProfile(int)));

connect(base->monitorDisplaySelectDD, TQT_SIGNAL(activated(int)), TQT_SLOT(changed()));
connect(base->gammamonitorDisplaySelectDD, TQT_SIGNAL(activated(int)), TQT_SLOT(changed()));
connect(base->gammaTargetSelectDD, TQT_SIGNAL(activated(int)), TQT_SLOT(gammaTargetChanged(int)));
@@ -857,31 +869,23 @@ void KDisplayConfig::deviceChanged (TDEGenericDevice* device) {
void KDisplayConfig::updateExtendedMonitorInformation () {
SingleScreenData *screendata;

screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->monitorDisplaySelectDD->currentItem());
screendata->is_extended = base->isExtendedMonitorCB->isChecked();

refreshDisplayedInformation();
}

void KDisplayConfig::rescanHardware (void) {
m_randrsimple->destroyScreenInformationObject(m_screenInfoArray);
m_screenInfoArray = m_randrsimple->readCurrentDisplayConfiguration();
m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray);
numberOfScreens = m_screenInfoArray.count();
m_randrsimple->destroyScreenInformationObject(m_screenInfoArray[activeProfileName]);
m_screenInfoArray[activeProfileName] = m_randrsimple->readCurrentDisplayConfiguration();
m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray[activeProfileName]);
numberOfScreens = m_screenInfoArray[activeProfileName].count();
refreshDisplayedInformation();
}

void KDisplayConfig::reloadProfile (void) {
// FIXME
m_randrsimple->destroyScreenInformationObject(m_screenInfoArray);
if (getuid() != 0) {
m_screenInfoArray = m_randrsimple->loadSystemwideDisplayConfiguration("", locateLocal("config", "/", true));
}
else {
m_screenInfoArray = m_randrsimple->loadSystemwideDisplayConfiguration("", KDE_CONFDIR);
}
m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray);
numberOfScreens = m_screenInfoArray.count();
m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray[activeProfileName]);
numberOfScreens = m_screenInfoArray[activeProfileName].count();
refreshDisplayedInformation();
}

@@ -897,7 +901,7 @@ void KDisplayConfig::identifyMonitors () {
randr_display = tqt_xdisplay();
randr_screen_info = m_randrsimple->read_screen_info(randr_display);

for (i = 0; i < m_screenInfoArray.count(); i++) {
for (i = 0; i < m_screenInfoArray[activeProfileName].count(); i++) {
// Look for ON outputs...
if (!randr_screen_info->outputs[i]->cur_crtc) {
continue;
@@ -920,29 +924,226 @@ void KDisplayConfig::identifyMonitors () {
m_randrsimple->freeScreenInfoStructure(randr_screen_info);
}

void KDisplayConfig::activatePreview() {
m_randrsimple->applyDisplayConfiguration(m_screenInfoArray[activeProfileName], TRUE);
}

void KDisplayConfig::load()
{
load( false );
}

void KDisplayConfig::loadProfileFromDiskHelper(bool forceReload) {
if (forceReload) {
m_randrsimple->destroyScreenInformationObject(m_screenInfoArray[activeProfileName]);
m_screenInfoArray.remove(activeProfileName);
}
if (!m_screenInfoArray.contains(activeProfileName)) {
TQPtrList<SingleScreenData> originalInfoArray;
TQPtrList<SingleScreenData> newInfoArray;
// If a configuration is present, load it in
// Otherwise, use the current display configuration
originalInfoArray = m_screenInfoArray[activeProfileName];
if (getuid() != 0) {
newInfoArray = m_randrsimple->loadDisplayConfiguration(activeProfileName, locateLocal("config", "/", true));
}
else {
newInfoArray = m_randrsimple->loadDisplayConfiguration(activeProfileName, KDE_CONFDIR);
}
if (newInfoArray.count() > 0) {
m_screenInfoArray[activeProfileName] = newInfoArray;
m_randrsimple->destroyScreenInformationObject(originalInfoArray);
}
else {
m_screenInfoArray[activeProfileName] = originalInfoArray;
m_randrsimple->destroyScreenInformationObject(newInfoArray);
}
}

// If there is still no valid configuration, read the active display information from the hardware
// to initialise the configuration...
if (m_screenInfoArray[activeProfileName].count() < 1) {
m_screenInfoArray[activeProfileName] = m_randrsimple->readCurrentDisplayConfiguration();
}

m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray[activeProfileName]);
numberOfScreens = m_screenInfoArray[activeProfileName].count();

reloadProfile();
}

void KDisplayConfig::selectProfile (int slotNumber) {
TQString selectedProfile = base->displayProfileList->currentText();
if (selectedProfile == "<default>") {
selectedProfile = "";
}
activeProfileName = selectedProfile;

loadProfileFromDiskHelper();
}

void KDisplayConfig::deleteProfile () {
if (activeProfileName == "") {
KMessageBox::sorry(this, i18n("You cannot delete the default profile!"), i18n("Invalid operation requested"));
return;
}

int ret = KMessageBox::warningYesNo(this, i18n("<qt><b>You are attempting to delete the display profile '%1'</b><br>If you click Yes, the profile will be permanently removed from disk<p>Do you want to delete this profile?</qt>").arg(activeProfileName), i18n("Delete display profile?"));
if (ret == KMessageBox::Yes) {
bool success = false;
if (getuid() != 0) {
success = m_randrsimple->deleteDisplayConfiguration(activeProfileName, locateLocal("config", "/", true));
}
else {
success = m_randrsimple->deleteDisplayConfiguration(activeProfileName, KDE_CONFDIR);
}
if (success) {
TQStringList::Iterator it = availableProfileNames.find(activeProfileName);
if (it != availableProfileNames.end()) {
availableProfileNames.remove(it);
}
profileListChanged();
selectProfile(base->displayProfileList->currentItem());
}
else {
KMessageBox::error(this, i18n("<qt><b>Unable to delete profile '%1'!</b><p>Please verify that you have permission to access the configuration file</qt>").arg(activeProfileName), i18n("Deletion failed!"));
}
}
}

void KDisplayConfig::renameProfile () {
if (activeProfileName == "") {
KMessageBox::sorry(this, i18n("You cannot rename the default profile!"), i18n("Invalid operation requested"));
return;
}

// Pop up a text entry box asking for the new name of the profile
bool _ok = false;
bool _end = false;
TQString _new;
TQString _text = i18n("Please enter the new profile name below:");
TQString _error;

while (!_end) {
_new = KInputDialog::getText( i18n("Display Profile Configuration"), _error + _text, activeProfileName, &_ok, this);
if (!_ok ) {
_end = true;
}
else {
_error = TQString();
if (!_new.isEmpty()) {
if (findProfileIndex(_new) != -1) {
_error = i18n("Error: A profile with that name already exists") + TQString("\n");
}
else {
_end = true;
}
}
}
}
if (!_ok) return;


bool success = false;
if (getuid() != 0) {
success = m_randrsimple->renameDisplayConfiguration(activeProfileName, _new, locateLocal("config", "/", true));
}
else {
success = m_randrsimple->renameDisplayConfiguration(activeProfileName, _new, KDE_CONFDIR);
}

if (success) {
TQStringList::Iterator it = availableProfileNames.find(activeProfileName);
if (it != availableProfileNames.end()) {
availableProfileNames.remove(it);
}
availableProfileNames.append(_new);
profileListChanged();
base->displayProfileList->setCurrentItem(_new);
selectProfile(base->displayProfileList->currentItem());
}
else {
KMessageBox::error(this, i18n("<qt><b>Unable to rename profile '%1'!</b><p>Please verify that you have permission to access the configuration file</qt>").arg(activeProfileName), i18n("Renaming failed!"));
}
}

void KDisplayConfig::addProfile () {
void KDisplayConfig::activateProfile() {
if (getuid() != 0) {
m_randrsimple->applyDisplayConfiguration(m_screenInfoArray[activeProfileName], TRUE, locateLocal("config", "/", true));
}
else {
m_randrsimple->applyDisplayConfiguration(m_screenInfoArray[activeProfileName], TRUE, KDE_CONFDIR);
}
rescanHardware();
}

void KDisplayConfig::reloadProfileFromDisk() {
loadProfileFromDiskHelper(true);
}

void KDisplayConfig::activatePreview() {
m_randrsimple->applySystemwideDisplayConfiguration(m_screenInfoArray, TRUE);
void KDisplayConfig::saveProfile() {
saveActiveSystemWideProfileToDisk();
}

void KDisplayConfig::load()
void KDisplayConfig::addProfile () {
// Pop up a text entry box asking for the name of the new profile
bool _ok = false;
bool _end = false;
TQString _new;
TQString _text = i18n("Please enter the new profile name below:");
TQString _error;

while (!_end) {
_new = KInputDialog::getText( i18n("Display Profile Configuration"), _error + _text, TQString::null, &_ok, this);
if (!_ok ) {
_end = true;
}
else {
_error = TQString();
if (!_new.isEmpty()) {
if (findProfileIndex(_new) != -1) {
_error = i18n("Error: A profile with that name already exists") + TQString("\n");
}
else {
_end = true;
}
}
}
}
if (!_ok) return;

m_screenInfoArray[_new] = m_randrsimple->copyScreenInformationObject(m_screenInfoArray[activeProfileName]);

// Insert the new profile name
availableProfileNames.append(_new);
profileListChanged();
base->displayProfileList->setCurrentItem(_new);
selectProfile(base->displayProfileList->currentItem());

updateDisplayedInformation();
saveActiveSystemWideProfileToDisk();
emit changed();
}

void KDisplayConfig::updateStartupProfileLabel()
{
load( false );
TQString friendlyName = startupProfileName;
if (friendlyName == "") {
friendlyName = "<default>";
}

base->startupDisplayProfileList->setCurrentItem(friendlyName, false);
}

void KDisplayConfig::selectProfile (int slotNumber) {
void KDisplayConfig::selectDefaultProfile(int slotNumber)
{
TQString selectedProfile = base->startupDisplayProfileList->currentText();
if (selectedProfile == "<default>") {
selectedProfile = "";
}

startupProfileName = selectedProfile;
}

void KDisplayConfig::selectScreen (int slotNumber) {
@@ -952,9 +1153,9 @@ void KDisplayConfig::selectScreen (int slotNumber) {
}

void KDisplayConfig::updateArray (void) {
m_screenInfoArray = m_randrsimple->readCurrentDisplayConfiguration();
m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray);
numberOfScreens = m_screenInfoArray.count();
m_screenInfoArray[activeProfileName] = m_randrsimple->readCurrentDisplayConfiguration();
m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray[activeProfileName]);
numberOfScreens = m_screenInfoArray[activeProfileName].count();
}

void KDisplayConfig::updateDisplayedInformation () {
@@ -964,7 +1165,18 @@ void KDisplayConfig::updateDisplayedInformation () {

ensureMonitorDataConsistency();

screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->monitorDisplaySelectDD->currentItem());

if (!screendata) {
base->resolutionSlider->setEnabled(false);
base->refreshRateDD->setEnabled(false);
base->rotationSelectDD->setEnabled(false);
base->orientationHFlip->setEnabled(false);
base->orientationVFlip->setEnabled(false);
base->isPrimaryMonitorCB->setEnabled(false);
base->isExtendedMonitorCB->setEnabled(false);
return;
}

if (screendata->screen_connected) {
base->resolutionSlider->setEnabled(true);
@@ -1053,6 +1265,8 @@ void KDisplayConfig::updateDisplayedInformation () {
}

void KDisplayConfig::refreshDisplayedInformation () {
createHotplugRulesGrid();

// Insert data into the GUI
int i;
SingleScreenData *screendata;
@@ -1061,13 +1275,13 @@ void KDisplayConfig::refreshDisplayedInformation () {
int currentScreenIndex = base->monitorDisplaySelectDD->currentItem();
base->monitorDisplaySelectDD->clear();
for (i=0;i<numberOfScreens;i++) {
screendata = m_screenInfoArray.at(i);
screendata = m_screenInfoArray[activeProfileName].at(i);
base->monitorDisplaySelectDD->insertItem(screendata->screenFriendlyName, i);
}
base->monitorDisplaySelectDD->setCurrentItem(currentScreenIndex);
base->gammamonitorDisplaySelectDD->clear();
for (i=0;i<numberOfScreens;i++) {
screendata = m_screenInfoArray.at(i);
screendata = m_screenInfoArray[activeProfileName].at(i);
base->gammamonitorDisplaySelectDD->insertItem(screendata->screenFriendlyName, i);
}
base->gammamonitorDisplaySelectDD->setCurrentItem(currentScreenIndex);
@@ -1076,15 +1290,21 @@ void KDisplayConfig::refreshDisplayedInformation () {

updateDragDropDisplay();

screendata = m_screenInfoArray.at(0);
base->systemEnableDPMS->setEnabled(screendata->has_dpms);
base->systemEnableDPMS->setChecked(screendata->enable_dpms);
base->systemEnableDPMSStandby->setChecked(screendata->dpms_standby_delay!=0);
base->systemEnableDPMSSuspend->setChecked(screendata->dpms_suspend_delay!=0);
base->systemEnableDPMSPowerDown->setChecked(screendata->dpms_off_delay!=0);
base->dpmsStandbyTimeout->setValue(screendata->dpms_standby_delay/60);
base->dpmsSuspendTimeout->setValue(screendata->dpms_suspend_delay/60);
base->dpmsPowerDownTimeout->setValue(screendata->dpms_off_delay/60);
screendata = m_screenInfoArray[activeProfileName].at(0);
if (screendata) {
base->groupPowerManagement->setEnabled(true);
base->systemEnableDPMS->setEnabled(screendata->has_dpms);
base->systemEnableDPMS->setChecked(screendata->enable_dpms);
base->systemEnableDPMSStandby->setChecked(screendata->dpms_standby_delay!=0);
base->systemEnableDPMSSuspend->setChecked(screendata->dpms_suspend_delay!=0);
base->systemEnableDPMSPowerDown->setChecked(screendata->dpms_off_delay!=0);
base->dpmsStandbyTimeout->setValue(screendata->dpms_standby_delay/60);
base->dpmsSuspendTimeout->setValue(screendata->dpms_suspend_delay/60);
base->dpmsPowerDownTimeout->setValue(screendata->dpms_off_delay/60);
}
else {
base->groupPowerManagement->setEnabled(false);
}
processDPMSControls();
}

@@ -1115,7 +1335,7 @@ void KDisplayConfig::updateDragDropDisplay() {
base->monitorPhyArrange->resize_factor = 0.0625; // This always needs to divide by a multiple of 2
for (j=0;j<2;j++) {
for (i=0;i<numberOfScreens;i++) {
screendata = m_screenInfoArray.at(i);
screendata = m_screenInfoArray[activeProfileName].at(i);
if (((j==0) && (screendata->is_primary==true)) || ((j==1) && (screendata->is_primary==false))) { // This ensures that the primary monitor is always the first one created and placed on the configuration widget
TQString rotationDesired = *screendata->rotations.at(screendata->current_rotation_index);
bool isvisiblyrotated = ((rotationDesired == ROTATION_90_DEGREES_STRING) || (rotationDesired == ROTATION_270_DEGREES_STRING));
@@ -1154,7 +1374,7 @@ void KDisplayConfig::layoutDragDropDisplay() {
for ( i = 0; i < int(monitors.count()); ++i ) {
if (::tqqt_cast<DraggableMonitor*>(TQT_TQWIDGET(monitors.at( i )))) {
DraggableMonitor *monitor = static_cast<DraggableMonitor*>(TQT_TQWIDGET(monitors.at( i )));
screendata = m_screenInfoArray.at(monitor->screen_id);
screendata = m_screenInfoArray[activeProfileName].at(monitor->screen_id);
moveMonitor(monitor, screendata->absolute_x_position, screendata->absolute_y_position);
}
}
@@ -1162,30 +1382,32 @@ void KDisplayConfig::layoutDragDropDisplay() {
}

void KDisplayConfig::ensureMonitorDataConsistency() {
m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray);
m_randrsimple->ensureMonitorDataConsistency(m_screenInfoArray[activeProfileName]);
}

void KDisplayConfig::resolutionSliderTextUpdate(int index) {
SingleScreenData *screendata;
screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->monitorDisplaySelectDD->currentItem());

base->resolutionLabel->setText(screendata->resolutions[realResolutionSliderValue()] + TQString(" ") + i18n("pixels"));
}

void KDisplayConfig::resolutionSliderChanged(int index) {
SingleScreenData *screendata;
screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->monitorDisplaySelectDD->currentItem());

screendata->current_resolution_index = realResolutionSliderValue();
updateDisplayedInformation();
updateDraggableMonitorInformation(base->monitorDisplaySelectDD->currentItem());

applyMonitorLayoutRules();

changed();
}

void KDisplayConfig::rotationInfoChanged() {
SingleScreenData *screendata;
screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->monitorDisplaySelectDD->currentItem());

screendata->current_rotation_index = base->rotationSelectDD->currentItem();
screendata->has_x_flip = base->orientationHFlip->isChecked();
@@ -1193,12 +1415,14 @@ void KDisplayConfig::rotationInfoChanged() {
updateDisplayedInformation();
updateDraggableMonitorInformation(base->monitorDisplaySelectDD->currentItem());

applyMonitorLayoutRules();

changed();
}

void KDisplayConfig::refreshInfoChanged() {
SingleScreenData *screendata;
screendata = m_screenInfoArray.at(base->monitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->monitorDisplaySelectDD->currentItem());

screendata->current_refresh_rate_index = base->refreshRateDD->currentItem();
updateDisplayedInformation();
@@ -1207,10 +1431,6 @@ void KDisplayConfig::refreshInfoChanged() {
changed();
}

TQString KDisplayConfig::extractFileName(TQString displayName, TQString profileName) {

}

void KDisplayConfig::ensurePrimaryMonitorIsAvailable() {
// Ensure that only one monitor, and not less than one monitor, is marked as primary
int i;
@@ -1219,11 +1439,11 @@ void KDisplayConfig::ensurePrimaryMonitorIsAvailable() {
// First, the screens
int currentScreenIndex = base->monitorDisplaySelectDD->currentItem();
for (i=0;i<numberOfScreens;i++) {
screendata = m_screenInfoArray.at(i);
screendata = m_screenInfoArray[activeProfileName].at(i);
if (i != currentScreenIndex)
screendata->is_primary = false;
}
screendata = m_screenInfoArray.at(currentScreenIndex);
screendata = m_screenInfoArray[activeProfileName].at(currentScreenIndex);
screendata->is_primary = true;
screendata->is_extended = true;
updateDragDropDisplay();
@@ -1231,17 +1451,19 @@ void KDisplayConfig::ensurePrimaryMonitorIsAvailable() {
}

int KDisplayConfig::findProfileIndex(TQString profileName) {

}

int KDisplayConfig::findScreenIndex(TQString screenName) {

int i;
for (i=0;i<base->displayProfileList->count();i++) {
if (base->displayProfileList->text(i) == profileName) {
return i;
}
}
return -1;
}

void KDisplayConfig::setGammaLabels() {
SingleScreenData *screendata;

screendata = m_screenInfoArray.at(base->gammamonitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->gammamonitorDisplaySelectDD->currentItem());

// Round off the gammas to one decimal place
screendata->gamma_red = floorf(screendata->gamma_red * 10 + 0.5) / 10;
@@ -1259,7 +1481,7 @@ void KDisplayConfig::gammaSetAverageAllSlider() {
float average_gamma;
SingleScreenData *screendata;

screendata = m_screenInfoArray.at(base->gammamonitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->gammamonitorDisplaySelectDD->currentItem());
average_gamma = (screendata->gamma_red+screendata->gamma_green+screendata->gamma_blue)/3.0;
average_gamma = floorf(average_gamma* 10 + 0.5) / 10; // Round off the gamma to one decimal place
base->gammaAllSlider->setValue(average_gamma*10.0);
@@ -1273,7 +1495,7 @@ void KDisplayConfig::gammaselectScreen (int slotNumber) {
base->gammaGreenSlider->blockSignals(true);
base->gammaBlueSlider->blockSignals(true);

screendata = m_screenInfoArray.at(base->gammamonitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->gammamonitorDisplaySelectDD->currentItem());
base->gammaRedSlider->setValue(screendata->gamma_red*10.0);
base->gammaGreenSlider->setValue(screendata->gamma_green*10.0);
base->gammaBlueSlider->setValue(screendata->gamma_blue*10.0);
@@ -1294,7 +1516,7 @@ void KDisplayConfig::gammaAllSliderChanged(int index) {
base->gammaGreenSlider->blockSignals(true);
base->gammaBlueSlider->blockSignals(true);

screendata = m_screenInfoArray.at(base->gammamonitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->gammamonitorDisplaySelectDD->currentItem());

base->gammaRedSlider->setValue(base->gammaAllSlider->value());
base->gammaGreenSlider->setValue(base->gammaAllSlider->value());
@@ -1323,7 +1545,7 @@ void KDisplayConfig::gammaRedSliderChanged(int index) {
base->gammaGreenSlider->blockSignals(true);
base->gammaBlueSlider->blockSignals(true);

screendata = m_screenInfoArray.at(base->gammamonitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->gammamonitorDisplaySelectDD->currentItem());
screendata->gamma_red = ((float)index)/10.0;
gammaSetAverageAllSlider();
setGammaLabels();
@@ -1345,7 +1567,7 @@ void KDisplayConfig::gammaGreenSliderChanged(int index) {
base->gammaGreenSlider->blockSignals(true);
base->gammaBlueSlider->blockSignals(true);

screendata = m_screenInfoArray.at(base->gammamonitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->gammamonitorDisplaySelectDD->currentItem());
screendata->gamma_green = ((float)index)/10.0;
gammaSetAverageAllSlider();
setGammaLabels();
@@ -1367,7 +1589,7 @@ void KDisplayConfig::gammaBlueSliderChanged(int index) {
base->gammaGreenSlider->blockSignals(true);
base->gammaBlueSlider->blockSignals(true);

screendata = m_screenInfoArray.at(base->gammamonitorDisplaySelectDD->currentItem());
screendata = m_screenInfoArray[activeProfileName].at(base->gammamonitorDisplaySelectDD->currentItem());
screendata->gamma_blue = ((float)index)/10.0;
gammaSetAverageAllSlider();
setGammaLabels();
@@ -1382,7 +1604,7 @@ void KDisplayConfig::gammaBlueSliderChanged(int index) {
}

void KDisplayConfig::applyGamma() {
m_randrsimple->applySystemwideDisplayGamma(m_screenInfoArray);
m_randrsimple->applyDisplayGamma(m_screenInfoArray[activeProfileName]);
}

void KDisplayConfig::gammaTargetChanged (int slotNumber) {
@@ -1392,7 +1614,7 @@ void KDisplayConfig::gammaTargetChanged (int slotNumber) {

void KDisplayConfig::dpmsChanged() {
SingleScreenData *screendata;
screendata = m_screenInfoArray.at(0);
screendata = m_screenInfoArray[activeProfileName].at(0);

processDPMSControls();

@@ -1404,6 +1626,194 @@ void KDisplayConfig::dpmsChanged() {
changed();
}

void KDisplayConfig::createHotplugRulesGrid() {
const TQObjectList children = base->profileRulesGridWidget->childrenListObject();
TQObjectList::iterator it = children.begin();
for (; it != children.end(); ++it) {
TQWidget *w = dynamic_cast<TQWidget*>(*it);
if (w) {
delete w;
}
}

int i = 0;
int j = 0;
TQLabel* label;
SingleScreenData *screendata;
for (i=0;i<numberOfScreens;i++) {
screendata = m_screenInfoArray[activeProfileName].at(i);
label = new TQLabel(base->profileRulesGridWidget, (TQString("%1").arg(i)).ascii());
if (screendata) {
label->setText(screendata->screenUniqueName);
}
profileRulesGrid->addWidget(label, 0, i);
label->show();
}
label = new TQLabel(base->profileRulesGridWidget, "<ignore>");
label->setText(i18n("Activate Profile on Match"));
profileRulesGrid->addWidget(label, 0, i+1);
label->show();

i=0;
HotPlugRulesList::Iterator it2;
for (it2=currentHotplugRules.begin(); it2 != currentHotplugRules.end(); ++it2) {
for (j=0;j<numberOfScreens;j++) {
int index = (*it2).outputs.findIndex(m_screenInfoArray[activeProfileName].at(j)->screenUniqueName);

TQCheckBox* cb = new TQCheckBox(base->profileRulesGridWidget, (TQString("%1:%2").arg(i).arg(j)).ascii());
connect(cb, TQT_SIGNAL(stateChanged(int)), this, TQT_SLOT(profileRuleCheckBoxStateChanged(int)));
connect(cb, TQT_SIGNAL(stateChanged(int)), this, TQT_SLOT(changed()));
cb->setTristate(true);
if (index < 0) {
cb->setNoChange();
}
else {
switch ((*it2).states[index]) {
case HotPlugRule::AnyState:
cb->setNoChange();
break;
case HotPlugRule::Connected:
cb->setChecked(true);
break;
case HotPlugRule::Disconnected:
cb->setChecked(false);
break;
}
}
profileRulesGrid->addWidget(cb, i+1, j);
cb->show();
}
KComboBox* combo = new KComboBox(base->profileRulesGridWidget, (TQString("%1").arg(i)).ascii());
connect(combo, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changed()));
combo->insertItem("<default>");
for (TQStringList::Iterator it3 = availableProfileNames.begin(); it3 != availableProfileNames.end(); ++it3) {
combo->insertItem(*it3);
}
combo->setCurrentItem((*it2).profileName);
profileRulesGrid->addWidget(combo, i+1, j+1);
combo->show();
TQPushButton* button = new TQPushButton(base->profileRulesGridWidget, (TQString("%1").arg(i)).ascii());
button->setText(i18n("Delete Rule"));
connect(button, TQT_SIGNAL(clicked()), this, TQT_SLOT(deleteProfileRule()));
connect(button, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed()));
profileRulesGrid->addWidget(button, i+1, j+2);
button->show();
i++;
}

TQPushButton* button = new TQPushButton(base->profileRulesGridWidget);
button->setText(i18n("Add New Rule"));
connect(button, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewProfileRule()));
connect(button, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed()));
profileRulesGrid->addMultiCellWidget(button, i+2, i+2, 0, numberOfScreens+2);
button->show();
}

void KDisplayConfig::addNewProfileRule() {
currentHotplugRules.append(HotPlugRule());
createHotplugRulesGrid();
}

void KDisplayConfig::deleteProfileRule() {
const TQWidget* w = dynamic_cast<const TQWidget*>(sender());
if (w) {
int row = atoi(w->name());
currentHotplugRules.remove(currentHotplugRules.at(row));
createHotplugRulesGrid();
}
}

void KDisplayConfig::profileRuleCheckBoxStateChanged(int state) {
updateProfileConfigObjectFromGrid();
emit(changed());
}

void KDisplayConfig::updateProfileConfigObjectFromGrid() {
const TQObjectList children = base->profileRulesGridWidget->childrenListObject();
TQObjectList::iterator it = children.begin();
for (; it != children.end(); ++it) {
TQWidget *w = dynamic_cast<TQWidget*>(*it);
TQCheckBox *cb = dynamic_cast<TQCheckBox*>(w);
TQComboBox *combo = dynamic_cast<TQComboBox*>(w);
TQLabel* label = dynamic_cast<TQLabel*>(w);

if (label) {
if (TQString(w->name()) != TQString("<ignore>")) {
int col = atoi(w->name());
HotPlugRulesList::Iterator it2;
for (it2=currentHotplugRules.begin(); it2 != currentHotplugRules.end(); ++it2) {
TQStringList &strlist = (*it2).outputs;
while (strlist.count() < (uint)numberOfScreens) {
strlist.append("");
}
while (strlist.count() > (uint)numberOfScreens) {
strlist.remove(strlist.at(strlist.count()-1));
}
strlist[col] = label->text();
}
}
}
if (cb) {
TQStringList rowcol = TQStringList::split(":", cb->name());
int row = atoi(rowcol[0].ascii());
int col = atoi(rowcol[1].ascii());
TQValueList<int> &intlist = (*(currentHotplugRules.at(row))).states;
while (intlist.count() < (uint)numberOfScreens) {
intlist.append(HotPlugRule::AnyState);
}
while (intlist.count() > (uint)numberOfScreens) {
intlist.remove(intlist.at(intlist.count()-1));
}
int state = cb->state();
if (state == TQButton::On) {
intlist[col] = HotPlugRule::Connected;
}
else if (state == TQButton::Off) {
intlist[col] = HotPlugRule::Disconnected;
}
else {
intlist[col] = HotPlugRule::AnyState;
}
}
if (combo) {
int row = atoi(w->name());
(*(currentHotplugRules.at(row))).profileName = combo->currentText();
}
}
}

void KDisplayConfig::profileListChanged() {
// Save selected profile settings
TQString currentDisplayProfileListItem = base->displayProfileList->currentText();
TQString currentStartupDisplayProfileListItem = base->startupDisplayProfileList->currentText();

// Clear and reload the combo boxes
base->displayProfileList->clear();
base->startupDisplayProfileList->clear();
base->displayProfileList->insertItem("<default>");
base->startupDisplayProfileList->insertItem("<default>");
for (TQStringList::Iterator it = availableProfileNames.begin(); it != availableProfileNames.end(); ++it) {
base->displayProfileList->insertItem(*it);
base->startupDisplayProfileList->insertItem(*it);
}

// Restore selected profile settings if possible
if (base->displayProfileList->contains(currentDisplayProfileListItem)) {
base->displayProfileList->setCurrentItem(currentDisplayProfileListItem);
}
else {
base->displayProfileList->setCurrentItem(0);
}
if (base->startupDisplayProfileList->contains(currentStartupDisplayProfileListItem)) {
base->startupDisplayProfileList->setCurrentItem(currentStartupDisplayProfileListItem);
}
else {
base->startupDisplayProfileList->setCurrentItem(0);
}

createHotplugRulesGrid();
}

void KDisplayConfig::processDPMSControls() {
if (base->systemEnableDPMS->isChecked()) {
base->systemEnableDPMSStandby->setEnabled(true);
@@ -1435,6 +1845,15 @@ void KDisplayConfig::processLockoutControls() {
base->resolutionTab->setEnabled(false);
base->gammaTab->setEnabled(false);
base->powerTab->setEnabled(false);
base->displayProfileList->setEnabled(false);
base->addProfileButton->setEnabled(false);
base->renameProfileButton->setEnabled(false);
base->deleteProfileButton->setEnabled(false);
base->reloadProfileButton->setEnabled(false);
base->saveProfileButton->setEnabled(false);
base->activateProfileButton->setEnabled(false);
base->startupDisplayProfileList->setEnabled(false);
base->groupProfileRules->setEnabled(false);
}
else {
base->globalTab->setEnabled(true);
@@ -1442,11 +1861,29 @@ void KDisplayConfig::processLockoutControls() {
base->resolutionTab->setEnabled(true);
base->gammaTab->setEnabled(true);
base->powerTab->setEnabled(true);
base->displayProfileList->setEnabled(true);
base->addProfileButton->setEnabled(true);
base->renameProfileButton->setEnabled(true);
base->deleteProfileButton->setEnabled(true);
base->reloadProfileButton->setEnabled(true);
base->saveProfileButton->setEnabled(true);
base->activateProfileButton->setEnabled(true);
base->startupDisplayProfileList->setEnabled(true);
base->groupProfileRules->setEnabled(true);
}
else {
base->resolutionTab->setEnabled(false);
base->gammaTab->setEnabled(false);
base->powerTab->setEnabled(false);
base->displayProfileList->setEnabled(false);
base->addProfileButton->setEnabled(false);
base->renameProfileButton->setEnabled(false);
base->deleteProfileButton->setEnabled(false);
base->reloadProfileButton->setEnabled(false);
base->saveProfileButton->setEnabled(false);
base->activateProfileButton->setEnabled(false);
base->startupDisplayProfileList->setEnabled(false);
base->groupProfileRules->setEnabled(false);
}
}

@@ -1479,12 +1916,23 @@ KCModule* KDisplayConfig::addTab( const TQString name, const TQString label )

void KDisplayConfig::load(bool useDefaults )
{
if (getuid() != 0) {
availableProfileNames = m_randrsimple->getDisplayConfigurationProfiles(locateLocal("config", "/", true));
}
else {
availableProfileNames = m_randrsimple->getDisplayConfigurationProfiles(KDE_CONFDIR);
}
profileListChanged();

// Update the toggle buttons with the current configuration
updateArray();

systemconfig->setGroup(NULL);
base->systemEnableSupport->setChecked(systemconfig->readBoolEntry("EnableDisplayControl", false));

startupProfileName = systemconfig->readEntry("StartupProfileName", "");
updateStartupProfileLabel();

refreshDisplayedInformation();

gammaselectScreen(base->gammamonitorDisplaySelectDD->currentItem());
@@ -1498,22 +1946,39 @@ void KDisplayConfig::load(bool useDefaults )
base->gammaTargetSelectDD->setCurrentItem(4);
gammaTargetChanged(4);

currentHotplugRules = m_randrsimple->getHotplugRules(locateLocal("config", "/", true));
createHotplugRulesGrid();

emit changed(useDefaults);
}

void KDisplayConfig::saveActiveSystemWideProfileToDisk()
{
if (getuid() != 0) {
m_randrsimple->saveDisplayConfiguration(base->systemEnableSupport->isChecked(), activeProfileName, startupProfileName, locateLocal("config", "/", true), m_screenInfoArray[activeProfileName]);
}
else {
m_randrsimple->saveDisplayConfiguration(base->systemEnableSupport->isChecked(), activeProfileName, startupProfileName, KDE_CONFDIR, m_screenInfoArray[activeProfileName]);
}
}

void KDisplayConfig::save()
{
if (m_randrsimple->applySystemwideDisplayConfiguration(m_screenInfoArray, TRUE)) {
if (m_randrsimple->applyDisplayConfiguration(m_screenInfoArray[activeProfileName], TRUE)) {
saveActiveSystemWideProfileToDisk();

updateProfileConfigObjectFromGrid();
if (getuid() != 0) {
m_randrsimple->saveSystemwideDisplayConfiguration(base->systemEnableSupport->isChecked(), "", locateLocal("config", "/", true), m_screenInfoArray);
m_randrsimple->saveHotplugRules(currentHotplugRules, locateLocal("config", "/", true));
}
else {
m_randrsimple->saveSystemwideDisplayConfiguration(base->systemEnableSupport->isChecked(), "", KDE_CONFDIR, m_screenInfoArray);
m_randrsimple->saveHotplugRules(currentHotplugRules, KDE_CONFDIR);
}

// Write system configuration
systemconfig->setGroup(NULL);
systemconfig->writeEntry("EnableDisplayControl", base->systemEnableSupport->isChecked());
systemconfig->writeEntry("StartupProfileName", startupProfileName);

systemconfig->sync();


+ 21
- 3
kcontrol/displayconfig/displayconfig.h View File

@@ -44,6 +44,8 @@ class KConfig;
class KPopupMenu;
class KListViewItem;

typedef TQMap< TQString, TQPtrList< SingleScreenData > > ScreenConfigurationMap;

class KDisplayConfig : public KCModule, public DCOPObject
{
K_DCOP
@@ -79,13 +81,13 @@ private:
TQStringList cfgProfiles;
void refreshDisplayedInformation ();
void updateDisplayedInformation ();
TQString extractFileName(TQString displayName, TQString profileName);
TQString *displayFileArray;
int findProfileIndex(TQString profileName);
int findScreenIndex(TQString screenName);
TQString m_defaultProfile;
KRandrSimpleAPI *m_randrsimple;
TQPtrList<SingleScreenData> m_screenInfoArray;
ScreenConfigurationMap m_screenInfoArray;
TQString activeProfileName;
TQString startupProfileName;
int realResolutionSliderValue();
void setRealResolutionSliderValue(int index);
KCModule* addTab( const TQString name, const TQString label );
@@ -97,6 +99,14 @@ private:
void gammaSetAverageAllSlider();
void setGammaLabels();
void generateSortedResolutions();
void loadProfileFromDiskHelper(bool forceReload = false);
void saveActiveSystemWideProfileToDisk();
void createHotplugRulesGrid();
TQGridLayout* profileRulesGrid;
TQStringList availableProfileNames;
void profileListChanged();
HotPlugRulesList currentHotplugRules;
void updateProfileConfigObjectFromGrid();

private slots:
void selectProfile (int slotNumber);
@@ -107,6 +117,9 @@ private slots:
void addProfile (void);
void renameProfile (void);
void deleteProfile (void);
void activateProfile (void);
void reloadProfileFromDisk (void);
void saveProfile (void);
void ensurePrimaryMonitorIsAvailable (void);
void updateDragDropDisplay (void);
void layoutDragDropDisplay (void);
@@ -130,6 +143,11 @@ private slots:
void dpmsChanged (void);
void processDPMSControls (void);
void deviceChanged (TDEGenericDevice*);
void updateStartupProfileLabel (void);
void selectDefaultProfile (int index);
void addNewProfileRule (void);
void deleteProfileRule (void);
void profileRuleCheckBoxStateChanged (int state);
};

#endif


+ 127
- 2
kcontrol/displayconfig/displayconfigbase.ui View File

@@ -42,7 +42,7 @@
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="TQCheckBox" row="0" column="0" colspan="4">
<widget class="TQCheckBox" row="0" column="0" colspan="5">
<property name="name">
<cstring>systemEnableSupport</cstring>
</property>
@@ -50,9 +50,134 @@
<string>&amp;Enable global display control</string>
</property>
</widget>
<widget class="TQLayoutWidget" row="1" column="0" colspan="5">
<property name="name">
<cstring>layout7</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="TQLabel">
<property name="name">
<cstring>textLabel2_0</cstring>
</property>
<property name="text">
<string>Startup Profile:</string>
</property>
</widget>
<widget class="KComboBox">
<property name="name">
<cstring>startupDisplayProfileList</cstring>
</property>
</widget>
</hbox>
</widget>
</grid>
</widget>
<widget class="TQGroupBox" row="2" column="0">
<property name="name">
<cstring>groupProfiles</cstring>
</property>
<property name="title">
<string>Display Profiles</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="TQLayoutWidget" row="1" column="0" colspan="3">
<property name="name">
<cstring>layout7</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="TQLabel">
<property name="name">
<cstring>textLabel4_18</cstring>
</property>
<property name="text">
<string>Currently editing:</string>
</property>
</widget>
<widget class="KComboBox">
<property name="name">
<cstring>displayProfileList</cstring>
</property>
</widget>
</hbox>
</widget>
<widget class="KPushButton" row="2" column="0">
<property name="name">
<cstring>addProfileButton</cstring>
</property>
<property name="text">
<string>Create New</string>
</property>
</widget>
<widget class="KPushButton" row="2" column="1">
<property name="name">
<cstring>renameProfileButton</cstring>
</property>
<property name="text">
<string>Rename</string>
</property>
</widget>
<widget class="KPushButton" row="2" column="2">
<property name="name">
<cstring>deleteProfileButton</cstring>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
<widget class="KPushButton" row="3" column="0">
<property name="name">
<cstring>reloadProfileButton</cstring>
</property>
<property name="text">
<string>Reload</string>
</property>
</widget>
<widget class="KPushButton" row="3" column="1">
<property name="name">
<cstring>saveProfileButton</cstring>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
<widget class="KPushButton" row="3" column="2">
<property name="name">
<cstring>activateProfileButton</cstring>
</property>
<property name="text">
<string>Activate</string>
</property>
</widget>
</grid>
</widget>
<widget class="TQGroupBox" row="3" column="0">
<property name="name">
<cstring>groupProfileRules</cstring>
</property>
<property name="title">
<string>Hotplug Rules</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="TQWidget" row="0" column="0">
<property name="name">
<cstring>profileRulesGridWidget</cstring>
</property>
</widget>
</grid>
</widget>
<spacer row="2" column="0">
<spacer row="4" column="0">
<property name="name" stdset="0">
<cstring>Spacer4</cstring>
</property>


+ 2
- 0
kcontrol/iccconfig/iccconfig.cpp View File

@@ -178,6 +178,7 @@ void KICCConfig::renameProfile () {
}
}
}
if (!_ok) return;

// Rename the profile
if (config) config->deleteGroup(base->iccProfileList->currentText());
@@ -212,6 +213,7 @@ void KICCConfig::addProfile () {
}
}
}
if (!_ok) return;

// Expand the profile memory
numberOfProfiles++;


+ 26
- 31
kcontrol/randr/krandrtray.cpp View File

@@ -32,6 +32,7 @@
#include <kstdguiitem.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>

#include <cstdlib>
#include <unistd.h>
@@ -139,9 +140,6 @@ void KRandRSystemTray::mousePressEvent(TQMouseEvent* e)
void KRandRSystemTray::reloadDisplayConfiguration()
{
// Reload the randr configuration...
XRROutputInfo *output_info;
char *output_name;
RROutput output_id;
int i;
int activeOutputs = 0;
int screenDeactivated = 0;
@@ -152,7 +150,6 @@ void KRandRSystemTray::reloadDisplayConfiguration()
// Count outputs in the active state
activeOutputs = 0;
for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info;
// Look for ON outputs
if (!randr_screen_info->outputs[i]->cur_crtc) {
continue;
@@ -170,7 +167,6 @@ void KRandRSystemTray::reloadDisplayConfiguration()
// There are no active displays!
// Activate the first connected display we come across...
for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info;
// Look for OFF outputs
if (randr_screen_info->outputs[i]->cur_crtc) {
continue;
@@ -197,7 +193,6 @@ void KRandRSystemTray::reloadDisplayConfiguration()
}

for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info;
// Look for ON outputs
if (!randr_screen_info->outputs[i]->cur_crtc) {
continue;
@@ -207,9 +202,6 @@ void KRandRSystemTray::reloadDisplayConfiguration()
continue;
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;

// Deactivate this display to avoid a crash!
randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc;
randr_screen_info->cur_output = randr_screen_info->outputs[i];
@@ -281,6 +273,19 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu)
menu->connectItem(lastIndex, this, TQT_SLOT(slotColorProfileChanged(int)));
}

// Find any display profiles
TQStringList displayProfiles;
displayProfiles = getDisplayConfigurationProfiles(locateLocal("config", "/", true));
if (displayProfiles.isEmpty() == false) {
menu->insertTitle(SmallIcon("background"), i18n("Display Profiles"));
}
lastIndex = menu->insertItem(SmallIcon("bookmark"), "<default>");
menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int)));
for (TQStringList::Iterator t(displayProfiles.begin()); t != displayProfiles.end(); ++t) {
lastIndex = menu->insertItem(SmallIcon("bookmark"), *t);
menu->connectItem(lastIndex, this, TQT_SLOT(slotDisplayProfileChanged(int)));
}

menu->insertTitle(SmallIcon("randr"), i18n("Global Configuation"));

KAction *actColors = new KAction( i18n( "Configure Displays..." ),
@@ -550,13 +555,10 @@ void KRandRSystemTray::slotCycleDisplays()
{
XRROutputInfo *output_info;
char *output_name;
RROutput output_id;
int i;
int lastIndex = 0;
int current_on_index = -1;
int max_index = -1;
int prev_on_index;
Status s;

randr_screen_info = read_screen_info(randr_display);

@@ -572,7 +574,6 @@ void KRandRSystemTray::slotCycleDisplays()
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;
current_on_index = i;
if (i > max_index) {
max_index = i;
@@ -591,7 +592,6 @@ void KRandRSystemTray::slotCycleDisplays()
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;
if (i > max_index) {
max_index = i;
}
@@ -609,7 +609,6 @@ void KRandRSystemTray::slotCycleDisplays()
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;
if (i > max_index) {
max_index = i;
}
@@ -671,7 +670,6 @@ void KRandRSystemTray::slotCycleDisplays()
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;

// Deactivate this display to avoid a crash!
randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc;
@@ -697,14 +695,9 @@ void KRandRSystemTray::slotCycleDisplays()

void KRandRSystemTray::findPrimaryDisplay()
{
XRROutputInfo *output_info;
char *output_name;
RROutput output_id;
int i;
int lastIndex = 0;

for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info;
// Look for ON outputs...
if (!randr_screen_info->outputs[i]->cur_crtc) {
continue;
@@ -715,10 +708,6 @@ void KRandRSystemTray::findPrimaryDisplay()
continue;
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;
//printf("ACTIVE CHECK: Found output %s\n\r", output_name);

randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc;
randr_screen_info->cur_output = randr_screen_info->outputs[i];
}
@@ -728,7 +717,6 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu)
{
XRROutputInfo *output_info;
char *output_name;
RROutput output_id;
int i;
int lastIndex = 0;
int connected_displays = 0;
@@ -747,7 +735,6 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu)
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;
//printf("ON: Found output %s\n\r", output_name);

lastIndex = menu->insertItem(i18n("%1 (Active)").arg(output_name));
@@ -770,7 +757,6 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu)
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;
//printf("CONNECTED, NOT ON: Found output %s\n\r", output_name);

lastIndex = menu->insertItem(i18n("%1 (Connected, Inactive)").arg(output_name));
@@ -793,7 +779,6 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu)
}

output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id;
//printf("DISCONNECTED, NOT ON: Found output %s\n\r", output_name);

lastIndex = menu->insertItem(i18n("%1 (Disconnected, Inactive)").arg(output_name));
@@ -817,16 +802,25 @@ void KRandRSystemTray::slotColorProfileChanged(int parameter)
applyIccConfiguration(m_menu->text(parameter), NULL);
}

void KRandRSystemTray::slotDisplayProfileChanged(int parameter)
{
TQString profileName = m_menu->text(parameter);
if (profileName == "<default>") {
profileName = "";
}
TQPtrList<SingleScreenData> profileData = loadDisplayConfiguration(profileName, locateLocal("config", "/", true));
applyDisplayConfiguration(profileData, TRUE, locateLocal("config", "/", true));
destroyScreenInformationObject(profileData);
}

void KRandRSystemTray::slotOutputChanged(int parameter)
{
XRROutputInfo *output_info;
char *output_name;
int i;
int num_outputs_on;

num_outputs_on = 0;
for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info;
// Look for ON outputs
if (!randr_screen_info->outputs[i]->cur_crtc) {
continue;
@@ -880,5 +874,6 @@ void KRandRSystemTray::deviceChanged (TDEGenericDevice* device) {
this, "ScreenChangeNotification");

reloadDisplayConfiguration();
applyHotplugRules(locateLocal("config", "/", true));
}
}

+ 1
- 0
kcontrol/randr/krandrtray.h View File

@@ -57,6 +57,7 @@ protected slots:
void slotCycleDisplays();
void slotOutputChanged(int parameter);
void slotColorProfileChanged(int parameter);
void slotDisplayProfileChanged(int parameter);

protected:
void mousePressEvent( TQMouseEvent *e );


+ 7
- 0
kicker/kicker/core/container_extension.cpp View File

@@ -2030,6 +2030,13 @@ TQRect ExtensionContainer::initialGeometry(KPanelExtension::Position p,
{
//RESEARCH: is there someway to cache the results of the repeated calls to this method?

if (XineramaScreen == -3) {
// Forcibly hide
autoHidden = true;
userHidden = Unhidden;
XineramaScreen = kapp->desktop()->screenNumber(const_cast<ExtensionContainer*>(this));
}

/*kdDebug(1210) << "initialGeometry() Computing geometry for " << name() <<
" on screen " << XineramaScreen << endl;*/
TQRect workArea = ExtensionManager::the()->workArea(XineramaScreen, this);


+ 1
- 1
tdeinit/displayconfig.cpp View File

@@ -63,7 +63,7 @@ int main(int argc, char **argv)
#ifdef WITH_XRANDR
// Load up user specific display settings
KRandrSimpleAPI *randrsimple = new KRandrSimpleAPI();
randrsimple->applySystemwideDisplayConfiguration("", locateLocal("config", "/", true));
randrsimple->applyDisplayConfiguration("", locateLocal("config", "/", true));
delete randrsimple;
#endif



+ 1
- 1
tdm/kfrontend/kgapp.cpp View File

@@ -278,7 +278,7 @@ kg_main( const char *argv0 )
// Load up systemwide display settings
#ifdef WITH_XRANDR
KRandrSimpleAPI *randrsimple = new KRandrSimpleAPI();
TQPoint primaryScreenPosition = randrsimple->applySystemwideDisplayConfiguration("", KDE_CONFDIR);
TQPoint primaryScreenPosition = randrsimple->applyDisplayConfiguration("", KDE_CONFDIR);
delete randrsimple;
#endif



Loading…
Cancel
Save