summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Ritter2016-11-10 17:14:02 +0100
committerSteffen Ritter2016-11-10 17:14:02 +0100
commitef13cf1489d7ce9d015d5e761e48bd476c9b6cd1 (patch)
tree189ec6543c8ee3a9dfa4161c03214c47678a5284
parentStay on top (diff)
downloadbeamergui-ef13cf1489d7ce9d015d5e761e48bd476c9b6cd1.tar.gz
beamergui-ef13cf1489d7ce9d015d5e761e48bd476c9b6cd1.tar.xz
beamergui-ef13cf1489d7ce9d015d5e761e48bd476c9b6cd1.zip
Fix beamer detection in clone mode for some cases
* clone mode is now detected by checking if x starts at upper left corner for all crtcs. Not only if the reported width/height is 0 * treat the output with the largest diagonale as beamer if no output has a width/height of 0
-rw-r--r--src/widget.cpp76
-rw-r--r--src/widget.h1
2 files changed, 52 insertions, 25 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index c418d0e..8833630 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -10,6 +10,7 @@
#include "widget.h"
#include "ui_widget.h"
#include "timeoutdialog.h"
+#include "math.h"
//______________________________________________________________________________
Widget::Widget(QWidget *parent) :
@@ -33,35 +34,39 @@ Widget::Widget(QWidget *parent) :
qDebug() << "Normal output";
exit(0);
break;
- /*************************************************************************/
case 2: // In case of two connected outputs
- // Check if one of the connected outputs is a beamer. This program only
- // adresses cases in which eiter of the outouts is a beamer. Meaning
- // either output one has dimension zero or output tow has no dimension.
-#ifdef QT_DEBUG
- if ( true ) {
-#else
- if ( ((_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 )) ) {
-#endif
+ qDebug() << "Two connected outputs";
+
+ // Check if we are in clone mode
+ if (cloneMode()) {
+
+ qDebug() << "Clone mode!";
- qDebug() << "BEAMER CONNECTED!";
+ double_t w0 = _outputMap[_connectedOutputList[0]]->mm_width;
+ double_t h0 = _outputMap[_connectedOutputList[0]]->mm_height;
+
+ double_t w1 = _outputMap[_connectedOutputList[1]]->mm_width;
+ double_t h1 = _outputMap[_connectedOutputList[1]]->mm_height;
// Get a human readable reference
- if (_outputMap[_connectedOutputList[0]]->mm_width == 0
- && _outputMap[_connectedOutputList[0]]->mm_height == 0 ) {
+ if (w0 == 0 && h0 == 0) {
_beamer = _connectedOutputList[0];
_monitor = _connectedOutputList[1];
- } else {
+ } else if (w1 == 0 && h1 == 0) {
_beamer = _connectedOutputList[1];
_monitor = _connectedOutputList[0];
+ } else {
+ double_t d0 = sqrt((pow(w0, 2) * pow(h0, 2)));
+ double_t d1 = sqrt((pow(w1, 2) * pow(h1, 2)));
+
+ if (d0 > d1) {
+ _beamer = _connectedOutputList[0];
+ _monitor = _connectedOutputList[1];
+ } else {
+ _beamer = _connectedOutputList[1];
+ _monitor = _connectedOutputList[0];
+ }
}
// Intersect them by the resolution sorted, dont care about O(n³)
@@ -72,7 +77,7 @@ Widget::Widget(QWidget *parent) :
XRRModeInfo* monitorMode = _modeMap[_outputMap[_monitor]->modes[i]];
- // Skip interlaces modes
+ // Skip interlace modes
if ( monitorMode->modeFlags & RR_Interlace )
continue;
@@ -81,7 +86,7 @@ Widget::Widget(QWidget *parent) :
XRRModeInfo* beamerMode = _modeMap[_outputMap[_beamer]->modes[j]];
- // Skip interlaces modes
+ // Skip interlace modes
if ( beamerMode->modeFlags & RR_Interlace )
continue;
@@ -162,7 +167,7 @@ Widget::Widget(QWidget *parent) :
// Compute the aspect ratio of the beamer
float aspectRatio = (float)_modeMap[preferredBeamerModeId]->width
- / _modeMap[preferredBeamerModeId]->height;
+ / _modeMap[preferredBeamerModeId]->height;
// Fill widget with data
for (QList<QPair<XRRModeInfo*, XRRModeInfo*> >::iterator i
@@ -217,7 +222,7 @@ Widget::Widget(QWidget *parent) :
// If NEITHER of the outputs is a beamer (likely dualscreen setup)
else {
// TODO(manuel): Future feature. Setup dualscreen
- qDebug() << "Dual output";
+ qDebug() << "Dual output with extended screen";
exit(0);
}
break;
@@ -300,7 +305,7 @@ Widget::~Widget() {
//______________________________________________________________________________
-void Widget::handleButton(){
+void Widget::handleButton(){
/*************************** Backup the crtcinfos ***************************/
@@ -448,4 +453,25 @@ void Widget::handleButton(){
updateScreenResources();
}
+bool Widget::cloneMode()
+{
+ bool cloneMode = true;
+
+ for (CrtcMap::iterator it = _crtcMap.begin(); it != _crtcMap.end(); it++) {
+ XRRCrtcInfo* crtc = it.value();
+
+ // check if x starts on upper left corner
+ if (crtc->x != 0 || crtc->y != 0) {
+ cloneMode = false;
+ }
+
+ qDebug() << "width: " << crtc->width
+ << "height: " << crtc->height
+ << "x: " << crtc->x
+ << "y: " << crtc->y
+ << "mode: " << crtc->mode;
+ }
+
+ return cloneMode;
+}
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/widget.h b/src/widget.h
index a737412..31b9a95 100644
--- a/src/widget.h
+++ b/src/widget.h
@@ -43,6 +43,7 @@ public:
private:
void timeout();
void updateScreenResources();
+ bool cloneMode();
Ui::Widget * _ui;
Display* _display;