Changeset View
Changeset View
Standalone View
Standalone View
output.cpp
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | ||||
3 | This file is part of the KDE project. | ||||
4 | | ||||
5 | Copyright 2018 Roman Gilg <subdiff@gmail.com> | ||||
6 | | ||||
7 | This program is free software; you can redistribute it and/or modify | ||||
8 | it under the terms of the GNU General Public License as published by | ||||
9 | the Free Software Foundation; either version 2 of the License, or | ||||
10 | (at your option) any later version. | ||||
11 | | ||||
12 | This program is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | GNU General Public License for more details. | ||||
16 | | ||||
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/>. | ||||
19 | *********************************************************************/ | ||||
20 | #include "output.h" | ||||
21 | | ||||
22 | // KWayland | ||||
23 | #include <KWayland/Server/output_interface.h> | ||||
24 | #include <KWayland/Server/outputchangeset.h> | ||||
25 | #include <KWayland/Server/outputdevice_interface.h> | ||||
26 | // KF5 | ||||
27 | #include <KLocalizedString> | ||||
28 | | ||||
29 | namespace KWin | ||||
30 | { | ||||
31 | | ||||
32 | Output::~Output() | ||||
33 | { | ||||
34 | delete m_waylandOutputDevice.data(); | ||||
35 | delete m_waylandOutput.data(); | ||||
36 | } | ||||
37 | | ||||
38 | QString Output::name() const | ||||
39 | { | ||||
40 | if (!m_waylandOutput) { | ||||
41 | return i18n("unknown"); | ||||
42 | } | ||||
43 | return QStringLiteral("%1 %2").arg(m_waylandOutput->manufacturer()).arg(m_waylandOutput->model()); | ||||
44 | } | ||||
45 | | ||||
46 | QRect Output::geometry() const | ||||
47 | { | ||||
48 | return QRect(m_globalPos, pixelSize() / scale()); | ||||
49 | } | ||||
50 | | ||||
51 | QSize Output::physicalSize() const | ||||
52 | { | ||||
53 | if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) { | ||||
54 | return QSize(m_physicalSize.height(), m_physicalSize.width()); | ||||
55 | } | ||||
56 | return m_physicalSize; | ||||
57 | } | ||||
58 | | ||||
59 | void Output::setGlobalPos(const QPoint &pos) | ||||
60 | { | ||||
61 | m_globalPos = pos; | ||||
62 | if (m_waylandOutput) { | ||||
63 | m_waylandOutput->setGlobalPosition(pos); | ||||
64 | } | ||||
65 | if (m_waylandOutputDevice) { | ||||
66 | m_waylandOutputDevice->setGlobalPosition(pos); | ||||
67 | } | ||||
68 | } | ||||
69 | | ||||
70 | void Output::setScale(qreal scale) | ||||
71 | { | ||||
72 | m_scale = scale; | ||||
73 | if (m_waylandOutput) { | ||||
74 | m_waylandOutput->setScale(scale); | ||||
75 | } | ||||
76 | if (m_waylandOutputDevice) { | ||||
77 | m_waylandOutputDevice->setScale(scale); | ||||
78 | } | ||||
79 | } | ||||
80 | | ||||
81 | void Output::setChanges(KWayland::Server::OutputChangeSet *changes) | ||||
82 | { | ||||
83 | m_changeset = changes; | ||||
84 | qCDebug(KWIN_CORE) << "set changes in Output"; | ||||
85 | commitChanges(); | ||||
86 | } | ||||
87 | | ||||
88 | void Output::setWaylandOutput(KWayland::Server::OutputInterface *set) | ||||
89 | { | ||||
90 | m_waylandOutput = set; | ||||
91 | } | ||||
92 | | ||||
93 | void Output::setWaylandOutputDevice(KWayland::Server::OutputDeviceInterface *set) | ||||
94 | { | ||||
95 | m_waylandOutputDevice = set; | ||||
96 | } | ||||
97 | | ||||
98 | } |