Changeset View
Changeset View
Standalone View
Standalone View
abstract_wayland_output.cpp
Show All 18 Lines | |||||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 20 | *********************************************************************/ | ||
21 | #include "abstract_wayland_output.h" | 21 | #include "abstract_wayland_output.h" | ||
22 | 22 | | |||
23 | #include "screens.h" | 23 | #include "screens.h" | ||
24 | #include "wayland_server.h" | 24 | #include "wayland_server.h" | ||
25 | 25 | | |||
26 | // KWayland | 26 | // KWayland | ||
27 | #include <KWayland/Server/display.h> | 27 | #include <KWaylandServer/display.h> | ||
28 | #include <KWayland/Server/outputchangeset.h> | 28 | #include <KWaylandServer/outputchangeset.h> | ||
29 | #include <KWayland/Server/xdgoutput_interface.h> | 29 | #include <KWaylandServer/xdgoutput_interface.h> | ||
30 | // KF5 | 30 | // KF5 | ||
31 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
32 | 32 | | |||
33 | #include <cmath> | 33 | #include <cmath> | ||
34 | 34 | | |||
35 | namespace KWin | 35 | namespace KWin | ||
36 | { | 36 | { | ||
37 | 37 | | |||
38 | AbstractWaylandOutput::AbstractWaylandOutput(QObject *parent) | 38 | AbstractWaylandOutput::AbstractWaylandOutput(QObject *parent) | ||
39 | : AbstractOutput(parent) | 39 | : AbstractOutput(parent) | ||
40 | { | 40 | { | ||
41 | m_waylandOutput = waylandServer()->display()->createOutput(this); | 41 | m_waylandOutput = waylandServer()->display()->createOutput(this); | ||
42 | m_waylandOutputDevice = waylandServer()->display()->createOutputDevice(this); | 42 | m_waylandOutputDevice = waylandServer()->display()->createOutputDevice(this); | ||
43 | m_xdgOutput = waylandServer()->xdgOutputManager()->createXdgOutput(m_waylandOutput, this); | 43 | m_xdgOutput = waylandServer()->xdgOutputManager()->createXdgOutput(m_waylandOutput, this); | ||
44 | 44 | | |||
45 | connect(m_waylandOutput, &KWayland::Server::OutputInterface::dpmsModeRequested, this, | 45 | connect(m_waylandOutput, &KWaylandServer::OutputInterface::dpmsModeRequested, this, | ||
46 | [this] (KWayland::Server::OutputInterface::DpmsMode mode) { | 46 | [this] (KWaylandServer::OutputInterface::DpmsMode mode) { | ||
47 | updateDpms(mode); | 47 | updateDpms(mode); | ||
48 | }); | 48 | }); | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | AbstractWaylandOutput::~AbstractWaylandOutput() | 51 | AbstractWaylandOutput::~AbstractWaylandOutput() | ||
52 | { | 52 | { | ||
53 | } | 53 | } | ||
54 | 54 | | |||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 110 | { | |||
116 | // I don't know whether we want to round or ceil | 116 | // I don't know whether we want to round or ceil | ||
117 | // or maybe even set this to 3 when we're scaling to 1.5 | 117 | // or maybe even set this to 3 when we're scaling to 1.5 | ||
118 | // don't treat this like it's chosen deliberately | 118 | // don't treat this like it's chosen deliberately | ||
119 | m_waylandOutput->setScale(std::ceil(scale)); | 119 | m_waylandOutput->setScale(std::ceil(scale)); | ||
120 | m_xdgOutput->setLogicalSize(pixelSize() / scale); | 120 | m_xdgOutput->setLogicalSize(pixelSize() / scale); | ||
121 | m_xdgOutput->done(); | 121 | m_xdgOutput->done(); | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | using DeviceInterface = KWayland::Server::OutputDeviceInterface; | 124 | using DeviceInterface = KWaylandServer::OutputDeviceInterface; | ||
125 | 125 | | |||
126 | KWayland::Server::OutputInterface::Transform toOutputTransform(DeviceInterface::Transform transform) | 126 | KWaylandServer::OutputInterface::Transform toOutputTransform(DeviceInterface::Transform transform) | ||
127 | { | 127 | { | ||
128 | using Transform = DeviceInterface::Transform; | 128 | using Transform = DeviceInterface::Transform; | ||
129 | using OutputTransform = KWayland::Server::OutputInterface::Transform; | 129 | using OutputTransform = KWaylandServer::OutputInterface::Transform; | ||
130 | 130 | | |||
131 | switch (transform) { | 131 | switch (transform) { | ||
132 | case Transform::Rotated90: | 132 | case Transform::Rotated90: | ||
133 | return OutputTransform::Rotated90; | 133 | return OutputTransform::Rotated90; | ||
134 | case Transform::Rotated180: | 134 | case Transform::Rotated180: | ||
135 | return OutputTransform::Rotated180; | 135 | return OutputTransform::Rotated180; | ||
136 | case Transform::Rotated270: | 136 | case Transform::Rotated270: | ||
137 | return OutputTransform::Rotated270; | 137 | return OutputTransform::Rotated270; | ||
Show All 26 Lines | |||||
164 | } | 164 | } | ||
165 | 165 | | |||
166 | inline | 166 | inline | ||
167 | DeviceInterface::Transform toDeviceTransform(AbstractWaylandOutput::Transform transform) | 167 | DeviceInterface::Transform toDeviceTransform(AbstractWaylandOutput::Transform transform) | ||
168 | { | 168 | { | ||
169 | return static_cast<DeviceInterface::Transform>(transform); | 169 | return static_cast<DeviceInterface::Transform>(transform); | ||
170 | } | 170 | } | ||
171 | 171 | | |||
172 | void AbstractWaylandOutput::applyChanges(const KWayland::Server::OutputChangeSet *changeSet) | 172 | void AbstractWaylandOutput::applyChanges(const KWaylandServer::OutputChangeSet *changeSet) | ||
173 | { | 173 | { | ||
174 | qCDebug(KWIN_CORE) << "Apply changes to the Wayland output."; | 174 | qCDebug(KWIN_CORE) << "Apply changes to the Wayland output."; | ||
175 | bool emitModeChanged = false; | 175 | bool emitModeChanged = false; | ||
176 | bool overallSizeCheckNeeded = false; | 176 | bool overallSizeCheckNeeded = false; | ||
177 | 177 | | |||
178 | // Enablement changes are handled by platform. | 178 | // Enablement changes are handled by platform. | ||
179 | if (changeSet->modeChanged()) { | 179 | if (changeSet->modeChanged()) { | ||
180 | qCDebug(KWIN_CORE) << "Setting new mode:" << changeSet->mode(); | 180 | qCDebug(KWIN_CORE) << "Setting new mode:" << changeSet->mode(); | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 252 | { | |||
265 | m_waylandOutput->setModel(m_waylandOutputDevice->model()); | 265 | m_waylandOutput->setModel(m_waylandOutputDevice->model()); | ||
266 | m_waylandOutput->setPhysicalSize(m_waylandOutputDevice->physicalSize()); | 266 | m_waylandOutput->setPhysicalSize(m_waylandOutputDevice->physicalSize()); | ||
267 | 267 | | |||
268 | int i = 0; | 268 | int i = 0; | ||
269 | for (auto mode : modes) { | 269 | for (auto mode : modes) { | ||
270 | qCDebug(KWIN_CORE).nospace() << "Adding mode " << ++i << ": " << mode.size << " [" << mode.refreshRate << "]"; | 270 | qCDebug(KWIN_CORE).nospace() << "Adding mode " << ++i << ": " << mode.size << " [" << mode.refreshRate << "]"; | ||
271 | m_waylandOutputDevice->addMode(mode); | 271 | m_waylandOutputDevice->addMode(mode); | ||
272 | 272 | | |||
273 | KWayland::Server::OutputInterface::ModeFlags flags; | 273 | KWaylandServer::OutputInterface::ModeFlags flags; | ||
274 | if (mode.flags & DeviceInterface::ModeFlag::Current) { | 274 | if (mode.flags & DeviceInterface::ModeFlag::Current) { | ||
275 | flags |= KWayland::Server::OutputInterface::ModeFlag::Current; | 275 | flags |= KWaylandServer::OutputInterface::ModeFlag::Current; | ||
276 | } | 276 | } | ||
277 | if (mode.flags & DeviceInterface::ModeFlag::Preferred) { | 277 | if (mode.flags & DeviceInterface::ModeFlag::Preferred) { | ||
278 | flags |= KWayland::Server::OutputInterface::ModeFlag::Preferred; | 278 | flags |= KWaylandServer::OutputInterface::ModeFlag::Preferred; | ||
279 | } | 279 | } | ||
280 | m_waylandOutput->addMode(mode.size, flags, mode.refreshRate); | 280 | m_waylandOutput->addMode(mode.size, flags, mode.refreshRate); | ||
281 | } | 281 | } | ||
282 | 282 | | |||
283 | m_waylandOutputDevice->create(); | 283 | m_waylandOutputDevice->create(); | ||
284 | 284 | | |||
285 | // start off enabled | 285 | // start off enabled | ||
286 | 286 | | |||
Show All 34 Lines |