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 | QString Output::name() const | ||||
33 | { | ||||
34 | if (!m_waylandOutput) { | ||||
35 | return i18n("unknown"); | ||||
36 | } | ||||
37 | return QStringLiteral("%1 %2").arg(m_waylandOutput->manufacturer()).arg(m_waylandOutput->model()); | ||||
38 | } | ||||
39 | | ||||
40 | QRect Output::geometry() const | ||||
41 | { | ||||
42 | return QRect(m_globalPos, pixelSize() / scale()); | ||||
43 | } | ||||
44 | | ||||
45 | QSize Output::physicalSize() const | ||||
46 | { | ||||
47 | if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) { | ||||
48 | return QSize(m_physicalSize.height(), m_physicalSize.width()); | ||||
49 | } | ||||
50 | return m_physicalSize; | ||||
51 | } | ||||
52 | | ||||
53 | void Output::setGlobalPos(const QPoint &pos) | ||||
54 | { | ||||
55 | m_globalPos = pos; | ||||
56 | if (m_waylandOutput) { | ||||
57 | m_waylandOutput->setGlobalPosition(pos); | ||||
58 | } | ||||
59 | if (m_waylandOutputDevice) { | ||||
60 | m_waylandOutputDevice->setGlobalPosition(pos); | ||||
61 | } | ||||
62 | } | ||||
63 | | ||||
64 | void Output::setScale(qreal scale) | ||||
65 | { | ||||
66 | m_scale = scale; | ||||
67 | if (m_waylandOutput) { | ||||
68 | m_waylandOutput->setScale(scale); | ||||
69 | } | ||||
70 | if (m_waylandOutputDevice) { | ||||
71 | m_waylandOutputDevice->setScale(scale); | ||||
72 | } | ||||
73 | } | ||||
74 | | ||||
75 | void Output::setChanges(KWayland::Server::OutputChangeSet *changes) | ||||
76 | { | ||||
77 | m_changeset = changes; | ||||
78 | qCDebug(KWIN_CORE) << "set changes in Output"; | ||||
79 | commitChanges(); | ||||
80 | } | ||||
81 | | ||||
82 | void Output::setWaylandOutput(KWayland::Server::OutputInterface *set) | ||||
83 | { | ||||
84 | m_waylandOutput = set; | ||||
85 | } | ||||
86 | | ||||
87 | void Output::setWaylandOutputDevice(KWayland::Server::OutputDeviceInterface *set) | ||||
88 | { | ||||
89 | m_waylandOutputDevice = set; | ||||
90 | } | ||||
91 | | ||||
92 | } |