@ -416,6 +416,7 @@ TQPoint compressTQRectTouchingMonitorRegion(TQRect rect, MonitorRegion region, T
void KDisplayConfig : : updateDraggableMonitorInformation ( int monitor_id ) {
void KDisplayConfig : : updateDraggableMonitorInformation ( int monitor_id ) {
updateDraggableMonitorInformationInternal ( monitor_id , true ) ;
updateDraggableMonitorInformationInternal ( monitor_id , true ) ;
changed ( ) ;
}
}
void KDisplayConfig : : updateDraggableMonitorInformationInternal ( int monitor_id , bool recurse ) {
void KDisplayConfig : : updateDraggableMonitorInformationInternal ( int monitor_id , bool recurse ) {
@ -463,6 +464,7 @@ void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id,
j = i ;
j = i ;
}
}
monitors = base - > monitorPhyArrange - > childrenListObject ( ) ;
monitors = base - > monitorPhyArrange - > childrenListObject ( ) ;
primary_monitor = 0 ;
if ( monitors . count ( ) ) {
if ( monitors . count ( ) ) {
for ( i = 0 ; i < int ( monitors . count ( ) ) ; + + i ) {
for ( i = 0 ; i < int ( monitors . count ( ) ) ; + + i ) {
if ( : : tqqt_cast < DraggableMonitor * > ( TQT_TQWIDGET ( monitors . at ( i ) ) ) ) {
if ( : : tqqt_cast < DraggableMonitor * > ( TQT_TQWIDGET ( monitors . at ( i ) ) ) ) {
@ -473,23 +475,28 @@ void KDisplayConfig::updateDraggableMonitorInformationInternal (int monitor_id,
}
}
}
}
if ( moved_monitor ! = primary_monitor ) {
if ( primary_monitor ) {
// Run layout rules
if ( moved_monitor ! = primary_monitor ) {
applyMonitorLayoutRules ( moved_monitor ) ;
// Run layout rules
applyMonitorLayoutRules ( moved_monitor ) ;
int toffset_x = moved_monitor - > x ( ) - ( ( base - > monitorPhyArrange - > width ( ) / 2 ) - ( primary_monitor - > width ( ) / 2 ) ) ;
int toffset_x = moved_monitor - > x ( ) - ( ( base - > monitorPhyArrange - > width ( ) / 2 ) - ( primary_monitor - > width ( ) / 2 ) ) ;
int toffset_y = moved_monitor - > y ( ) - ( ( base - > monitorPhyArrange - > height ( ) / 2 ) - ( primary_monitor - > height ( ) / 2 ) ) ;
int toffset_y = moved_monitor - > y ( ) - ( ( base - > monitorPhyArrange - > height ( ) / 2 ) - ( primary_monitor - > height ( ) / 2 ) ) ;
int offset_x = toffset_x / base - > monitorPhyArrange - > resize_factor ;
int offset_x = toffset_x / base - > monitorPhyArrange - > resize_factor ;
int offset_y = toffset_y / base - > monitorPhyArrange - > resize_factor ;
int offset_y = toffset_y / base - > monitorPhyArrange - > resize_factor ;
screendata = m_screenInfoArray . at ( monitor_id ) ;
screendata = m_screenInfoArray . at ( monitor_id ) ;
screendata - > absolute_x_position = offset_x ;
screendata - > absolute_x_position = offset_x ;
screendata - > absolute_y_position = offset_y ;
screendata - > absolute_y_position = offset_y ;
}
else {
// Reset the position of the primary monitor
moveMonitor ( primary_monitor , 0 , 0 ) ;
}
}
}
else {
else {
// Reset the position of the primary monitor
printf ( " [WARNING] Display layout broken... \n \r " ) ; fflush ( stdout ) ;
moveMonitor ( primary_monitor , 0 , 0 ) ;
}
}
layoutDragDropDisplay ( ) ;
layoutDragDropDisplay ( ) ;
@ -672,6 +679,7 @@ KDisplayConfig::KDisplayConfig(TQWidget *parent, const char *name, const TQStrin
connect ( base - > systemEnableSupport , TQT_SIGNAL ( clicked ( ) ) , TQT_SLOT ( processLockoutControls ( ) ) ) ;
connect ( base - > systemEnableSupport , TQT_SIGNAL ( clicked ( ) ) , TQT_SLOT ( processLockoutControls ( ) ) ) ;
connect ( base - > monitorDisplaySelectDD , TQT_SIGNAL ( activated ( int ) ) , TQT_SLOT ( changed ( ) ) ) ;
connect ( base - > monitorDisplaySelectDD , TQT_SIGNAL ( activated ( int ) ) , TQT_SLOT ( changed ( ) ) ) ;
connect ( base - > rotationSelectDD , TQT_SIGNAL ( activated ( int ) ) , TQT_SLOT ( rotationInfoChanged ( ) ) ) ;
connect ( base - > rotationSelectDD , TQT_SIGNAL ( activated ( int ) ) , TQT_SLOT ( rotationInfoChanged ( ) ) ) ;
connect ( base - > refreshRateDD , TQT_SIGNAL ( activated ( int ) ) , TQT_SLOT ( refreshInfoChanged ( ) ) ) ;
connect ( base - > orientationHFlip , TQT_SIGNAL ( clicked ( ) ) , TQT_SLOT ( rotationInfoChanged ( ) ) ) ;
connect ( base - > orientationHFlip , TQT_SIGNAL ( clicked ( ) ) , TQT_SLOT ( rotationInfoChanged ( ) ) ) ;
connect ( base - > orientationVFlip , TQT_SIGNAL ( clicked ( ) ) , TQT_SLOT ( rotationInfoChanged ( ) ) ) ;
connect ( base - > orientationVFlip , TQT_SIGNAL ( clicked ( ) ) , TQT_SLOT ( rotationInfoChanged ( ) ) ) ;
connect ( base - > resolutionSlider , TQT_SIGNAL ( valueChanged ( int ) ) , TQT_SLOT ( resolutionSliderChanged ( int ) ) ) ;
connect ( base - > resolutionSlider , TQT_SIGNAL ( valueChanged ( int ) ) , TQT_SLOT ( resolutionSliderChanged ( int ) ) ) ;
@ -709,7 +717,7 @@ void KDisplayConfig::updateExtendedMonitorInformation () {
screendata = m_screenInfoArray . at ( base - > monitorDisplaySelectDD - > currentItem ( ) ) ;
screendata = m_screenInfoArray . at ( base - > monitorDisplaySelectDD - > currentItem ( ) ) ;
screendata - > is_extended = base - > isExtendedMonitorCB - > isChecked ( ) ;
screendata - > is_extended = base - > isExtendedMonitorCB - > isChecked ( ) ;
update DisplayedInformation( ) ;
refresh DisplayedInformation( ) ;
}
}
void KDisplayConfig : : deleteProfile ( ) {
void KDisplayConfig : : deleteProfile ( ) {
@ -744,6 +752,7 @@ void KDisplayConfig::selectScreen (int slotNumber) {
void KDisplayConfig : : updateArray ( void ) {
void KDisplayConfig : : updateArray ( void ) {
m_screenInfoArray = m_randrsimple - > readCurrentDisplayConfiguration ( ) ;
m_screenInfoArray = m_randrsimple - > readCurrentDisplayConfiguration ( ) ;
m_randrsimple - > ensureMonitorDataConsistency ( m_screenInfoArray ) ;
numberOfScreens = m_screenInfoArray . count ( ) ;
numberOfScreens = m_screenInfoArray . count ( ) ;
}
}
@ -768,7 +777,7 @@ void KDisplayConfig::updateDisplayedInformation () {
// Update the resolutions for the selected screen
// Update the resolutions for the selected screen
base - > resolutionSlider - > blockSignals ( true ) ;
base - > resolutionSlider - > blockSignals ( true ) ;
base - > resolutionSlider - > setMaxValue ( screendata - > re fresh_rates. count ( ) ) ;
base - > resolutionSlider - > setMaxValue ( screendata - > re solutions. count ( ) - 1 ) ;
setRealResolutionSliderValue ( screendata - > current_resolution_index ) ;
setRealResolutionSliderValue ( screendata - > current_resolution_index ) ;
resolutionSliderTextUpdate ( realResolutionSliderValue ( ) ) ;
resolutionSliderTextUpdate ( realResolutionSliderValue ( ) ) ;
base - > resolutionSlider - > blockSignals ( false ) ;
base - > resolutionSlider - > blockSignals ( false ) ;
@ -864,6 +873,7 @@ void KDisplayConfig::refreshDisplayedInformation () {
void KDisplayConfig : : updateDragDropDisplay ( ) {
void KDisplayConfig : : updateDragDropDisplay ( ) {
// Insert data into the GUI
// Insert data into the GUI
int i ;
int i ;
int j ;
int largest_x_pixels ;
int largest_x_pixels ;
int largest_y_pixels ;
int largest_y_pixels ;
TQObjectList monitors ;
TQObjectList monitors ;
@ -887,22 +897,27 @@ void KDisplayConfig::updateDragDropDisplay() {
// Add the screens to the workspace
// Add the screens to the workspace
// Set the scaling small to start with
// Set the scaling small to start with
base - > monitorPhyArrange - > resize_factor = 0.0625 ; // This always needs to divide by a multiple of 2
base - > monitorPhyArrange - > resize_factor = 0.0625 ; // This always needs to divide by a multiple of 2
for ( i = 0 ; i < numberOfScreens ; i + + ) {
for ( j = 0 ; j < 2 ; j + + ) {
screendata = m_screenInfoArray . at ( i ) ;
for ( i = 0 ; i < numberOfScreens ; i + + ) {
TQString rotationDesired = * screendata - > rotations . at ( screendata - > current_rotation_index ) ;
screendata = m_screenInfoArray . at ( i ) ;
bool isvisiblyrotated = ( ( rotationDesired = = " Rotate 90 degrees " ) | | ( rotationDesired = = " Rotate 270 degrees " ) ) ;
if ( ( ( j = = 0 ) & & ( screendata - > is_primary = = true ) ) | | ( j = = 1 ) ) { // This ensures that the primary monitor is always the first one created and placed on the configuration widget
DraggableMonitor * m = new DraggableMonitor ( base - > monitorPhyArrange , 0 , WStyle_Customize | WDestructiveClose | WStyle_NoBorder | WX11BypassWM ) ;
TQString rotationDesired = * screendata - > rotations . at ( screendata - > current_rotation_index ) ;
connect ( m , TQT_SIGNAL ( workspaceRelayoutNeeded ( ) ) , this , TQT_SLOT ( layoutDragDropDisplay ( ) ) ) ;
bool isvisiblyrotated = ( ( rotationDesired = = " Rotate 90 degrees " ) | | ( rotationDesired = = " Rotate 270 degrees " ) ) ;
connect ( m , TQT_SIGNAL ( monitorSelected ( int ) ) , this , TQT_SLOT ( selectScreen ( int ) ) ) ;
DraggableMonitor * m = new DraggableMonitor ( base - > monitorPhyArrange , 0 , WStyle_Customize | WDestructiveClose | WStyle_NoBorder | WX11BypassWM ) ;
connect ( m , TQT_SIGNAL ( monitorDragComplete ( int ) ) , this , TQT_SLOT ( updateDraggableMonitorInformation ( int ) ) ) ;
connect ( m , TQT_SIGNAL ( workspaceRelayoutNeeded ( ) ) , this , TQT_SLOT ( layoutDragDropDisplay ( ) ) ) ;
m - > screen_id = i ;
connect ( m , TQT_SIGNAL ( monitorSelected ( int ) ) , this , TQT_SLOT ( selectScreen ( int ) ) ) ;
if ( isvisiblyrotated )
connect ( m , TQT_SIGNAL ( monitorDragComplete ( int ) ) , this , TQT_SLOT ( updateDraggableMonitorInformation ( int ) ) ) ;
m - > setFixedSize ( screendata - > current_y_pixel_count * base - > monitorPhyArrange - > resize_factor , screendata - > current_x_pixel_count * base - > monitorPhyArrange - > resize_factor ) ;
m - > screen_id = i ;
else
if ( isvisiblyrotated )
m - > setFixedSize ( screendata - > current_x_pixel_count * base - > monitorPhyArrange - > resize_factor , screendata - > current_y_pixel_count * base - > monitorPhyArrange - > resize_factor ) ;
m - > setFixedSize ( screendata - > current_y_pixel_count * base - > monitorPhyArrange - > resize_factor , screendata - > current_x_pixel_count * base - > monitorPhyArrange - > resize_factor ) ;
m - > setText ( TQString ( " %1 " ) . arg ( i + 1 ) ) ;
else
m - > show ( ) ;
m - > setFixedSize ( screendata - > current_x_pixel_count * base - > monitorPhyArrange - > resize_factor , screendata - > current_y_pixel_count * base - > monitorPhyArrange - > resize_factor ) ;
updateDraggableMonitorInformation ( i ) ; // Make sure the new monitors don't overlap
m - > setText ( TQString ( " %1 " ) . arg ( i + 1 ) ) ;
m - > show ( ) ;
moveMonitor ( m , screendata - > absolute_x_position , screendata - > absolute_y_position ) ;
updateDraggableMonitorInformation ( i ) ; // Make sure the new monitors don't overlap
}
}
}
}
layoutDragDropDisplay ( ) ;
layoutDragDropDisplay ( ) ;
@ -967,6 +982,17 @@ void KDisplayConfig::rotationInfoChanged() {
changed ( ) ;
changed ( ) ;
}
}
void KDisplayConfig : : refreshInfoChanged ( ) {
SingleScreenData * screendata ;
screendata = m_screenInfoArray . at ( base - > monitorDisplaySelectDD - > currentItem ( ) ) ;
screendata - > current_refresh_rate_index = base - > refreshRateDD - > currentItem ( ) ;
updateDisplayedInformation ( ) ;
updateDraggableMonitorInformation ( base - > monitorDisplaySelectDD - > currentItem ( ) ) ;
changed ( ) ;
}
TQString KDisplayConfig : : extractFileName ( TQString displayName , TQString profileName ) {
TQString KDisplayConfig : : extractFileName ( TQString displayName , TQString profileName ) {
}
}
@ -985,6 +1011,8 @@ void KDisplayConfig::ensurePrimaryMonitorIsAvailable() {
}
}
screendata = m_screenInfoArray . at ( currentScreenIndex ) ;
screendata = m_screenInfoArray . at ( currentScreenIndex ) ;
screendata - > is_primary = true ;
screendata - > is_primary = true ;
screendata - > is_extended = true ;
updateDragDropDisplay ( ) ;
refreshDisplayedInformation ( ) ;
refreshDisplayedInformation ( ) ;
}
}
@ -1052,7 +1080,7 @@ void KDisplayConfig::load(bool useDefaults )
void KDisplayConfig : : save ( )
void KDisplayConfig : : save ( )
{
{
if ( m_randrsimple - > applySystemwideDisplayConfiguration ( m_screenInfoArray , TRUE ) ) {
if ( m_randrsimple - > applySystemwideDisplayConfiguration ( m_screenInfoArray , TRUE ) ) {
m_randrsimple - > saveSystemwideDisplayConfiguration ( " " , KDE_CONFDIR , m_screenInfoArray ) ;
m_randrsimple - > saveSystemwideDisplayConfiguration ( base - > systemEnableSupport - > isChecked ( ) , " " , KDE_CONFDIR , m_screenInfoArray ) ;
// Write system configuration
// Write system configuration
systemconfig - > setGroup ( NULL ) ;
systemconfig - > setGroup ( NULL ) ;