@ -177,7 +177,7 @@ TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
icc_command = TQString ( " xcalib \" %1 \" " ) . arg ( fileName ) ;
icc_command = TQString ( " xcalib \" %1 \" " ) . arg ( fileName ) ;
if ( ( pipe_xcalib = popen ( icc_command . ascii ( ) , " r " ) ) = = NULL )
if ( ( pipe_xcalib = popen ( icc_command . ascii ( ) , " r " ) ) = = NULL )
{
{
printf ( " Xcalib pipe error \n \r ") ;
printf ( " Xcalib pipe error \n \r [xcalib apply] ") ;
}
}
else {
else {
if ( fgets ( xcalib_result , 2048 , pipe_xcalib ) ) {
if ( fgets ( xcalib_result , 2048 , pipe_xcalib ) ) {
@ -193,7 +193,7 @@ TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
}
}
}
}
else {
else {
printf ( " Xcalib pipe error \n \r " ) ;
return " " ;
}
}
}
}
}
}
@ -246,7 +246,7 @@ TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
icc_command = TQString ( " xcalib -c " ) ;
icc_command = TQString ( " xcalib -c " ) ;
if ( ( pipe_xcalib = popen ( icc_command . ascii ( ) , " r " ) ) = = NULL )
if ( ( pipe_xcalib = popen ( icc_command . ascii ( ) , " r " ) ) = = NULL )
{
{
printf ( " Xcalib pipe error \n \r ") ;
printf ( " Xcalib pipe error \n \r [xcalib clear] ") ;
}
}
else {
else {
if ( fgets ( xcalib_result , 2048 , pipe_xcalib ) ) {
if ( fgets ( xcalib_result , 2048 , pipe_xcalib ) ) {
@ -262,7 +262,7 @@ TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
}
}
}
}
else {
else {
printf ( " Xcalib pipe error \n \r " ) ;
return " " ;
}
}
}
}
}
}
@ -401,7 +401,7 @@ TQString KRandrSimpleAPI::applySystemWideIccConfiguration(TQString kde_confdir)
icc_command = TQString ( " xcalib \" %1 \" " ) . arg ( getIccFileName ( NULL , " Default " , kde_confdir ) ) ;
icc_command = TQString ( " xcalib \" %1 \" " ) . arg ( getIccFileName ( NULL , " Default " , kde_confdir ) ) ;
if ( ( pipe_xcalib = popen ( icc_command . ascii ( ) , " r " ) ) = = NULL )
if ( ( pipe_xcalib = popen ( icc_command . ascii ( ) , " r " ) ) = = NULL )
{
{
printf ( " Xcalib pipe error \n \r " ) ;
printf ( " Xcalib pipe error [xcalib apply] \n \r " ) ;
}
}
else {
else {
if ( fgets ( xcalib_result , 2048 , pipe_xcalib ) ) {
if ( fgets ( xcalib_result , 2048 , pipe_xcalib ) ) {
@ -417,7 +417,7 @@ TQString KRandrSimpleAPI::applySystemWideIccConfiguration(TQString kde_confdir)
}
}
}
}
else {
else {
printf ( " Xcalib pipe error \n \r " ) ;
return " " ;
}
}
}
}
return " " ;
return " " ;
@ -569,16 +569,16 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::loadSystemwideDisplayConfiguration(
int KRandrSimpleAPI : : getHardwareRotationFlags ( SingleScreenData * screendata ) {
int KRandrSimpleAPI : : getHardwareRotationFlags ( SingleScreenData * screendata ) {
int rotationFlags = 0 ;
int rotationFlags = 0 ;
TQString rotationDesired = * screendata - > rotations . at ( screendata - > current_rotation_index ) ;
TQString rotationDesired = * screendata - > rotations . at ( screendata - > current_rotation_index ) ;
if ( rotationDesired = = " Normal " ) {
if ( rotationDesired = = ROTATION_0_DEGREES_STRING ) {
rotationFlags = rotationFlags | RandRScreen : : Rotate0 ;
rotationFlags = rotationFlags | RandRScreen : : Rotate0 ;
}
}
else if ( rotationDesired = = " Rotate 90 degrees " ) {
else if ( rotationDesired = = ROTATION_90_DEGREES_STRING ) {
rotationFlags = rotationFlags | RandRScreen : : Rotate90 ;
rotationFlags = rotationFlags | RandRScreen : : Rotate90 ;
}
}
else if ( rotationDesired = = " Rotate 180 degrees " ) {
else if ( rotationDesired = = ROTATION_180_DEGREES_STRING ) {
rotationFlags = rotationFlags | RandRScreen : : Rotate180 ;
rotationFlags = rotationFlags | RandRScreen : : Rotate180 ;
}
}
else if ( rotationDesired = = " Rotate 270 degrees " ) {
else if ( rotationDesired = = ROTATION_270_DEGREES_STRING ) {
rotationFlags = rotationFlags | RandRScreen : : Rotate270 ;
rotationFlags = rotationFlags | RandRScreen : : Rotate270 ;
}
}
if ( screendata - > has_x_flip ) {
if ( screendata - > has_x_flip ) {
@ -658,21 +658,6 @@ bool KRandrSimpleAPI::applySystemwideDisplayConfiguration(TQPtrList<SingleScreen
return accepted ;
return accepted ;
}
}
}
}
// HACK
// This is needed because Qt does not properly generate screen
// resize events when switching screens, so KDE gets stuck in the old resolution
// This only seems to happen with more than one screen, so check for that condition...
// FIXME: This also only occurs when the primary display has been changed
// FIXME: Check for that condition as well!
if ( kapp - > desktop ( ) - > numScreens ( ) > 1 ) {
for ( i = 0 ; i < screenInfoArray . count ( ) ; i + + ) {
screendata = screenInfoArray . at ( i ) ;
if ( screendata - > is_primary = = true ) {
kapp - > desktop ( ) - > emitResizedSignal ( i ) ;
}
}
}
# else
# else
randr_display = tqt_xdisplay ( ) ;
randr_display = tqt_xdisplay ( ) ;
randr_screen_info = read_screen_info ( randr_display ) ;
randr_screen_info = read_screen_info ( randr_display ) ;
@ -804,8 +789,9 @@ void KRandrSimpleAPI::ensureMonitorDataConsistency(TQPtrList<SingleScreenData> s
bool has_primary_monitor = false ;
bool has_primary_monitor = false ;
for ( i = 0 ; i < numberOfScreens ; i + + ) {
for ( i = 0 ; i < numberOfScreens ; i + + ) {
screendata = screenInfoArray . at ( i ) ;
screendata = screenInfoArray . at ( i ) ;
if ( screendata - > is_primary )
if ( screendata - > is_primary ) {
has_primary_monitor = true ;
has_primary_monitor = true ;
}
}
}
if ( ! has_primary_monitor ) {
if ( ! has_primary_monitor ) {
for ( i = 0 ; i < numberOfScreens ; i + + ) {
for ( i = 0 ; i < numberOfScreens ; i + + ) {
@ -1117,10 +1103,10 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
// RandRScreen::ReflectX
// RandRScreen::ReflectX
// RandRScreen::ReflectY
// RandRScreen::ReflectY
screendata - > rotations . append ( i18n ( " Normal " ) ) ;
screendata - > rotations . append ( i18n ( ROTATION_0_DEGREES_STRING ) ) ;
screendata - > rotations . append ( i18n ( " Rotate 90 degrees " ) ) ;
screendata - > rotations . append ( i18n ( ROTATION_90_DEGREES_STRING ) ) ;
screendata - > rotations . append ( i18n ( " Rotate 180 degrees " ) ) ;
screendata - > rotations . append ( i18n ( ROTATION_180_DEGREES_STRING ) ) ;
screendata - > rotations . append ( i18n ( " Rotate 270 degrees " ) ) ;
screendata - > rotations . append ( i18n ( ROTATION_270_DEGREES_STRING ) ) ;
screendata - > supports_transformations = ( cur_screen - > rotations ( ) ! = RandRScreen : : Rotate0 ) ;
screendata - > supports_transformations = ( cur_screen - > rotations ( ) ! = RandRScreen : : Rotate0 ) ;
if ( screendata - > supports_transformations ) {
if ( screendata - > supports_transformations ) {
screendata - > current_orientation_mask = cur_screen - > proposedRotation ( ) ;
screendata - > current_orientation_mask = cur_screen - > proposedRotation ( ) ;
@ -1154,13 +1140,16 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
// Determine if this display is primary and/or extended
// Determine if this display is primary and/or extended
RROutput primaryoutput = XRRGetOutputPrimary ( tqt_xdisplay ( ) , DefaultRootWindow ( tqt_xdisplay ( ) ) ) ;
RROutput primaryoutput = XRRGetOutputPrimary ( tqt_xdisplay ( ) , DefaultRootWindow ( tqt_xdisplay ( ) ) ) ;
if ( primaryoutput = = randr_screen_info - > outputs [ i ] - > id )
if ( primaryoutput = = randr_screen_info - > outputs [ i ] - > id ) {
screendata - > is_primary = false ;
screendata - > is_primary = false ;
else
}
else {
screendata - > is_primary = true ;
screendata - > is_primary = true ;
}
screendata - > is_extended = screen_active ;
screendata - > is_extended = screen_active ;
if ( ! screendata - > is_extended )
if ( ! screendata - > is_extended ) {
screendata - > is_primary = false ;
screendata - > is_primary = false ;
}
// Get this screen's absolute position
// Get this screen's absolute position
screendata - > absolute_x_position = 0 ;
screendata - > absolute_x_position = 0 ;
@ -1277,10 +1266,21 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
numberOfScreens + + ;
numberOfScreens + + ;
}
}
// [FIXME]
bool primary_set = false ;
// Set this on the real primary monitor only!
for ( screendata = screenInfoArray . first ( ) ; screendata ; screendata = screenInfoArray . next ( ) ) {
screendata = screenInfoArray . at ( 0 ) ;
if ( screendata - > is_primary ) {
screendata - > is_primary = true ;
primary_set = true ;
break ;
}
}
// If there is no primary monitor set, xrandr is probably not functioning correctly!
Q_ASSERT ( primary_set ) ;
if ( ! primary_set ) {
// [FIXME]
// Set this on the real primary monitor only!
screendata = screenInfoArray . at ( 0 ) ;
screendata - > is_primary = true ;
}
return screenInfoArray ;
return screenInfoArray ;
}
}
@ -1296,7 +1296,7 @@ TQString KRandrSimpleAPI::clearIccConfiguration() {
icc_command = TQString ( " xcalib -c " ) ;
icc_command = TQString ( " xcalib -c " ) ;
if ( ( pipe_xcalib = popen ( icc_command . ascii ( ) , " r " ) ) = = NULL )
if ( ( pipe_xcalib = popen ( icc_command . ascii ( ) , " r " ) ) = = NULL )
{
{
printf ( " Xcalib pipe error \n \r " ) ;
printf ( " Xcalib pipe error [xcalib clear] \n \r " ) ;
}
}
else {
else {
if ( fgets ( xcalib_result , 2048 , pipe_xcalib ) ) {
if ( fgets ( xcalib_result , 2048 , pipe_xcalib ) ) {
@ -1312,7 +1312,7 @@ TQString KRandrSimpleAPI::clearIccConfiguration() {
}
}
}
}
else {
else {
printf ( " Xcalib pipe error \n \r " ) ;
return " " ;
}
}
}
}
return " " ;
return " " ;
@ -1388,6 +1388,11 @@ int KRandrSimpleAPI::main_low_apply (ScreenInfo *screen_info)
return internal_main_low_apply ( screen_info ) ;
return internal_main_low_apply ( screen_info ) ;
}
}
void KRandrSimpleAPI : : set_primary_output ( ScreenInfo * screen_info , RROutput output_id )
{
internal_output_set_primary ( screen_info , output_id ) ;
}
bool KRandrSimpleAPI : : kRandrHasRandr ( void )
bool KRandrSimpleAPI : : kRandrHasRandr ( void )
{
{
return isValid ( ) ;
return isValid ( ) ;