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 | #include "wayland_server.h" | ||||
22 | | ||||
23 | // KWayland | ||||
24 | #include <KWayland/Server/output_interface.h> | ||||
25 | #include <KWayland/Server/outputchangeset.h> | ||||
26 | #include <KWayland/Server/outputdevice_interface.h> | ||||
27 | #include <KWayland/Server/xdgoutput_interface.h> | ||||
28 | // KF5 | ||||
29 | #include <KLocalizedString> | ||||
30 | | ||||
31 | namespace KWin | ||||
32 | { | ||||
33 | | ||||
34 | Output::~Output() | ||||
35 | { | ||||
36 | delete m_waylandOutputDevice.data(); | ||||
37 | delete m_xdgOutput.data(); | ||||
38 | delete m_waylandOutput.data(); | ||||
39 | } | ||||
40 | | ||||
41 | QString Output::name() const | ||||
42 | { | ||||
43 | if (!m_waylandOutput) { | ||||
44 | return i18n("unknown"); | ||||
45 | } | ||||
46 | return QStringLiteral("%1 %2").arg(m_waylandOutput->manufacturer()).arg(m_waylandOutput->model()); | ||||
47 | } | ||||
48 | | ||||
49 | QRect Output::geometry() const | ||||
50 | { | ||||
51 | return QRect(m_globalPos, pixelSize() / scale()); | ||||
52 | } | ||||
53 | | ||||
54 | QSize Output::physicalSize() const | ||||
55 | { | ||||
56 | if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) { | ||||
57 | return QSize(m_physicalSize.height(), m_physicalSize.width()); | ||||
58 | } | ||||
59 | return m_physicalSize; | ||||
60 | } | ||||
61 | | ||||
62 | void Output::setGlobalPos(const QPoint &pos) | ||||
63 | { | ||||
64 | m_globalPos = pos; | ||||
65 | if (m_waylandOutput) { | ||||
66 | m_waylandOutput->setGlobalPosition(pos); | ||||
67 | } | ||||
68 | if (m_waylandOutputDevice) { | ||||
69 | m_waylandOutputDevice->setGlobalPosition(pos); | ||||
70 | } | ||||
71 | if (m_xdgOutput) { | ||||
72 | m_xdgOutput->setLogicalPosition(pos); | ||||
73 | m_xdgOutput->done(); | ||||
74 | } | ||||
75 | } | ||||
76 | | ||||
77 | void Output::setScale(qreal scale) | ||||
78 | { | ||||
79 | m_scale = scale; | ||||
80 | if (m_waylandOutput) { | ||||
81 | m_waylandOutput->setScale(scale); | ||||
82 | } | ||||
83 | if (m_waylandOutputDevice) { | ||||
84 | m_waylandOutputDevice->setScale(scale); | ||||
85 | } | ||||
86 | if (m_xdgOutput) { | ||||
87 | m_xdgOutput->setLogicalSize(pixelSize() / m_scale); | ||||
88 | m_xdgOutput->done(); | ||||
89 | } | ||||
90 | } | ||||
91 | | ||||
92 | void Output::setChanges(KWayland::Server::OutputChangeSet *changes) | ||||
93 | { | ||||
94 | m_changeset = changes; | ||||
95 | qCDebug(KWIN_CORE) << "set changes in Output"; | ||||
96 | commitChanges(); | ||||
97 | } | ||||
98 | | ||||
99 | void Output::setWaylandOutput(KWayland::Server::OutputInterface *set) | ||||
100 | { | ||||
101 | m_waylandOutput = set; | ||||
102 | } | ||||
103 | | ||||
104 | void Output::createXdgOutput() | ||||
105 | { | ||||
106 | if (!m_waylandOutput || m_xdgOutput) { | ||||
107 | return; | ||||
108 | } | ||||
109 | m_xdgOutput = waylandServer()->xdgOutputManager()->createXdgOutput(m_waylandOutput, m_waylandOutput); | ||||
110 | } | ||||
111 | | ||||
112 | void Output::setWaylandOutputDevice(KWayland::Server::OutputDeviceInterface *set) | ||||
113 | { | ||||
114 | m_waylandOutputDevice = set; | ||||
115 | } | ||||
116 | | ||||
117 | } |