summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp420
1 files changed, 420 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index cb48fbb..9c95f7c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,11 +1,431 @@
+
+
#include <QtGui/QApplication>
+#include <QString>
+#include <QDebug>
+#include <fstream>
+#include <iostream>
#include "widget.h"
+#include "config.h"
+#include "x.h"
+
+
+// Prototypes
+QString getIP ();
+
+void usage()
+{
+}
int main(int argc, char *argv[])
{
+// ///////////////////
+// // Debug
+// argv[1] = "/home/manuel/beamer.conf";
+// ///////////////////7
+
+// if ( argc < 1 )
+// {
+// std::cerr << "Too many arguments. The only parameter shall be a path to a config file." << std::endl;
+// exit(1);
+// }
+// if ( argc == 1 )
+// {
+// // Check if file exists
+// std::ifstream f(argv[1]);
+// if (!f)
+// {
+// std::cerr << "The config file does not exist" << std::endl;
+// exit(1);
+// }
+// else
+// f.close();
+// }
+
+// //Load settings
+// Config::inst()->loadSettings(argv[1]);
+// qDebug() << X::Screen::inst();
+
+
+// qDebug() << Config::inst()->getDisplay();
+// qDebug() << Config::inst()->getInterface();
+// qDebug() << Config::inst()->getIpSpecificXConf();
+// qDebug() << Config::inst()->getModeLines();
+// qDebug() << Config::inst()->getSettingsPath();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// // Get initial data (to be freed)
+// Display *dpy = XOpenDisplay(NULL);
+// XRRScreenResources *sr = XRRGetScreenResourcesCurrent(dpy, DefaultRootWindow(dpy));
+
+
+
+
+// int X=1;RandR::
+// int M=1;
+
+// XRROutputInfo *output_first_info = XRRGetOutputInfo(dpy, sr, sr->outputs[X]);
+
+// // XRRSet
+// // HOLY
+// XRRSetCrtcConfig(dpy,
+// sr,
+// output_first_info->crtc,
+// CurrentTime,
+// 0, 0,
+// sr->modes[output_first_info->npreferred -1].id,
+// RR_Rotate_0,
+// &sr->outputs[X],
+// 1);
+
+
+
+
+
+
+
+
+
+
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
+
+
+
+
+////////////////////////////////////////// CODE MÜLLEIMER
+
+
+ // eine datei
+
+
+//Widget::Widget(QWidget *parent) :
+// QWidget(parent),
+// ui(new Ui::Widget)
+//{
+// ui->setupUi(this);
+
+// for (std::vector<Output>::iterator i = DisplayManager::Inst()->getConnectedOutputs().begin();
+// i != DisplayManager::Inst()->getConnectedOutputs().end();
+// ++i)
+// {
+// qDebug() << "EDID?" << ( (*i).hasEDID() ? "true" : "false");
+// qDebug() << "Proj?" << ( (*i).isProjector() ? "true" : "false");
+// qDebug() << "Current?"
+// << DisplayManager::Inst()->getResolution((*i).getCurrentMode()).width
+// << DisplayManager::Inst()->getResolution((*i).getCurrentMode()).height;
+// Resolution res;
+// if ((*i).getPreferredMode())
+// qDebug() << "Preferred?"
+// << DisplayManager::Inst()->getResolution((*i).getPreferredMode()).width
+// << DisplayManager::Inst()->getResolution((*i).getPreferredMode()).height;
+
+// QSet<RRMode> modes = (*i).getSupportedModes();
+
+// for ( QSet<RRMode>::iterator i = modes.begin(); i != modes.end(); ++i )
+// {
+// qDebug() << "---- "
+// << DisplayManager::Inst()->getResolution(*i).width
+// << DisplayManager::Inst()->getResolution(*i).height;
+// }
+// }
+
+
+// switch ( DisplayManager::Inst()->getConnectedOutputs().size() ){
+// /*************************************************************************/
+// case 1:// In case of one connected output - xrandr --auto
+// qDebug() << "Normal output";
+// exit(0);
+// break;
+// /*************************************************************************/
+// case 2: // In case of two connected outputs
+
+// /*********************************************************************/
+// // If one of the two connected outputs is a beamer
+
+// if ( true)//DisplayManager::Inst()->isProjectorConnected() )
+// {
+// /*
+// Here the usecases have to be listed theoretically there are two
+// in this case. 2 Projectors, 1 projectors and on monitor. Only the
+// latter is asumed here.
+// */
+
+// // Remember which one is the projector
+// int ProjectorIndex;
+// DisplayManager::Inst()->getConnectedOutputs().at(0).isProjector()
+// ? ProjectorIndex = 0 : ProjectorIndex = 0;
+
+// /*****************************************************************/
+// // If the beamer transmits reliable EDID data.
+// if( DisplayManager::Inst()->getConnectedOutputs().at(ProjectorIndex).hasEDID() )
+// {
+// // Now we can assume that the preferred mode of the projector to be correnct
+// // to be correct.
+
+// // Get the AR of the beamer
+// Resolution res;
+// if ( DisplayManager::Inst()->getConnectedOutputs().at(ProjectorIndex).getPreferredMode() )
+// fprintf(stderr, "Beamer has EDID but no preferred mode.");
+
+// float AR = res.width/res.height;
+
+// QSet<RRMode> BeamerModes =
+// DisplayManager::Inst()->getConnectedOutputs().at(ProjectorIndex).getSupportedModes();
+
+// QSet<RRMode> MonitorModes =
+// DisplayManager::Inst()->getConnectedOutputs().at(1-ProjectorIndex).getSupportedModes();
+
+// QSet<RRMode> CommonModes = BeamerModes.unite(MonitorModes);
+
+// CommonModes.intersect(BeamerModes);
+// CommonModes.intersect(MonitorModes);
+
+// // Fill treewidget with data from cups dests;
+// for ( QSet<RRMode>::iterator i = CommonModes.begin(); i != CommonModes.end(); ++i )
+// {
+// char * ModeString;
+// sprintf(ModeString, "%dx%d",
+// DisplayManager::Inst()->getResolution(*i).width,
+// DisplayManager::Inst()->getResolution(*i).height
+// );
+
+// qDebug() << ModeString;
+// ui->comboBox->addItem(ModeString, QVariant((unsigned long long int)*i));
+// }
+// }
+// /*****************************************************************/
+// // If the beamer DOES NOT transmits reliable EDID data.
+// else
+// {
+// qDebug() << "beamer output no reliable EDID ";
+// configureWidgetForBeamerWithEDID();
+// }
+// /*****************************************************************/
+
+// }
+// /*********************************************************************/
+// // If NEITHER of the outputs is a beamer (likely dualscreen setup)
+// else
+// {
+// // Just apply preferred settings
+
+// qDebug() << "dualscreen output";
+
+// }
+// break;
+// /*************************************************************************/
+// default:
+// // If there are more than 3 outputs
+// // its up to the user. Quit.
+// exit(0);
+// break;
+// }
+// /*************************************************************************/
+
+
+
+
+
+
+// //Remove borders and stuff
+// setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
+
+
+
+
+// // QSet<RRMode> outputs0, outputs1;
+// // for (int i = 0; i < XManager::Inst()->getOutputInfos()[0]->nmode; ++i)
+// // outputs0.insert(XManager::Inst()->getOutputInfos()[0]->modes[i]);
+// // for (int i = 0; i < XManager::Inst()->getOutputInfos()[1]->nmode; ++i)
+// // outputs1.insert(XManager::Inst()->getOutputInfos()[1]->modes[i]);
+// // outputs0.intersect(outputs1);
+
+// // // Fill treewidget with data from cups dests;
+// // for ( QSet<RRMode>::iterator it = outputs0.begin(); it != outputs0.end(); ++it )
+// // {
+// // qDebug() << *it;
+// // qDebug() << XManager::Inst()->getModeMap()[*it];
+// // ui->comboBox->addItem(XManager::Inst()->getModeMap().at(*it), (unsigned long long int)*it);
+// // }
+
+// // // Fill treewidget with data from cups dests;
+// // for ( map<XID, char *>::iterator it = XManager::Inst()->getModeMap().begin(); it != XManager::Inst()->getModeMap().end(); ++it )
+// // {
+// // qDebug() << it->first ;
+// //// qDebug() << XManager::getInstance()->getModeMap()[*it];
+// //// ui->comboBox->addItem(XManager::getInstance()->getModeMap().at(*it), (unsigned long long int)*it);
+// // }
+
+// // Resize widget to its content
+// resize(sizeHint());
+
+// // Center dialog on screenbottom
+// const QRect desktopRect = QApplication::desktop()->screenGeometry();
+// this->move( desktopRect.width()/2-this->width()/2,
+// desktopRect.height()-this->height());
+// }
+
+// Widget::~Widget()
+// {
+// delete ui;
+// }
+
+// void Widget::configureWidgetForBeamerWithEDID()
+// {
+// }
+
+// void Widget::configureWidgetForBeamerWithOUTEDID()
+// {
+// }
+
+
+
+
+
+ // eine andre datei
+
+
+
+
+
+
+//Widget::Widget(QWidget *parent) :
+// QWidget(parent),
+// ui(new Ui::Widget)
+//{
+// ui->setupUi(this);
+
+
+// X11::XManager * XM = X11::XManager::getInstance();
+
+
+// switch ( XM->getOutputInfos().size() ){
+// /*************************************************************************/
+// case 1:// In case of one connected output - xrandr --auto
+// qDebug() << "Normal output";
+// exit(0);
+// break;
+// /*************************************************************************/
+// case 2: // In case of two connected outputs
+
+// /*********************************************************************/
+// // If one of the two connected outputs is a beamer
+// if ( true ) //( XM->getOutputInfos()[0]->mm_width == 0 && XM->getOutputInfos()[0]->mm_height == 0 )
+// // || ( XM->getOutputInfos()[1]->mm_width == 0 && XM->getOutputInfos()[1]->mm_height == 0 ) )
+// {
+// /*****************************************************************/
+// // If the beamer transmits reliable EDID data.
+// if( isReliableEDIDpresent() )
+// {
+// qDebug() << "beamer output reliable EDID ";
+// configureWidgetForBeamerWithEDID();
+// }
+// /*****************************************************************/
+// // If the beamer DOES NOT transmits reliable EDID data.
+// else
+// {
+// qDebug() << "beamer output no reliable EDID ";
+// configureWidgetForBeamerWithEDID();
+// }
+// /*****************************************************************/
+
+// }
+// /*********************************************************************/
+// // If NEITHER of the outputs is a beamer (likely dualscreen setup)
+// else
+// {
+// // Just apply preferred settings
+// qDebug() << "dualscreen output";
+
+// }
+// break;
+// /*************************************************************************/
+// default:
+// // If there are more than 3 outputs
+// // its up to the user. Quit.
+// exit(0);
+// break;
+// }
+// /*************************************************************************/
+
+
+
+
+// Remove borders and stuff
+// setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
+
+
+
+
+// QSet<RRMode> outputs0, outputs1;
+// for (int i = 0; i < XManager::Inst()->getOutputInfos()[0]->nmode; ++i)
+// outputs0.insert(XManager::Inst()->getOutputInfos()[0]->modes[i]);
+// for (int i = 0; i < XManager::Inst()->getOutputInfos()[1]->nmode; ++i)
+// outputs1.insert(XManager::Inst()->getOutputInfos()[1]->modes[i]);
+// outputs0.intersect(outputs1);
+
+// // Fill treewidget with data from cups dests;
+// for ( QSet<RRMode>::iterator it = outputs0.begin(); it != outputs0.end(); ++it )
+// {
+// qDebug() << *it;
+// qDebug() << XManager::Inst()->getModeMap()[*it];
+// ui->comboBox->addItem(XManager::Inst()->getModeMap().at(*it), (unsigned long long int)*it);
+// }
+
+// // Fill treewidget with data from cups dests;
+// for ( map<XID, char *>::iterator it = XManager::Inst()->getModeMap().begin(); it != XManager::Inst()->getModeMap().end(); ++it )
+// {
+// qDebug() << it->first ;
+//// qDebug() << XManager::getInstance()->getModeMap()[*it];
+//// ui->comboBox->addItem(XManager::getInstance()->getModeMap().at(*it), (unsigned long long int)*it);
+// }
+
+// // Resize widget to its content
+// resize(sizeHint());
+
+// // Center dialog on screenbottom
+// const QRect desktopRect = QApplication::desktop()->screenGeometry();
+// this->move( desktopRect.width()/2-this->width()/2,
+// desktopRect.height()-this->height());
+//}
+
+