summaryrefslogblamecommitdiffstats
path: root/src/xx.h
blob: 53d3507b4695b8e3297a1ef8537c4474663716b5 (plain) (tree)
1
2
3
4
5
6
7
8
9








                  
                      
                     























                                                                           
                          
 




                        
















                                                       

                  


                                  
       
                                                 


                                             
                                            




                                                                                               

                                                
                                            











                                                                        
                                                              
                                    


                                           



                                                           




                                                                           
#ifndef XRANDR_H
#define XRANDR_H

#include <QList>
#include <QString>
#include <QSize>

struct ScreenInfo;
class XPrivate;
class QSocketNotifier;
class BackupInternal;

typedef QVector<QSize>                    ResolutionVector;

///////////////////////////////////////////////////////////////////////////

enum class ScreenMode
{
	Single,
	Clone,
	Dual,
	Advanced,
};

struct ScreenInfo
{
	int position;
	QString name;
	QString output;
	QSize currentResolution;
	QSize preferredResolution;
	bool isProjector;
	ResolutionVector modes;
};

enum class ConnectionEvent
{
	   Connected,
	   Disconnected,
	   Unknown,
};

class ConfigBackup
{
    friend class ScreenSetup;
protected:
    explicit ConfigBackup(XPrivate*);
    explicit ConfigBackup();
private:
    bool _ok;
    BackupInternal* a;
    ConfigBackup& operator=(const ConfigBackup &other);
public:
    ConfigBackup(const ConfigBackup &other);
    ~ConfigBackup();
    bool ok() const { return _ok; }
    void revert();
};

struct OutputInfo;

class ScreenSetup : public QObject
{
	Q_OBJECT
public:
	void         addMissingEdidResolutions();
	void         updateScreenResources();
	void         initModes();
	ScreenMode   getCurrentMode();
	bool         hasScreenWithoutEdid();
    ConfigBackup setDefaultMode(bool dryRun, ScreenMode &mode);
    bool         createMode(unsigned int resX, unsigned int resY, float refresh, QString name);
    ConfigBackup setCenteredClone();
    ConfigBackup setClone(const QSize &resolution);
    ConfigBackup setCustom(const QList<QPair<QSize, QList<QString>>> &list);
	ResolutionVector getCommonModes() const;
	int getOutputCount() const;
	int queryCurrentOutputCount() const;
	QMap<QString, ScreenInfo> getScreenPositions() const;
	const ResolutionVector &getVirtualResolutions() const;

	// Singleton
	inline static ScreenSetup*             inst() {
		if (_instance == nullptr) _instance = new ScreenSetup();
		return _instance;
	}

private:
	ScreenSetup();
	~ScreenSetup();
	ScreenInfo initScreenInfo(const OutputInfo *oi) const;
    ConfigBackup createCrtcBackup();

	static ScreenSetup *     _instance;
	XPrivate *a;
	QSocketNotifier *_socketNotifier;
signals:
	   void outputConfigChanged(ConnectionEvent event);

};

///////////////////////////////////////////////////////////////////////////

#endif // XRANDR_H