From 024855948c923bd40ffaf526c1300dd8c0377698 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 15 Dec 2017 14:12:44 +0100 Subject: Update to CMAKE, fix timeout dialog on Qt5, fix menu getting covered by window --- src/widget.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/widget.cpp') diff --git a/src/widget.cpp b/src/widget.cpp index b3a559f..887249f 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -244,6 +244,7 @@ Widget::Widget(QWidget *parent) : void Widget::bringToTopTimer() { + if (_ui->comboBox->isVisible()) return; raise(); } @@ -346,8 +347,9 @@ void Widget::handleButton(){ // First disconnect all crts to avoid conflicts for(CrtcMap::iterator it = _crtcMap.begin(); it != _crtcMap.end(); ++it) { - XRRSetCrtcConfig(_display, _screenResources, it.key(), CurrentTime, + Status st = XRRSetCrtcConfig(_display, _screenResources, it.key(), CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); + qDebug() << "Disconnecting" << it.key() << ":" << st; } // Set screensize @@ -357,27 +359,28 @@ void Widget::handleButton(){ 25.4 * monitorMode->height / 96); // standard dpi that X uses // Apply the modes - XRRSetCrtcConfig(_display, - _screenResources, + Status stMon = XRRSetCrtcConfig(_display, + _screenResources, _outputMap[_monitor]->crtc, CurrentTime, 0, 0, monitorMode->id, RR_Rotate_0, &_monitor, 1); - XRRSetCrtcConfig(_display, + Status stBem = XRRSetCrtcConfig(_display, _screenResources, _outputMap[_beamer]->crtc, CurrentTime, 0, 0, beamerMode->id, RR_Rotate_0, - &_beamer, 1); + &_beamer, 1); // Sync... whatever... XSync (_display, False); + qDebug() << "Monitor set:" << stMon << ", beamer set: " << stBem; // Center widget on screenbottom this->move( monitorMode->width/2 - this->width()/2, - monitorMode->height - this->height()); + monitorMode->height - this->height() ); // Set the mouse pointer in the middle of the screen QCursor::setPos(monitorMode->width/2, monitorMode->height/2); @@ -385,16 +388,22 @@ void Widget::handleButton(){ /*************************** ASK for confirmtion ****************************/ // Show a dialog asking if the res should be kept - TimeOutDialog *keepDialog = new TimeOutDialog(15, this); - keepDialog->setWindowTitle(" "); - keepDialog->setLabelText("Do you want to keep this resolution?"); - keepDialog->setCancelButtonText("Keep"); - keepDialog->move(monitorMode->width/2 - this->width()/2, + TimeOutDialog keepDialog(15, this); + keepDialog.setWindowModality(Qt::ApplicationModal); + keepDialog.setWindowTitle(" "); + keepDialog.setLabelText(trUtf8("Do you want to keep this resolution?")); + keepDialog.setCancelButtonText(trUtf8("Keep")); + keepDialog.move(monitorMode->width/2 - this->width()/2, monitorMode->height/2 - this->height()); - keepDialog->exec(); + keepDialog.show(); + + while (keepDialog.isActive()) { + QCoreApplication::processEvents(); + } // If the dialog was not canceled revert the resolution - if ( ! keepDialog->wasCanceled()) { + if ( !keepDialog.wasCanceled()) { + qDebug() << "User did not cancel timeout, reverting!"; /**************************** Apply the backup ****************************/ -- cgit v1.2.3-55-g7522