Changeset View
Changeset View
Standalone View
Standalone View
plugins/qpa/screen.cpp
Show All 16 Lines | |||||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "screen.h" | 20 | #include "screen.h" | ||
21 | #include "platformcursor.h" | 21 | #include "platformcursor.h" | ||
22 | #include "wayland_server.h" | 22 | #include "wayland_server.h" | ||
23 | 23 | | |||
24 | #include <KWayland/Client/output.h> | 24 | #include <KWayland/Client/output.h> | ||
25 | 25 | | |||
markg: Looks like its unused. | |||||
26 | namespace KWin | 26 | namespace KWin | ||
27 | { | 27 | { | ||
28 | namespace QPA | 28 | namespace QPA | ||
29 | { | 29 | { | ||
30 | 30 | | |||
31 | Screen::Screen(KWayland::Client::Output *o) | 31 | Screen::Screen(KWayland::Client::Output *o) | ||
32 | : QPlatformScreen() | 32 | : QPlatformScreen() | ||
33 | , m_output(QPointer<KWayland::Client::Output>(o)) | 33 | , m_output(QPointer<KWayland::Client::Output>(o)) | ||
Show All 11 Lines | |||||
45 | 45 | | |||
46 | QImage::Format Screen::format() const | 46 | QImage::Format Screen::format() const | ||
47 | { | 47 | { | ||
48 | return QImage::Format_ARGB32_Premultiplied; | 48 | return QImage::Format_ARGB32_Premultiplied; | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | QRect Screen::geometry() const | 51 | QRect Screen::geometry() const | ||
52 | { | 52 | { | ||
53 | return m_output ? m_output->geometry() : QRect(0, 0, 1, 1); | 53 | return m_output ? QRect(m_output->globalPosition(), m_output->pixelSize() / m_output->scale()) : QRect(0, 0, 1, 1); | ||
54 | } | 54 | } | ||
55 | 55 | | |||
56 | QSizeF Screen::physicalSize() const | 56 | QSizeF Screen::physicalSize() const | ||
57 | { | 57 | { | ||
58 | return m_output ? m_output->physicalSize() : QPlatformScreen::physicalSize(); | 58 | return m_output ? m_output->physicalSize() : QPlatformScreen::physicalSize(); | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | QPlatformCursor *Screen::cursor() const | 61 | QPlatformCursor *Screen::cursor() const | ||
62 | { | 62 | { | ||
63 | return m_cursor.data(); | 63 | return m_cursor.data(); | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | QDpi Screen::logicalDpi() const | 66 | QDpi Screen::logicalDpi() const | ||
67 | { | 67 | { | ||
68 | static int force_dpi = qEnvironmentVariableIsSet("QT_WAYLAND_FORCE_DPI") ? qEnvironmentVariableIntValue("QT_WAYLAND_FORCE_DPI") : -1; | 68 | static int force_dpi = qEnvironmentVariableIsSet("QT_WAYLAND_FORCE_DPI") ? qEnvironmentVariableIntValue("QT_WAYLAND_FORCE_DPI") : -1; | ||
69 | if (force_dpi > 0) { | 69 | if (force_dpi > 0) { | ||
70 | return QDpi(force_dpi, force_dpi); | 70 | return QDpi(force_dpi, force_dpi); | ||
71 | } | 71 | } | ||
72 | 72 | | |||
73 | return QPlatformScreen::logicalDpi(); | 73 | return QPlatformScreen::logicalDpi(); | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | qreal Screen::devicePixelRatio() const | ||||
77 | { | ||||
78 | return m_output ? (qreal)m_output->scale() : 1.0; | ||||
markg: c cast... no no no!
static_cast<qreal>(...) | |||||
is the cast needed at all? It should be implicitly casted from int to real, shouldn't it? graesslin: is the cast needed at all? It should be implicitly casted from int to real, shouldn't it? | |||||
79 | } | ||||
80 | | ||||
76 | } | 81 | } | ||
77 | } | 82 | } |
Looks like its unused.