Using XRRSetCrtcConfig
Manuel Schneider
manuelschneid3r at gmail.com
Thu Nov 28 11:34:37 PST 2013
Hello, for a project at my university I need to use the libxrandr to change the screensettings. I use XRRSetCrtConfig to apply the settings. But after applying the settings several times there is just a little rectangle left on my monitors, where something of the desktop is displayed. Is there something missing? I use the code below.
regards
////////////////////////////////////////////////////
XGrabServer(_display);
// First get a useful representation
unsigned int width, height;
QStringList modeAsStrings = _ui->comboBox->currentText().split("x", QString::SkipEmptyParts);
width = modeAsStrings.at(0).toInt();
height = modeAsStrings.at(1).toInt();
// Find a mode that matches the string
RRMode m1,m2;
for (int i = 0; i < _outputMap[_monitor]->nmode; ++i){
if ( width == _modeMap[_outputMap[_monitor]->modes[i]]->width
&& height == _modeMap[_outputMap[_monitor]->modes[i]]->height )
m1 = _modeMap[_outputMap[_monitor]->modes[i]]->id;
}
for (int i = 0; i < _outputMap[_beamer]->nmode; ++i){
if ( width == _modeMap[_outputMap[_beamer]->modes[i]]->width
&& height == _modeMap[_outputMap[_beamer]->modes[i]]->height )
m2 = _modeMap[_outputMap[_beamer]->modes[i]]->id;
}
qDebug() << _modeMap[m1]->width << _modeMap[m1]->height;
qDebug() << _modeMap[m2]->width << _modeMap[m2]->height;
/* values from xrandr */
float dpi = (25.4 * DisplayHeight(_display, 0)) / DisplayHeightMM(_display, 0);
int widthMM = (int) ((25.4 * width) / dpi);
int heightMM = (int) ((25.4 * height) / dpi);
// Set screensize
XRRSetScreenSize(_display, DefaultRootWindow(_display),
width, height,
widthMM, heightMM);
// Apply the modes
XRRSetCrtcConfig(_display,
_screenResources,
_outputMap[_monitor]->crtc,
CurrentTime,
0, 0,
m1,
RR_Rotate_0,
&_monitor,
1);
XRRSetCrtcConfig(_display,
_screenResources,
_outputMap[_beamer]->crtc,
CurrentTime,
0, 0,
m2,
RR_Rotate_0,
&_beamer,
1);
XUngrabServer(_display);
/////////////////////////////////////////
--
Mit freundlichem Gruß
Manuel Schneider
More information about the xorg-devel
mailing list