2
* Copyright (C) 2013-2016 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#include <QtDBus/QDBusInterface>
24
#include <qpa/qplatformscreen.h>
27
#include <mir/graphics/display_configuration.h>
31
#include "screenwindow.h"
33
class QOrientationSensor;
35
namespace graphics { class DisplayBuffer; class DisplaySyncGroup; }
36
namespace renderer { namespace gl { class RenderTarget; }}
39
class Screen : public QObject, public QPlatformScreen
43
Screen(const mir::graphics::DisplayConfigurationOutput &);
46
// QPlatformScreen methods.
47
QRect geometry() const override { return m_geometry; }
48
int depth() const override { return m_depth; }
49
QImage::Format format() const override { return m_format; }
50
qreal devicePixelRatio() const override { return m_devicePixelRatio; }
51
QSizeF physicalSize() const override { return m_physicalSize; }
52
qreal refreshRate() const override { return m_refreshRate; }
53
Qt::ScreenOrientation nativeOrientation() const override { return m_nativeOrientation; }
54
Qt::ScreenOrientation orientation() const override { return m_currentOrientation; }
55
QPlatformCursor *cursor() const override;
56
QString name() const override;
58
float scale() const { return m_scale; }
59
MirFormFactor formFactor() const { return m_formFactor; }
60
MirPowerMode powerMode() const { return m_powerMode; }
61
mir::graphics::DisplayConfigurationOutputId outputId() const { return m_outputId; }
62
mir::graphics::DisplayConfigurationOutputType outputType() const { return m_type; }
63
std::vector<MirPixelFormat> pixelFormats() const { return m_pixelFormats; }
64
std::vector<mir::graphics::DisplayConfigurationMode> modes() const { return m_modes; }
65
uint32_t currentModeIndex() const { return m_currentModeIndex; }
66
uint32_t preferredModeIndex() const { return m_preferredModeIndex; }
68
ScreenWindow* window() const;
71
void customEvent(QEvent* event) override;
73
// To make it testable
74
static bool skipDBusRegistration;
75
bool orientationSensorEnabled();
78
void onDisplayPowerStateChanged(int, int);
79
void onOrientationReadingChanged();
82
void setWindow(ScreenWindow *window);
84
void setMirDisplayConfiguration(const mir::graphics::DisplayConfigurationOutput &, bool notify = true);
85
void setMirDisplayBuffer(mir::graphics::DisplayBuffer *, mir::graphics::DisplaySyncGroup *);
91
void toggleSensors(const bool enable) const;
92
bool internalDisplay() const;
96
QImage::Format m_format;
97
qreal m_devicePixelRatio;
98
QSizeF m_physicalSize;
101
MirFormFactor m_formFactor;
102
std::vector<MirPixelFormat> m_pixelFormats;
103
std::vector<mir::graphics::DisplayConfigurationMode> m_modes;
104
uint32_t m_currentModeIndex;
105
uint32_t m_preferredModeIndex;
107
mir::renderer::gl::RenderTarget *m_renderTarget;
108
mir::graphics::DisplaySyncGroup *m_displayGroup;
109
mir::graphics::DisplayConfigurationOutputId m_outputId;
110
mir::graphics::DisplayConfigurationCardId m_cardId;
111
mir::graphics::DisplayConfigurationOutputType m_type;
112
MirPowerMode m_powerMode;
114
Qt::ScreenOrientation m_nativeOrientation;
115
Qt::ScreenOrientation m_currentOrientation;
116
QOrientationSensor *m_orientationSensor;
118
ScreenWindow *m_screenWindow;
119
QDBusInterface *m_unityScreen;
121
qtmir::Cursor m_cursor;
123
friend class ScreensModel;
124
friend class ScreenWindow;