27 #include <tqstringlist.h>
30 #include <tdemessagebox.h>
31 #include <tdeapplication.h>
37 #include "libtderandr.h"
39 #include <X11/extensions/dpms.h>
43 #define USE_XRANDR_PROGRAM
47 unsigned int reverse_bits(
register unsigned int x)
49 x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
50 x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
51 x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
52 x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
53 return((x >> 16) | (x << 16));
57 TQString exec(
const char * cmd) {
58 TQString bashcommand = cmd;
59 bashcommand = bashcommand.replace(
"\"",
"\\\"");
60 bashcommand = TQString(
"/bin/bash -c \"%1\" 2>&1").arg(bashcommand);
61 FILE* pipe = popen(bashcommand.ascii(),
"r");
62 if (!pipe)
return "ERROR";
66 if(fgets(buffer, 128, pipe) != NULL) {
71 result.remove(result.length(), 1);
75 TQString capitalizeString(TQString in) {
76 return in.left(1).upper() + in.right(in.length()-1);
79 TQString KRandrSimpleAPI::getIccFileName(TQString profileName, TQString screenName, TQString kde_confdir) {
82 int t_numberOfProfiles;
83 TQStringList t_cfgProfiles;
86 if ((profileName != NULL) && (profileName !=
"")) {
87 t_config =
new KSimpleConfig( TQString::fromLatin1(
"kiccconfigrc" ));
88 t_config->setGroup(NULL);
89 if (t_config->readBoolEntry(
"EnableICC",
false) ==
true) {
90 t_config->setGroup(profileName);
91 retval = t_config->readEntry(screenName);
99 t_systemconfig =
new KSimpleConfig( kde_confdir + TQString(
"/kicc/kiccconfigrc") );
100 t_systemconfig->setGroup(NULL);
101 if (t_systemconfig->readBoolEntry(
"EnableICC",
false) ==
true) {
102 retval = t_systemconfig->readEntry(
"ICCFile");
107 delete t_systemconfig;
113 TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
116 Display *randr_display;
117 ScreenInfo *randr_screen_info;
118 XRROutputInfo *output_info;
120 int screenNumber = 0;
122 if (fileName !=
"") {
131 if (isValid() ==
true) {
133 randr_display = tqt_xdisplay();
134 randr_screen_info = read_screen_info(randr_display);
135 if (randr_screen_info == NULL) {
139 for (i = 0; i < randr_screen_info->n_output; i++) {
140 output_info = randr_screen_info->outputs[i]->info;
142 if (!randr_screen_info->outputs[i]->cur_crtc) {
146 if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) {
149 if (output_info->name == screenName) {
154 freeScreenInfoStructure(randr_screen_info);
157 if (screenNumber >= 0) {
159 TQString icc_command;
161 char xcalib_result[2048];
165 icc_command = TQString(
"xcalib \"%1\"").arg(fileName);
166 if ((pipe_xcalib = popen(icc_command.ascii(),
"r")) == NULL)
168 printf(
"Xcalib pipe error\n [xcalib apply]");
171 if (fgets(xcalib_result, 2048, pipe_xcalib)) {
173 for (i=1;i<2048;i++) {
174 if (xcalib_result[i] == 0) {
175 xcalib_result[i-1]=0;
179 if (strlen(xcalib_result) > 2) {
180 return xcalib_result;
200 if (isValid() ==
true) {
202 randr_display = tqt_xdisplay();
203 randr_screen_info = read_screen_info(randr_display);
204 if (randr_screen_info == NULL) {
208 for (i = 0; i < randr_screen_info->n_output; i++) {
209 output_info = randr_screen_info->outputs[i]->info;
211 if (!randr_screen_info->outputs[i]->cur_crtc) {
215 if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) {
218 if (output_info->name == screenName) {
223 freeScreenInfoStructure(randr_screen_info);
226 if (screenNumber >= 0) {
228 TQString icc_command;
230 char xcalib_result[2048];
234 icc_command = TQString(
"xcalib -c");
235 if ((pipe_xcalib = popen(icc_command.ascii(),
"r")) == NULL)
237 printf(
"Xcalib pipe error\n [xcalib clear]");
240 if (fgets(xcalib_result, 2048, pipe_xcalib)) {
242 for (i=1;i<2048;i++) {
243 if (xcalib_result[i] == 0) {
244 xcalib_result[i-1]=0;
248 if (strlen(xcalib_result) > 2) {
249 return xcalib_result;
261 TQString KRandrSimpleAPI::applyIccConfiguration(TQString profileName, TQString kde_confdir) {
263 Display *randr_display;
264 ScreenInfo *randr_screen_info;
265 XRROutputInfo *output_info;
268 int screenNumber = 0;
269 TQString errorstr =
"";
271 t_config =
new KSimpleConfig( TQString::fromLatin1(
"kiccconfigrc" ));
274 if (isValid() ==
true) {
275 randr_display = tqt_xdisplay();
276 randr_screen_info = read_screen_info(randr_display);
277 if (randr_screen_info == NULL) {
280 for (i = 0; i < randr_screen_info->n_output; i++) {
281 output_info = randr_screen_info->outputs[i]->info;
282 errorstr = applyIccFile(output_info->name, getIccFileName(profileName, output_info->name, kde_confdir));
283 if (errorstr !=
"") {
287 freeScreenInfoStructure(randr_screen_info);
290 return applyIccFile(getIccFileName(profileName,
"Default", kde_confdir),
"Default");
293 t_config->writeEntry(
"CurrentProfile", profileName);
300 TQString KRandrSimpleAPI::getEDIDMonitorName(
int card, TQString displayname) {
302 TQByteArray binaryedid = getEDID(card, displayname);
303 if (binaryedid.isNull())
307 unsigned char letter_1 = ((binaryedid[8]>>2) & 0x1F) + 0x40;
308 unsigned char letter_2 = (((binaryedid[8] & 0x03) << 3) | ((binaryedid[9]>>5) & 0x07)) + 0x40;
309 unsigned char letter_3 = (binaryedid[9] & 0x1F) + 0x40;
310 TQChar qletter_1 = TQChar(letter_1);
311 TQChar qletter_2 = TQChar(letter_2);
312 TQChar qletter_3 = TQChar(letter_3);
313 TQString manufacturer_id = TQString(
"%1%2%3").arg(qletter_1).arg(qletter_2).arg(qletter_3);
316 unsigned int raw_model_id = (((binaryedid[10] << 8) | binaryedid[11]) << 16) & 0xFFFF0000;
318 unsigned int model_id = reverse_bits(raw_model_id);
321 bool has_friendly_name =
false;
322 unsigned char descriptor_block[18];
324 for (i=72;i<90;i++) {
325 descriptor_block[i-72] = binaryedid[i] & 0xFF;
327 if ((descriptor_block[0] != 0) || (descriptor_block[1] != 0) || (descriptor_block[3] != 0xFC)) {
328 for (i=90;i<108;i++) {
329 descriptor_block[i-90] = binaryedid[i] & 0xFF;
331 if ((descriptor_block[0] != 0) || (descriptor_block[1] != 0) || (descriptor_block[3] != 0xFC)) {
332 for (i=108;i<126;i++) {
333 descriptor_block[i-108] = binaryedid[i] & 0xFF;
338 TQString monitor_name;
339 if ((descriptor_block[0] == 0) && (descriptor_block[1] == 0) && (descriptor_block[3] == 0xFC)) {
340 char* pos = strchr((
char *)(descriptor_block+5),
'\n');
343 has_friendly_name =
true;
344 monitor_name = TQString((
char *)(descriptor_block+5));
347 has_friendly_name =
false;
354 if (has_friendly_name)
355 edid = TQString(
"%1 %2").arg(manufacturer_id).arg(monitor_name);
357 edid = TQString(
"%1 0x%2").arg(manufacturer_id).arg(model_id, 0, 16);
362 TQByteArray KRandrSimpleAPI::getEDID(
int card, TQString displayname) {
363 TQFile file(TQString(
"/sys/class/drm/card%1-%2/edid").arg(card).arg(displayname));
364 if (!file.open (IO_ReadOnly))
365 return TQByteArray();
366 TQByteArray binaryedid = file.readAll();
371 TQString KRandrSimpleAPI::getCurrentProfile () {
372 TQString profileName;
375 t_config =
new KSimpleConfig( TQString::fromLatin1(
"kiccconfigrc" ));
376 profileName = t_config->readEntry(
"CurrentProfile");
381 TQString KRandrSimpleAPI::applySystemWideIccConfiguration(TQString kde_confdir) {
383 TQString icc_command;
385 char xcalib_result[2048];
389 icc_command = TQString(
"xcalib \"%1\"").arg(getIccFileName(NULL,
"Default", kde_confdir));
390 if ((pipe_xcalib = popen(icc_command.ascii(),
"r")) == NULL)
392 printf(
"Xcalib pipe error [xcalib apply]\n");
395 if (fgets(xcalib_result, 2048, pipe_xcalib)) {
397 for (i=1;i<2048;i++) {
398 if (xcalib_result[i] == 0) {
399 xcalib_result[i-1]=0;
403 if (strlen(xcalib_result) > 2) {
404 return xcalib_result;
414 TQStringList KRandrSimpleAPI::getDisplayConfigurationProfiles(TQString kde_confdir) {
417 TQDir d(kde_confdir +
"/displayconfig/");
418 d.setFilter(TQDir::Files);
419 d.setSorting(TQDir::Name);
421 const TQFileInfoList *list = d.entryInfoList();
423 TQFileInfoListIterator it(*list);
426 while ((fi = it.current()) != 0) {
427 if (fi->fileName() !=
"default") {
428 ret.append(fi->fileName());
437 bool KRandrSimpleAPI::deleteDisplayConfiguration(TQString profilename, TQString kde_confdir) {
438 TQString fileName = kde_confdir +
"/displayconfig/";
439 fileName.append(profilename);
440 return (!unlink(fileName.ascii()));
443 bool KRandrSimpleAPI::renameDisplayConfiguration(TQString profilename, TQString newprofilename, TQString kde_confdir) {
444 TQString fileName = kde_confdir +
"/displayconfig/";
445 TQString newFileName = fileName;
446 fileName.append(profilename);
447 newFileName.append(newprofilename);
448 TQDir d(kde_confdir +
"/displayconfig/");
449 return (d.rename(fileName, newFileName));
452 void KRandrSimpleAPI::saveDisplayConfiguration(
bool enable,
bool applyonstart, TQString profilename, TQString defaultprofilename, TQString kde_confdir, TQPtrList<SingleScreenData> screenInfoArray) {
457 filename =
"displayglobals";
458 filename.prepend(kde_confdir.append(
"/"));
460 display_config->setGroup(
"General");
461 display_config->writeEntry(
"EnableDisplayControl", enable);
462 display_config->writeEntry(
"ApplySettingsOnStart", applyonstart);
463 display_config->writeEntry(
"StartupProfileName", defaultprofilename);
464 display_config->
sync();
465 delete display_config;
467 filename = profilename;
468 if (filename ==
"") {
469 filename =
"default";
471 filename.prepend(kde_confdir.append(
"/displayconfig/"));
476 SingleScreenData *screendata;
477 for ( screendata=screenInfoArray.first(); screendata; screendata=screenInfoArray.next() ) {
478 display_config->setGroup(TQString(
"SCREEN %1").arg(i));
479 display_config->writeEntry(
"ScreenUniqueName", screendata->screenUniqueName);
480 display_config->writeEntry(
"ScreenFriendlyName", screendata->screenFriendlyName);
481 display_config->writeEntry(
"GenericScreenDetected", screendata->generic_screen_detected);
482 display_config->writeEntry(
"ScreenConnected", screendata->screen_connected);
483 display_config->writeEntry(
"Resolutions", screendata->resolutions);
484 display_config->writeEntry(
"RefreshRates", screendata->refresh_rates);
485 display_config->writeEntry(
"ColorDepths", screendata->color_depths);
486 display_config->writeEntry(
"AvailableRotations", screendata->rotations);
487 display_config->writeEntry(
"CurrentResolution", screendata->current_resolution_index);
488 display_config->writeEntry(
"CurrentRefreshRate", screendata->current_refresh_rate_index);
489 display_config->writeEntry(
"CurrentColorDepth", screendata->current_color_depth_index);
490 display_config->writeEntry(
"CurrentRotation", screendata->current_rotation_index);
491 display_config->writeEntry(
"CurrentOrientiation", screendata->current_orientation_mask);
492 display_config->writeEntry(
"GammaRed", screendata->gamma_red);
493 display_config->writeEntry(
"GammaGreen", screendata->gamma_green);
494 display_config->writeEntry(
"GammaBlue", screendata->gamma_blue);
495 display_config->writeEntry(
"CurrentXFlip", screendata->has_x_flip);
496 display_config->writeEntry(
"CurrentYFlip", screendata->has_y_flip);
497 display_config->writeEntry(
"SupportsTransformation", screendata->supports_transformations);
498 display_config->writeEntry(
"IsPrimary", screendata->is_primary);
499 display_config->writeEntry(
"IsExtended", screendata->is_extended);
500 display_config->writeEntry(
"AbsXPos", screendata->absolute_x_position);
501 display_config->writeEntry(
"AbsYPos", screendata->absolute_y_position);
502 display_config->writeEntry(
"CurrentXPixelCount", screendata->current_x_pixel_count);
503 display_config->writeEntry(
"CurrentYPixelCount", screendata->current_y_pixel_count);
504 display_config->writeEntry(
"HasDPMS", screendata->has_dpms);
505 display_config->writeEntry(
"EnableDPMS", screendata->enable_dpms);
506 display_config->writeEntry(
"DPMSStandbyDelay", screendata->dpms_standby_delay);
507 display_config->writeEntry(
"DPMSSuspendDelay", screendata->dpms_suspend_delay);
508 display_config->writeEntry(
"DPMSPowerDownDelay", screendata->dpms_off_delay);
512 display_config->
sync();
513 delete display_config;
516 TQPoint KRandrSimpleAPI::applyStartupDisplayConfiguration(TQString kde_confdir) {
517 bool applyonstart = getDisplayConfigurationStartupAutoApplyEnabled(kde_confdir);
519 TQString profilename = getDisplayConfigurationStartupAutoApplyName(kde_confdir);
520 return applyDisplayConfiguration(profilename, kde_confdir);
527 TQPoint KRandrSimpleAPI::applyDisplayConfiguration(TQString profilename, TQString kde_confdir) {
530 bool enabled = getDisplayConfigurationEnabled(kde_confdir);
531 if (profilename ==
"") {
532 profilename =
"default";
536 TQPtrList<SingleScreenData> screenInfoArray;
537 screenInfoArray = loadDisplayConfiguration(profilename, kde_confdir);
538 if (screenInfoArray.count() > 0) {
539 applyDisplayConfiguration(screenInfoArray, FALSE, kde_confdir);
541 destroyScreenInformationObject(screenInfoArray);
542 screenInfoArray = readCurrentDisplayConfiguration();
543 ensureMonitorDataConsistency(screenInfoArray);
544 ret = primaryScreenOffsetFromTLC(screenInfoArray);
545 destroyScreenInformationObject(screenInfoArray);
551 TQPtrList<SingleScreenData> KRandrSimpleAPI::loadDisplayConfiguration(TQString profilename, TQString kde_confdir) {
555 filename = profilename;
556 if (filename ==
"") {
557 filename =
"default";
559 filename.prepend(kde_confdir.append(
"/displayconfig/"));
563 TQStringList grouplist = display_config->
groupList();
564 SingleScreenData *screendata;
565 TQPtrList<SingleScreenData> screenInfoArray;
566 for ( TQStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) {
567 if ((*it).startsWith(
"SCREEN ")) {
568 display_config->setGroup(*it);
569 i = ((*it).remove(
"SCREEN ")).toInt();
570 screendata =
new SingleScreenData;
571 screenInfoArray.append(screendata);
572 screendata->screenUniqueName = display_config->readEntry(
"ScreenUniqueName");
573 screendata->screenFriendlyName = display_config->readEntry(
"ScreenFriendlyName");
574 screendata->generic_screen_detected = display_config->readBoolEntry(
"GenericScreenDetected");
575 screendata->screen_connected = display_config->readBoolEntry(
"ScreenConnected");
576 screendata->resolutions = display_config->readListEntry(
"Resolutions");
577 screendata->refresh_rates = display_config->readListEntry(
"RefreshRates");
578 screendata->color_depths = display_config->readListEntry(
"ColorDepths");
579 screendata->rotations = display_config->readListEntry(
"AvailableRotations");
580 screendata->current_resolution_index = display_config->readNumEntry(
"CurrentResolution");
581 screendata->current_refresh_rate_index = display_config->readNumEntry(
"CurrentRefreshRate");
582 screendata->current_color_depth_index = display_config->readNumEntry(
"CurrentColorDepth");
583 screendata->current_rotation_index = display_config->readNumEntry(
"CurrentRotation");
584 screendata->current_orientation_mask = display_config->readNumEntry(
"CurrentOrientiation");
585 screendata->gamma_red = display_config->readDoubleNumEntry(
"GammaRed");
586 screendata->gamma_green = display_config->readDoubleNumEntry(
"GammaGreen");
587 screendata->gamma_blue = display_config->readDoubleNumEntry(
"GammaBlue");
588 screendata->has_x_flip = display_config->readBoolEntry(
"CurrentXFlip");
589 screendata->has_y_flip = display_config->readBoolEntry(
"CurrentYFlip");
590 screendata->supports_transformations = display_config->readBoolEntry(
"SupportsTransformation");
591 screendata->is_primary = display_config->readBoolEntry(
"IsPrimary");
592 screendata->is_extended = display_config->readBoolEntry(
"IsExtended");
593 screendata->absolute_x_position = display_config->readNumEntry(
"AbsXPos");
594 screendata->absolute_y_position = display_config->readNumEntry(
"AbsYPos");
595 screendata->current_x_pixel_count = display_config->readNumEntry(
"CurrentXPixelCount");
596 screendata->current_y_pixel_count = display_config->readNumEntry(
"CurrentYPixelCount");
597 screendata->has_dpms = display_config->readBoolEntry(
"HasDPMS");
598 screendata->enable_dpms = display_config->readBoolEntry(
"EnableDPMS");
599 screendata->dpms_standby_delay = display_config->readNumEntry(
"DPMSStandbyDelay");
600 screendata->dpms_suspend_delay = display_config->readNumEntry(
"DPMSSuspendDelay");
601 screendata->dpms_off_delay = display_config->readNumEntry(
"DPMSPowerDownDelay");
605 delete display_config;
607 return screenInfoArray;
610 int KRandrSimpleAPI::getHardwareRotationFlags(SingleScreenData* screendata) {
611 int rotationFlags = 0;
612 TQString rotationDesired = *screendata->rotations.at(screendata->current_rotation_index);
613 if (rotationDesired == ROTATION_0_DEGREES_STRING) {
614 rotationFlags = rotationFlags | RandRScreen::Rotate0;
616 else if (rotationDesired == ROTATION_90_DEGREES_STRING) {
617 rotationFlags = rotationFlags | RandRScreen::Rotate90;
619 else if (rotationDesired == ROTATION_180_DEGREES_STRING) {
620 rotationFlags = rotationFlags | RandRScreen::Rotate180;
622 else if (rotationDesired == ROTATION_270_DEGREES_STRING) {
623 rotationFlags = rotationFlags | RandRScreen::Rotate270;
625 if (screendata->has_x_flip) {
626 rotationFlags = rotationFlags | RandRScreen::ReflectX;
628 if (screendata->has_y_flip) {
629 rotationFlags = rotationFlags | RandRScreen::ReflectY;
631 return rotationFlags;
634 #define USE_XRANDR_PROGRAM
636 bool KRandrSimpleAPI::applyDisplayConfiguration(TQPtrList<SingleScreenData> screenInfoArray,
bool test, TQString kde_confdir) {
639 bool accepted =
true;
640 Display *randr_display;
641 XRROutputInfo *output_info;
642 ScreenInfo *randr_screen_info;
644 SingleScreenData *screendata;
646 TQPtrList<SingleScreenData> oldconfig;
648 oldconfig = readCurrentDisplayConfiguration();
651 if (isValid() ==
true) {
652 #ifdef USE_XRANDR_PROGRAM
657 randr_display = tqt_xdisplay();
658 randr_screen_info = read_screen_info(randr_display);
659 for (i = 0; i < screenInfoArray.count(); i++) {
660 screendata = screenInfoArray.at(i);
662 output_info = randr_screen_info->outputs[i]->info;
663 command.append(
" --output ").append(output_info->name);
664 if (screendata->is_primary || screendata->is_extended) {
665 command.append(TQString(
" --mode %1x%2").arg(screendata->current_x_pixel_count).arg(screendata->current_y_pixel_count));
666 command.append(TQString(
" --pos %1x%2").arg(screendata->absolute_x_position).arg(screendata->absolute_y_position));
667 command.append(TQString(
" --refresh %1").arg((*screendata->refresh_rates.at(screendata->current_refresh_rate_index)).
replace(
"Hz",
"")));
668 command.append(TQString(
" --gamma %1:%2:%3").arg(screendata->gamma_red).arg(screendata->gamma_green).arg(screendata->gamma_blue));
669 if (screendata->current_rotation_index == 0) command.append(
" --rotate ").append(
"normal");
670 if (screendata->current_rotation_index == 1) command.append(
" --rotate ").append(
"left");
671 if (screendata->current_rotation_index == 2) command.append(
" --rotate ").append(
"inverted");
672 if (screendata->current_rotation_index == 3) command.append(
" --rotate ").append(
"right");
673 if ((screendata->has_x_flip == 0) && (screendata->has_y_flip == 0)) command.append(
" --reflect ").append(
"normal");
674 if ((screendata->has_x_flip == 1) && (screendata->has_y_flip == 0)) command.append(
" --reflect ").append(
"x");
675 if ((screendata->has_x_flip == 0) && (screendata->has_y_flip == 1)) command.append(
" --reflect ").append(
"y");
676 if ((screendata->has_x_flip == 1) && (screendata->has_y_flip == 1)) command.append(
" --reflect ").append(
"xy");
677 if (screendata->is_primary) {
678 command.append(
" --primary");
682 command.append(
" --off");
686 printf(
"[WARNING] Unable to find configuration for monitor %d; settings may not be correctly applied...\n", i); fflush(stdout);
689 freeScreenInfoStructure(randr_screen_info);
691 TQString xrandr_command_output = exec(command.ascii());
692 xrandr_command_output = xrandr_command_output.stripWhiteSpace();
694 if (xrandr_command_output !=
"") {
695 applyDisplayConfiguration(oldconfig, FALSE, kde_confdir);
697 destroyScreenInformationObject(oldconfig);
698 KMessageBox::sorry(0, xrandr_command_output, i18n(
"XRandR encountered a problem"));
703 randr_display = tqt_xdisplay();
704 randr_screen_info = read_screen_info(randr_display);
706 for (i = 0; i < screenInfoArray.count(); i++) {
707 screendata = screenInfoArray.at(i);
708 output_info = randr_screen_info->outputs[i]->info;
710 randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc;
711 randr_screen_info->cur_output = randr_screen_info->outputs[i];
712 randr_screen_info->cur_output->auto_set = 0;
713 randr_screen_info->cur_output->off_set = 1;
714 output_off (randr_screen_info, randr_screen_info->cur_output);
715 j=main_low_apply(randr_screen_info);
717 freeScreenInfoStructure(randr_screen_info);
718 randr_screen_info = read_screen_info(randr_display);
720 for (i = 0; i < screenInfoArray.count(); i++) {
721 screendata = screenInfoArray.at(i);
722 output_info = randr_screen_info->outputs[i]->info;
724 if (screendata->is_primary ==
true) {
725 randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc;
726 randr_screen_info->cur_output = randr_screen_info->outputs[i];
727 randr_screen_info->cur_output->auto_set = 1;
728 randr_screen_info->cur_output->off_set = 0;
729 output_auto (randr_screen_info, randr_screen_info->cur_output);
730 j=main_low_apply(randr_screen_info);
733 freeScreenInfoStructure(randr_screen_info);
735 randr_screen_info = read_screen_info(randr_display);
736 for (i = 0; i < screenInfoArray.count(); i++) {
737 screendata = screenInfoArray.at(i);
738 output_info = randr_screen_info->outputs[i]->info;
741 randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc;
742 randr_screen_info->cur_output = randr_screen_info->outputs[i];
743 if (screendata->is_primary ==
false) {
744 if (screendata->is_primary || screendata->is_extended) {
745 randr_screen_info->cur_output->auto_set = 1;
746 randr_screen_info->cur_output->off_set = 0;
747 output_auto (randr_screen_info, randr_screen_info->cur_output);
748 j=main_low_apply(randr_screen_info);
751 randr_screen_info->cur_output->auto_set = 0;
752 randr_screen_info->cur_output->off_set = 1;
753 output_off (randr_screen_info, randr_screen_info->cur_output);
754 j=main_low_apply(randr_screen_info);
758 freeScreenInfoStructure(randr_screen_info);
759 randr_screen_info = read_screen_info(randr_display);
760 for (i = 0; i < screenInfoArray.count(); i++) {
761 screendata = screenInfoArray.at(i);
762 output_info = randr_screen_info->outputs[i]->info;
764 if (screendata->is_primary || screendata->is_extended) {
766 RandRScreen *cur_screen =
new RandRScreen(i);
767 cur_screen->proposeSize(screendata->current_resolution_index);
768 cur_screen->proposeRefreshRate(screendata->current_refresh_rate_index);
769 cur_screen->proposeRotation(getHardwareRotationFlags(screendata));
770 cur_screen->applyProposed();
774 randr_screen_info = read_screen_info(randr_display);
775 output_info = randr_screen_info->outputs[i]->info;
778 randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc;
779 if (randr_screen_info->cur_crtc) {
780 randr_screen_info->cur_crtc->cur_x = screendata->absolute_x_position;
781 randr_screen_info->cur_crtc->cur_y = screendata->absolute_y_position;
782 j=main_low_apply(randr_screen_info);
786 freeScreenInfoStructure(randr_screen_info);
790 applyDisplayGamma(screenInfoArray);
791 applyDisplayDPMS(screenInfoArray);
792 TQString current_icc_profile = getCurrentProfile();
793 applySystemWideIccConfiguration(kde_confdir);
794 applyIccConfiguration(current_icc_profile, kde_confdir);
797 int ret = showTestConfigurationDialog();
799 applyDisplayConfiguration(oldconfig, FALSE, kde_confdir);
802 destroyScreenInformationObject(oldconfig);
808 TQPtrList<SingleScreenData> KRandrSimpleAPI::copyScreenInformationObject(TQPtrList<SingleScreenData> screenInfoArray) {
809 SingleScreenData *origscreendata;
810 SingleScreenData *copyscreendata;
811 TQPtrList<SingleScreenData> retArray;
812 for ( origscreendata = screenInfoArray.first(); origscreendata; origscreendata = screenInfoArray.next() ) {
813 copyscreendata =
new SingleScreenData;
814 *copyscreendata = *origscreendata;
815 retArray.append(copyscreendata);
820 void KRandrSimpleAPI::destroyScreenInformationObject(TQPtrList<SingleScreenData> screenInfoArray) {
821 SingleScreenData *screendata;
822 for ( screendata = screenInfoArray.first(); screendata; screendata = screenInfoArray.next() ) {
823 screenInfoArray.remove(screendata);
828 void KRandrSimpleAPI::ensureMonitorDataConsistency(TQPtrList<SingleScreenData> screenInfoArray) {
830 SingleScreenData *screendata;
832 int numberOfScreens = screenInfoArray.count();
834 for (i=0;i<numberOfScreens;i++) {
835 screendata = screenInfoArray.at(i);
836 if (!screendata->screen_connected) {
837 screendata->is_primary =
false;
838 screendata->is_extended =
false;
842 bool has_primary_monitor =
false;
843 for (i=0;i<numberOfScreens;i++) {
844 screendata = screenInfoArray.at(i);
845 if (screendata->is_primary) {
846 has_primary_monitor =
true;
849 if (!has_primary_monitor) {
850 for (i=0;i<numberOfScreens;i++) {
851 screendata = screenInfoArray.at(i);
852 if (!has_primary_monitor) {
853 if (screendata->screen_connected && screendata->is_extended) {
854 screendata->is_primary =
true;
855 screendata->is_extended =
true;
856 has_primary_monitor =
true;
861 if (!has_primary_monitor) {
862 for (i=0;i<numberOfScreens;i++) {
863 screendata = screenInfoArray.at(i);
864 if (!has_primary_monitor) {
865 if (screendata->screen_connected) {
866 screendata->is_primary =
true;
867 screendata->is_extended =
true;
868 has_primary_monitor =
true;
874 bool found_first_primary_monitor =
false;
875 for (i=0;i<numberOfScreens;i++) {
876 screendata = screenInfoArray.at(i);
877 if (screendata->is_primary) {
878 if (!found_first_primary_monitor) {
879 found_first_primary_monitor =
true;
882 screendata->is_primary =
false;
887 for (i=0;i<numberOfScreens;i++) {
888 screendata = screenInfoArray.at(i);
889 if (screendata->is_primary) {
890 screendata->is_extended =
true;
894 for (i=0;i<numberOfScreens;i++) {
895 screendata = screenInfoArray.at(i);
896 TQString resolutionstring = screendata->resolutions[screendata->current_resolution_index];
897 int separator_pos = resolutionstring.find(
" x ");
898 TQString x_res_string = resolutionstring.left(separator_pos);
899 TQString y_res_string = resolutionstring.right(resolutionstring.length()-separator_pos-3);
900 screendata->current_x_pixel_count = x_res_string.toInt();
901 screendata->current_y_pixel_count = y_res_string.toInt();
902 screendata->current_orientation_mask = getHardwareRotationFlags(screendata);
907 int primary_offset_x = 0;
908 int primary_offset_y = 0;
909 for (i=0;i<numberOfScreens;i++) {
910 screendata = screenInfoArray.at(i);
911 if (screendata->is_primary) {
912 primary_offset_x = screendata->absolute_x_position;
913 primary_offset_y = screendata->absolute_y_position;
914 primary_offset_x = primary_offset_x * (-1);
915 primary_offset_y = primary_offset_y * (-1);
918 for (i=0;i<numberOfScreens;i++) {
919 screendata = screenInfoArray.at(i);
920 screendata->absolute_x_position = screendata->absolute_x_position + primary_offset_x;
921 screendata->absolute_y_position = screendata->absolute_y_position + primary_offset_y;
925 TQPoint KRandrSimpleAPI::primaryScreenOffsetFromTLC(TQPtrList<SingleScreenData> screenInfoArray) {
927 SingleScreenData *screendata;
928 int numberOfScreens = screenInfoArray.count();
930 int primary_offset_x = 0;
931 int primary_offset_y = 0;
932 for (i=0;i<numberOfScreens;i++) {
933 screendata = screenInfoArray.at(i);
934 if (screendata->absolute_x_position < primary_offset_x) {
935 primary_offset_x = screendata->absolute_x_position;
937 if (screendata->absolute_y_position < primary_offset_y) {
938 primary_offset_y = screendata->absolute_y_position;
941 primary_offset_x = primary_offset_x * (-1);
942 primary_offset_y = primary_offset_y * (-1);
944 return TQPoint(primary_offset_x, primary_offset_y);
947 HotPlugRulesList KRandrSimpleAPI::getHotplugRules(TQString kde_confdir) {
950 HotPlugRulesList ret;
952 filename =
"displayglobals";
953 filename.prepend(kde_confdir.append(
"/"));
956 TQStringList grouplist = display_config->
groupList();
957 for ( TQStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) {
958 if (!(*it).startsWith(
"Hotplug-Rule")) {
962 display_config->setGroup(*it);
963 rule.outputs = display_config->readListEntry(
"Outputs");
964 rule.states = display_config->readIntListEntry(
"States");
965 rule.profileName = display_config->readEntry(
"Profile");
968 delete display_config;
973 void KRandrSimpleAPI::saveHotplugRules(HotPlugRulesList rules, TQString kde_confdir) {
977 filename =
"displayglobals";
978 filename.prepend(kde_confdir.append(
"/"));
980 TQStringList grouplist = display_config->
groupList();
981 for ( TQStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) {
982 if (!(*it).startsWith(
"Hotplug-Rule")) {
985 display_config->deleteGroup(*it,
true,
false);
987 HotPlugRulesList::Iterator it;
989 for (it=rules.begin(); it != rules.end(); ++it) {
990 display_config->setGroup(TQString(
"Hotplug-Rule%1").arg(i));
991 display_config->writeEntry(
"Outputs", (*it).outputs);
992 display_config->writeEntry(
"States", (*it).states);
993 display_config->writeEntry(
"Profile", (*it).profileName);
996 display_config->
sync();
997 delete display_config;
1000 bool KRandrSimpleAPI::getDisplayConfigurationEnabled(TQString kde_confdir) {
1001 TQString filename =
"displayglobals";
1002 filename.prepend(kde_confdir.append(
"/"));
1004 display_config->setGroup(
"General");
1005 bool enabled = display_config->readBoolEntry(
"EnableDisplayControl",
false);
1006 delete display_config;
1011 bool KRandrSimpleAPI::getDisplayConfigurationStartupAutoApplyEnabled(TQString kde_confdir) {
1012 TQString filename =
"displayglobals";
1013 filename.prepend(kde_confdir.append(
"/"));
1015 display_config->setGroup(
"General");
1016 bool applyonstart = display_config->readBoolEntry(
"ApplySettingsOnStart",
false);
1017 delete display_config;
1019 return applyonstart;
1022 TQString KRandrSimpleAPI::getDisplayConfigurationStartupAutoApplyName(TQString kde_confdir) {
1023 TQString filename =
"displayglobals";
1024 filename.prepend(kde_confdir.append(
"/"));
1026 display_config->setGroup(
"General");
1027 TQString profilename = display_config->readEntry(
"StartupProfileName",
"");
1028 delete display_config;
1033 void KRandrSimpleAPI::applyHotplugRules(TQString kde_confdir) {
1034 bool enabled = getDisplayConfigurationEnabled(kde_confdir);
1039 HotPlugRulesList rules = getHotplugRules(kde_confdir);
1040 TQPtrList<SingleScreenData> screenInfoArray = readCurrentDisplayConfiguration();
1045 int bestRuleMatchCount = 0;
1046 SingleScreenData *screendata = NULL;
1047 HotPlugRulesList::Iterator it;
1048 for (it=rules.begin(); it != rules.end(); ++it) {
1051 HotPlugRule rule = *it;
1053 int numberOfScreens = screenInfoArray.count();
1054 for (i=0;i<numberOfScreens;i++) {
1055 screendata = screenInfoArray.at(i);
1056 for (j=0; j<(*it).outputs.count(); j++) {
1057 if ((*it).outputs[j] != screendata->screenUniqueName) {
1060 if ((*it).states[j] == HotPlugRule::Connected) {
1061 if (screendata->screen_connected) {
1065 else if ((*it).states[j] == HotPlugRule::Disconnected) {
1066 if (!screendata->screen_connected) {
1073 if (matchCount > bestRuleMatchCount) {
1074 bestRuleMatchCount = matchCount;
1075 bestRule = rule.profileName;
1079 destroyScreenInformationObject(screenInfoArray);
1081 if (bestRuleMatchCount > 0) {
1084 applyDisplayConfiguration(bestRule, kde_confdir);
1088 void KRandrSimpleAPI::applyDisplayGamma(TQPtrList<SingleScreenData> screenInfoArray) {
1090 Display *randr_display;
1091 XRROutputInfo *output_info;
1092 ScreenInfo *randr_screen_info;
1093 XRRCrtcGamma *gamma;
1095 SingleScreenData *screendata;
1097 if (isValid() ==
true) {
1098 randr_display = tqt_xdisplay();
1099 randr_screen_info = read_screen_info(randr_display);
1100 for (i = 0; i < screenInfoArray.count(); i++) {
1101 screendata = screenInfoArray.at(i);
1102 output_info = randr_screen_info->outputs[i]->info;
1103 CrtcInfo *current_crtc = randr_screen_info->outputs[i]->cur_crtc;
1104 if (!current_crtc) {
1108 int size = XRRGetCrtcGammaSize(randr_display, current_crtc->id);
1112 gamma = XRRAllocGamma(size);
1116 for (i = 0; i < size; i++) {
1117 if (screendata->gamma_red == 1.0)
1118 gamma->red[i] = i << 8;
1120 gamma->red[i] = (pow((
double)i/(
double)(size-1), (
double)screendata->gamma_red) * (double)(size-1)*256);
1122 if (screendata->gamma_green == 1.0)
1123 gamma->green[i] = i << 8;
1125 gamma->green[i] = (pow((
double)i/(
double)(size-1), (
double)screendata->gamma_green) * (double)(size-1)*256);
1127 if (screendata->gamma_blue == 1.0)
1128 gamma->blue[i] = i << 8;
1130 gamma->blue[i] = (pow((
double)i/(
double)(size-1), (
double)screendata->gamma_blue) * (double)(size-1)*256);
1132 XRRSetCrtcGamma(randr_display, current_crtc->id, gamma);
1136 freeScreenInfoStructure(randr_screen_info);
1140 void KRandrSimpleAPI::applyDisplayDPMS(TQPtrList<SingleScreenData> screenInfoArray) {
1142 Display *randr_display;
1143 XRROutputInfo *output_info;
1144 ScreenInfo *randr_screen_info;
1145 XRRCrtcGamma *gamma;
1147 SingleScreenData *screendata;
1149 if (isValid() ==
true) {
1150 randr_display = tqt_xdisplay();
1151 randr_screen_info = read_screen_info(randr_display);
1152 for (i = 0; i < screenInfoArray.count(); i++) {
1153 screendata = screenInfoArray.at(i);
1154 output_info = randr_screen_info->outputs[i]->info;
1155 CrtcInfo *current_crtc = randr_screen_info->outputs[i]->cur_crtc;
1156 if (!current_crtc) {
1159 if (!screendata->has_dpms) {
1162 if (screendata->enable_dpms) {
1163 DPMSSetTimeouts(randr_display, screendata->dpms_standby_delay, screendata->dpms_suspend_delay, screendata->dpms_off_delay);
1164 DPMSEnable(randr_display);
1167 DPMSDisable(randr_display);
1170 freeScreenInfoStructure(randr_screen_info);
1174 void KRandrSimpleAPI::freeScreenInfoStructure(ScreenInfo* screen_info) {
1177 for (i=0; i<screen_info->n_crtc; i++) {
1178 free(screen_info->crtcs[i]);
1180 for (i=0; i<screen_info->n_output; i++) {
1181 free(screen_info->outputs[i]);
1183 free(screen_info->outputs);
1184 free(screen_info->crtcs);
1188 TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
1193 XRROutputInfo *output_info;
1194 SingleScreenData *screendata;
1195 TQPtrList<SingleScreenData> screenInfoArray;
1197 Display *randr_display;
1198 ScreenInfo *randr_screen_info;
1201 destroyScreenInformationObject(screenInfoArray);
1203 int numberOfScreens = 0;
1204 if (isValid() ==
true) {
1205 randr_display = tqt_xdisplay();
1206 randr_screen_info = read_screen_info(randr_display);
1207 for (i = 0; i < randr_screen_info->n_output; i++) {
1208 output_info = randr_screen_info->outputs[i]->info;
1209 CrtcInfo *current_crtc = randr_screen_info->outputs[i]->cur_crtc;
1212 screendata =
new SingleScreenData;
1213 screenInfoArray.append(screendata);
1214 screendata->screenUniqueName = TQString(i18n(
"%1:%2")).arg(
":0").arg(capitalizeString(output_info->name));
1215 screendata->screenFriendlyName = TQString(i18n(
"%1. %2 output on %3")).arg(i+1).arg(capitalizeString(output_info->name)).arg(
":0");
1216 screendata->generic_screen_detected =
false;
1219 TQString edid = getEDIDMonitorName(0, output_info->name);
1220 if (!edid.isNull()) {
1221 screendata->screenFriendlyName = TQString(i18n(
"%1. %2 on %3 on card %4")).arg(i+1).arg(edid).arg(capitalizeString(output_info->name)).arg(
"0");
1226 RandRScreen *cur_screen = 0;
1227 if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) {
1229 screen_active =
false;
1232 if (randr_screen_info->outputs[i]->cur_crtc) {
1234 screen_active =
true;
1235 cur_screen =
new RandRScreen(i);
1239 screen_active =
false;
1240 cur_screen =
new RandRScreen(i);
1245 screendata->has_dpms = 1;
1246 if (screendata->has_dpms) {
1247 CARD16 dpms_standby_delay;
1248 CARD16 dpms_suspend_delay;
1249 CARD16 dpms_off_delay;
1250 screendata->has_dpms = DPMSGetTimeouts(randr_display, &dpms_standby_delay, &dpms_suspend_delay, &dpms_off_delay);
1251 screendata->dpms_standby_delay = dpms_standby_delay;
1252 screendata->dpms_suspend_delay = dpms_suspend_delay;
1253 screendata->dpms_off_delay = dpms_off_delay;
1254 if (screendata->has_dpms) {
1257 screendata->has_dpms = DPMSInfo(randr_display, &power_level, &enable_dpms);
1258 screendata->enable_dpms = enable_dpms;
1261 if (!screendata->has_dpms) {
1262 screendata->enable_dpms =
false;
1263 screendata->dpms_standby_delay = 0;
1264 screendata->dpms_suspend_delay = 0;
1265 screendata->dpms_off_delay = 0;
1269 screendata->screen_connected =
true;
1270 for (
int j = 0; j < cur_screen->numSizes(); j++) {
1271 screendata->resolutions.append(i18n(
"%1 x %2").arg(cur_screen->pixelSize(j).width()).arg(cur_screen->pixelSize(j).height()));
1273 screendata->current_resolution_index = 0;
1275 screendata->current_resolution_index = screendata->resolutions.findIndex(i18n(
"%1 x %2").arg(current_crtc->info->width).arg(current_crtc->info->height));
1277 if (screendata->current_resolution_index < 0) {
1278 screendata->current_resolution_index = cur_screen->proposedSize();
1282 TQStringList rr = cur_screen->refreshRates(screendata->current_resolution_index);
1283 for (TQStringList::Iterator it = rr.begin(); it != rr.end(); ++it) {
1284 screendata->refresh_rates.append(*it);
1286 screendata->current_refresh_rate_index = cur_screen->proposedRefreshRate();
1290 screendata->color_depths.append(i18n(
"Default"));
1291 screendata->current_color_depth_index = 0;
1301 screendata->rotations.append(i18n(ROTATION_0_DEGREES_STRING));
1302 screendata->rotations.append(i18n(ROTATION_90_DEGREES_STRING));
1303 screendata->rotations.append(i18n(ROTATION_180_DEGREES_STRING));
1304 screendata->rotations.append(i18n(ROTATION_270_DEGREES_STRING));
1305 screendata->supports_transformations = (cur_screen->rotations() != RandRScreen::Rotate0);
1306 if (screendata->supports_transformations) {
1307 screendata->current_orientation_mask = cur_screen->proposedRotation();
1308 switch (screendata->current_orientation_mask & RandRScreen::RotateMask) {
1309 case RandRScreen::Rotate0:
1310 screendata->current_rotation_index = 0;
1312 case RandRScreen::Rotate90:
1313 screendata->current_rotation_index = 1;
1315 case RandRScreen::Rotate180:
1316 screendata->current_rotation_index = 2;
1318 case RandRScreen::Rotate270:
1319 screendata->current_rotation_index = 3;
1323 Q_ASSERT(screendata->current_orientation_mask & RandRScreen::RotateMask);
1324 screendata->current_rotation_index = 0;
1327 screendata->has_x_flip = (screendata->current_orientation_mask & RandRScreen::ReflectX);
1328 screendata->has_y_flip = (screendata->current_orientation_mask & RandRScreen::ReflectY);
1331 screendata->has_x_flip =
false;
1332 screendata->has_y_flip =
false;
1333 screendata->current_rotation_index = 0;
1337 RROutput primaryoutput = XRRGetOutputPrimary(tqt_xdisplay(), DefaultRootWindow(tqt_xdisplay()));
1338 if (primaryoutput == randr_screen_info->outputs[i]->id) {
1339 screendata->is_primary =
false;
1342 screendata->is_primary =
true;
1344 screendata->is_extended = screen_active;
1345 if (!screendata->is_extended) {
1346 screendata->is_primary =
false;
1350 screendata->absolute_x_position = 0;
1351 screendata->absolute_y_position = 0;
1353 screendata->absolute_x_position = current_crtc->info->x;
1354 screendata->absolute_y_position = current_crtc->info->y;
1358 screendata->current_x_pixel_count = cur_screen->pixelSize(screendata->current_resolution_index).width();
1359 screendata->current_y_pixel_count = cur_screen->pixelSize(screendata->current_resolution_index).height();
1370 int size = XRRGetCrtcGammaSize(randr_display, current_crtc->id);
1371 XRRCrtcGamma *gammastruct = XRRGetCrtcGamma (randr_display, current_crtc->id);
1372 screendata->gamma_red = log(gammastruct->red[slot]/((size-1.0)*256.0))/log(slot/(size-1.0));
1373 screendata->gamma_green = log(gammastruct->green[slot]/((size-1.0)*256.0))/log(slot/(size-1.0));
1374 screendata->gamma_blue = log(gammastruct->blue[slot]/((size-1.0)*256.0))/log(slot/(size-1.0));
1377 screendata->gamma_red = 2.2;
1378 screendata->gamma_green = 2.2;
1379 screendata->gamma_blue = 2.2;
1382 screendata->gamma_red = floorf(screendata->gamma_red * 10 + 0.5) / 10;
1383 screendata->gamma_green = floorf(screendata->gamma_green * 10 + 0.5) / 10;
1384 screendata->gamma_blue = floorf(screendata->gamma_blue * 10 + 0.5) / 10;
1390 screendata->screenFriendlyName = screendata->screenFriendlyName + TQString(
" (") + i18n(
"disconnected") + TQString(
")");
1391 screendata->screen_connected =
false;
1393 screendata->resolutions = i18n(
"Default");
1394 screendata->refresh_rates = i18n(
"Default");
1395 screendata->color_depths = i18n(
"Default");
1396 screendata->rotations = i18n(
"N/A");
1398 screendata->current_resolution_index = 0;
1399 screendata->current_refresh_rate_index = 0;
1400 screendata->current_color_depth_index = 0;
1402 screendata->gamma_red = 2.2;
1403 screendata->gamma_green = 2.2;
1404 screendata->gamma_blue = 2.2;
1406 screendata->current_rotation_index = 0;
1407 screendata->current_orientation_mask = 0;
1408 screendata->has_x_flip =
false;
1409 screendata->has_y_flip =
false;
1410 screendata->supports_transformations =
false;
1412 screendata->is_primary =
false;
1413 screendata->is_extended =
false;
1414 screendata->absolute_x_position = 0;
1415 screendata->absolute_y_position = 0;
1416 screendata->current_x_pixel_count = 640;
1417 screendata->current_y_pixel_count = 480;
1424 freeScreenInfoStructure(randr_screen_info);
1427 screendata =
new SingleScreenData;
1428 screenInfoArray.append(screendata);
1431 screendata->screenFriendlyName = i18n(
"Default output on generic video card");
1432 screendata->generic_screen_detected =
true;
1433 screendata->screen_connected =
true;
1435 screendata->resolutions = i18n(
"Default");
1436 screendata->refresh_rates = i18n(
"Default");
1437 screendata->color_depths = i18n(
"Default");
1438 screendata->rotations = i18n(
"N/A");
1440 screendata->current_resolution_index = 0;
1441 screendata->current_refresh_rate_index = 0;
1442 screendata->current_color_depth_index = 0;
1444 screendata->gamma_red = 2.2;
1445 screendata->gamma_green = 2.2;
1446 screendata->gamma_blue = 2.2;
1448 screendata->current_rotation_index = 0;
1449 screendata->current_orientation_mask = 0;
1450 screendata->has_x_flip =
false;
1451 screendata->has_y_flip =
false;
1452 screendata->supports_transformations =
false;
1454 screendata->is_primary =
true;
1455 screendata->is_extended =
true;
1456 screendata->absolute_x_position = 0;
1457 screendata->absolute_y_position = 0;
1458 screendata->current_x_pixel_count = 640;
1459 screendata->current_y_pixel_count = 480;
1464 bool primary_set =
false;
1465 for ( screendata=screenInfoArray.first(); screendata; screendata=screenInfoArray.next() ) {
1466 if (screendata->is_primary) {
1472 Q_ASSERT(primary_set);
1476 screendata = screenInfoArray.at(0);
1477 screendata->is_primary =
true;
1480 return screenInfoArray;
1483 TQString KRandrSimpleAPI::clearIccConfiguration() {
1485 TQString icc_command;
1487 char xcalib_result[2048];
1491 icc_command = TQString(
"xcalib -c");
1492 if ((pipe_xcalib = popen(icc_command.ascii(),
"r")) == NULL)
1494 printf(
"Xcalib pipe error [xcalib clear]\n");
1497 if (fgets(xcalib_result, 2048, pipe_xcalib)) {
1498 pclose(pipe_xcalib);
1499 for (i=1;i<2048;i++) {
1500 if (xcalib_result[i] == 0) {
1501 xcalib_result[i-1]=0;
1505 if (strlen(xcalib_result) > 2) {
1506 return xcalib_result;
1516 ScreenInfo* KRandrSimpleAPI::read_screen_info (Display *display)
1518 return internal_read_screen_info(display);
1521 int KRandrSimpleAPI::set_screen_size (ScreenInfo *screen_info)
1523 return internal_set_screen_size(screen_info);
1526 void KRandrSimpleAPI::output_auto (ScreenInfo *screen_info, OutputInfo *output_info)
1528 internal_output_auto (screen_info, output_info);
1531 void KRandrSimpleAPI::output_off(ScreenInfo *screen_info, OutputInfo *output)
1533 internal_output_off(screen_info, output);
1536 CrtcInfo* KRandrSimpleAPI::auto_find_crtc (ScreenInfo *screen_info, OutputInfo *output_info)
1538 return internal_auto_find_crtc (screen_info, output_info);
1541 XRRModeInfo *KRandrSimpleAPI::find_mode_by_xid (ScreenInfo *screen_info, RRMode mode_id)
1543 return internal_find_mode_by_xid (screen_info, mode_id);
1546 int KRandrSimpleAPI::mode_height (XRRModeInfo *mode_info, Rotation rotation)
1548 return internal_mode_height (mode_info, rotation);
1551 int KRandrSimpleAPI::mode_width (XRRModeInfo *mode_info, Rotation rotation)
1553 return internal_mode_width (mode_info, rotation);
1556 int KRandrSimpleAPI::get_width_by_output_id (ScreenInfo *screen_info, RROutput output_id)
1558 return internal_get_width_by_output_id (screen_info, output_id);
1561 int KRandrSimpleAPI::get_height_by_output_id (ScreenInfo *screen_info, RROutput output_id)
1563 return internal_get_height_by_output_id (screen_info, output_id);
1566 char *KRandrSimpleAPI::get_output_name (ScreenInfo *screen_info, RROutput
id)
1568 return internal_get_output_name (screen_info,
id);
1571 Status KRandrSimpleAPI::crtc_apply (CrtcInfo *crtc_info)
1573 return internal_crtc_apply (crtc_info);
1576 Status KRandrSimpleAPI::crtc_disable (CrtcInfo *crtc)
1578 return internal_crtc_disable (crtc);
1581 int KRandrSimpleAPI::main_low_apply (ScreenInfo *screen_info)
1583 return internal_main_low_apply (screen_info);
1586 void KRandrSimpleAPI::set_primary_output (ScreenInfo *screen_info, RROutput output_id)
1588 internal_output_set_primary(screen_info, output_id);
1591 bool KRandrSimpleAPI::kRandrHasRandr(
void)
1596 const char *KRandrSimpleAPI::kRandrVersion(
void)
1601 const char *KRandrSimpleAPI::kRandrCopyright(
void)
1603 return "LibKRandr 0.9.5 (C)2010 Timothy Pearson <kb9vqf@pearsoncomputing.net>. U.S.A.";
1611 const char *kRandrVersion(
void)
1613 return KRandrSimpleAPI::kRandrVersion();
1616 const char *kRandrCopyright(
void)
1618 return KRandrSimpleAPI::kRandrCopyright();