summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widget.cpp111
-rw-r--r--src/widget.h12
-rw-r--r--src/widget.ui2
3 files changed, 104 insertions, 21 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index d2a6765..4254530 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -7,16 +7,13 @@
#include <algorithm>
#include <iostream>
-//___________________________________________________________________________
-int compareModeString (const QString & a, const QString & b) {
- if (a.size() == b.size())
- return a.compare(b);
- else
- if (a.size() > b.size())
- return -1;
- else
- return 1;
-}
+//void setRefreshSpeed::on_okButton_clicked()
+//{
+// QApplication::beep();
+// MainWindow::freq = ui->spinBox->value();
+// ui->setupUi(this);
+// setRefreshSpeed::close();
+//}
//___________________________________________________________________________
Widget::Widget(QWidget *parent) :
@@ -45,14 +42,14 @@ Widget::Widget(QWidget *parent) :
// adresses cases in which eiter of the outouts is a beamer. Meaning
// either output one has dimension zero or output tow has no dimension.
// The case of two beamers is not covered.
- if (/*true*/((_outputMap[_connectedOutputList[0]]->mm_width == 0
+ if (true/*((_outputMap[_connectedOutputList[0]]->mm_width == 0
&& _outputMap[_connectedOutputList[0]]->mm_height == 0 )
&& ! (_outputMap[_connectedOutputList[1]]->mm_width == 0
&& _outputMap[_connectedOutputList[1]]->mm_height == 0 ))
|| ( ! (_outputMap[_connectedOutputList[0]]->mm_width == 0
&& _outputMap[_connectedOutputList[0]]->mm_height == 0 )
&& (_outputMap[_connectedOutputList[1]]->mm_width == 0
- && _outputMap[_connectedOutputList[1]]->mm_height == 0 ))) {
+ && _outputMap[_connectedOutputList[1]]->mm_height == 0 ))*/) {
std::cout << "BEAMER CONNECTED!" << std::endl;
// Get a human readable reference
@@ -131,7 +128,7 @@ Widget::Widget(QWidget *parent) :
}
// If the beamer transmits no reliable EDID data add modes
- if (gotEDID) {
+ if (false/*gotEDID*/) {
std::cout << "GOT EDID!" << std::endl;
// Extract the preferred mode of the beamer
RRMode preferredBeamerModeId;
@@ -193,6 +190,9 @@ Widget::Widget(QWidget *parent) :
this->move( desktopRect.width()/2-this->width()/2,
desktopRect.height()-this->height());
+ // Connect button signal to appropriate slot
+ connect(_ui->pushButton, SIGNAL(clicked()), this, SLOT(handleButton()));
+
} // End of the beamer section
/*********************************************************************/
@@ -212,6 +212,12 @@ Widget::Widget(QWidget *parent) :
break;
}
/*************************************************************************/
+
+
+
+
+
+
}
//___________________________________________________________________________
@@ -275,3 +281,82 @@ Widget::~Widget()
XCloseDisplay(_display);
XRRFreeScreenResources(_screenResources);
}
+
+void Widget::handleButton()
+{
+
+// QProcess p;
+// QStringList arguments;
+// arguments << "--output" << _outputMap[_monitor]->name
+// << "--mode" << _ui->comboBox->currentText()
+// << "--output" << _outputMap[_beamer]->name
+// << "--mode" << _ui->comboBox->currentText()
+// << "--same-as" <<_outputMap[_monitor]->name;
+
+// p.start("xrandr", arguments);
+// p.waitForFinished();
+
+ 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);
+
+ // Center dialog on screenbottom
+ this->move( width/2 - this->width()/2,
+ height - this->height());
+}
diff --git a/src/widget.h b/src/widget.h
index efcf9e9..5df8ab5 100644
--- a/src/widget.h
+++ b/src/widget.h
@@ -12,12 +12,6 @@ class Widget;
class Widget : public QWidget
{
-
- Q_OBJECT
-
-
-
-
typedef QSet<RRMode> ModeSet;
typedef QSet<RRCrtc> CrtcSet;
typedef QSet<RROutput> OutputSet;
@@ -30,12 +24,16 @@ class Widget : public QWidget
typedef QMap<RRCrtc, XRRCrtcInfo*> CrtcMap;
typedef QMap<RROutput, XRROutputInfo*> OutputMap;
+ Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
-
+
+ private slots:
+ void handleButton();
+
private:
void updateScreenResources();
diff --git a/src/widget.ui b/src/widget.ui
index cfa9bdf..3755397 100644
--- a/src/widget.ui
+++ b/src/widget.ui
@@ -25,7 +25,7 @@
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
- <string>PushButton</string>
+ <string>Anwenden</string>
</property>
</widget>
</item>