Changeset View
Changeset View
Standalone View
Standalone View
abstract_output.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 "abstract_output.h" | 20 | #include "abstract_output.h" | ||
21 | #include "wayland_server.h" | 21 | #include "wayland_server.h" | ||
22 | 22 | | |||
23 | // KWayland | 23 | // KWayland | ||
24 | #include <KWayland/Server/display.h> | 24 | #include <KWayland/Server/display.h> | ||
25 | #include <KWayland/Server/output_interface.h> | | |||
26 | #include <KWayland/Server/outputchangeset.h> | 25 | #include <KWayland/Server/outputchangeset.h> | ||
27 | #include <KWayland/Server/xdgoutput_interface.h> | 26 | #include <KWayland/Server/xdgoutput_interface.h> | ||
28 | // KF5 | 27 | // KF5 | ||
29 | #include <KLocalizedString> | 28 | #include <KLocalizedString> | ||
30 | 29 | | |||
31 | #include <cmath> | 30 | #include <cmath> | ||
32 | 31 | | |||
33 | namespace KWin | 32 | namespace KWin | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 147 | { | |||
152 | m_xdgOutput = waylandServer()->xdgOutputManager()->createXdgOutput(m_waylandOutput, m_waylandOutput); | 151 | m_xdgOutput = waylandServer()->xdgOutputManager()->createXdgOutput(m_waylandOutput, m_waylandOutput); | ||
153 | } | 152 | } | ||
154 | 153 | | |||
155 | void AbstractOutput::setWaylandOutputDevice(KWayland::Server::OutputDeviceInterface *set) | 154 | void AbstractOutput::setWaylandOutputDevice(KWayland::Server::OutputDeviceInterface *set) | ||
156 | { | 155 | { | ||
157 | m_waylandOutputDevice = set; | 156 | m_waylandOutputDevice = set; | ||
158 | } | 157 | } | ||
159 | 158 | | |||
160 | void AbstractOutput::initWaylandOutput() | 159 | void AbstractOutput::initWaylandOutput(bool dpmsSupported) | ||
161 | { | 160 | { | ||
162 | Q_ASSERT(m_waylandOutputDevice); | 161 | Q_ASSERT(m_waylandOutputDevice); | ||
163 | 162 | | |||
164 | if (!m_waylandOutput.isNull()) { | 163 | if (!m_waylandOutput.isNull()) { | ||
165 | delete m_waylandOutput.data(); | 164 | delete m_waylandOutput.data(); | ||
166 | m_waylandOutput.clear(); | 165 | m_waylandOutput.clear(); | ||
167 | } | 166 | } | ||
168 | m_waylandOutput = waylandServer()->display()->createOutput(); | 167 | m_waylandOutput = waylandServer()->display()->createOutput(); | ||
169 | createXdgOutput(); | 168 | createXdgOutput(); | ||
170 | 169 | | |||
170 | /* | ||||
171 | * add base wayland output data | ||||
172 | */ | ||||
171 | m_waylandOutput->setManufacturer(m_waylandOutputDevice->manufacturer()); | 173 | m_waylandOutput->setManufacturer(m_waylandOutputDevice->manufacturer()); | ||
172 | m_waylandOutput->setModel(m_waylandOutputDevice->model()); | 174 | m_waylandOutput->setModel(m_waylandOutputDevice->model()); | ||
173 | m_waylandOutput->setPhysicalSize(rawPhysicalSize()); | 175 | m_waylandOutput->setPhysicalSize(rawPhysicalSize()); | ||
174 | 176 | | |||
177 | /* | ||||
178 | * add modes | ||||
179 | */ | ||||
175 | for(const auto &mode: m_waylandOutputDevice->modes()) { | 180 | for(const auto &mode: m_waylandOutputDevice->modes()) { | ||
176 | KWayland::Server::OutputInterface::ModeFlags flags; | 181 | KWayland::Server::OutputInterface::ModeFlags flags; | ||
177 | if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Current) { | 182 | if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Current) { | ||
178 | flags |= KWayland::Server::OutputInterface::ModeFlag::Current; | 183 | flags |= KWayland::Server::OutputInterface::ModeFlag::Current; | ||
179 | } | 184 | } | ||
180 | if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Preferred) { | 185 | if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Preferred) { | ||
181 | flags |= KWayland::Server::OutputInterface::ModeFlag::Preferred; | 186 | flags |= KWayland::Server::OutputInterface::ModeFlag::Preferred; | ||
182 | } | 187 | } | ||
183 | m_waylandOutput->addMode(mode.size, flags, mode.refreshRate); | 188 | m_waylandOutput->addMode(mode.size, flags, mode.refreshRate); | ||
184 | } | 189 | } | ||
185 | m_waylandOutput->create(); | 190 | m_waylandOutput->create(); | ||
191 | | ||||
192 | /* | ||||
193 | * set dpms | ||||
194 | */ | ||||
195 | m_waylandOutput->setDpmsSupported(dpmsSupported); | ||||
davidedmundson: This should be a virtual into the platform. | |||||
romangg: Good catch! I opted for a simple variable for now. | |||||
That isn't going to work, at some point you move initWaylandOutput into being done AbstractOutput::setEnabled. Also the patch seems messed up you set the mode twice? davidedmundson: That isn't going to work, at some point you move initWaylandOutput into being done… | |||||
romangg: Hmm, true.
Where do I set the mode a second time? | |||||
davidedmundson: You don't, ignore that last bit | |||||
196 | // set to last known mode | ||||
197 | m_waylandOutput->setDpmsMode(m_dpms); | ||||
198 | connect(m_waylandOutput.data(), &KWayland::Server::OutputInterface::dpmsModeRequested, this, | ||||
199 | [this] (KWayland::Server::OutputInterface::DpmsMode mode) { | ||||
200 | updateDpms(mode); | ||||
201 | }, Qt::QueuedConnection | ||||
202 | ); | ||||
186 | } | 203 | } | ||
187 | 204 | | |||
188 | } | 205 | } |
This should be a virtual into the platform.