Changeset View
Changeset View
Standalone View
Standalone View
platform.cpp
Show All 12 Lines | |||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
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 "platform.h" | 20 | #include "platform.h" | ||
21 | | ||||
22 | #include "abstract_output.h" | ||||
21 | #include <config-kwin.h> | 23 | #include <config-kwin.h> | ||
22 | #include "composite.h" | 24 | #include "composite.h" | ||
23 | #include "cursor.h" | 25 | #include "cursor.h" | ||
24 | #include "effects.h" | 26 | #include "effects.h" | ||
25 | #include <KCoreAddons> | 27 | #include <KCoreAddons> | ||
26 | #include "overlaywindow.h" | 28 | #include "overlaywindow.h" | ||
27 | #include "outline.h" | 29 | #include "outline.h" | ||
28 | #include "pointer_input.h" | 30 | #include "pointer_input.h" | ||
29 | #include "scene.h" | 31 | #include "scene.h" | ||
32 | #include "screens.h" | ||||
30 | #include "screenedge.h" | 33 | #include "screenedge.h" | ||
31 | #include "wayland_server.h" | 34 | #include "wayland_server.h" | ||
32 | #include "colorcorrection/manager.h" | 35 | #include "colorcorrection/manager.h" | ||
33 | 36 | | |||
34 | #include <KWayland/Server/outputconfiguration_interface.h> | 37 | #include <KWayland/Server/outputconfiguration_interface.h> | ||
38 | #include <KWayland/Server/outputchangeset.h> | ||||
35 | 39 | | |||
36 | namespace KWin | 40 | namespace KWin | ||
37 | { | 41 | { | ||
38 | 42 | | |||
39 | Platform::Platform(QObject *parent) | 43 | Platform::Platform(QObject *parent) | ||
40 | : QObject(parent) | 44 | : QObject(parent) | ||
41 | , m_eglDisplay(EGL_NO_DISPLAY) | 45 | , m_eglDisplay(EGL_NO_DISPLAY) | ||
42 | { | 46 | { | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 119 | { | |||
116 | return new Edge(edges); | 120 | return new Edge(edges); | ||
117 | } | 121 | } | ||
118 | 122 | | |||
119 | void Platform::createPlatformCursor(QObject *parent) | 123 | void Platform::createPlatformCursor(QObject *parent) | ||
120 | { | 124 | { | ||
121 | new InputRedirectionCursor(parent); | 125 | new InputRedirectionCursor(parent); | ||
122 | } | 126 | } | ||
123 | 127 | | |||
124 | void Platform::configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) | 128 | void Platform::requestOutputsChange(KWayland::Server::OutputConfigurationInterface *config) | ||
125 | { | 129 | { | ||
130 | if (!m_supportsOutputChanges) { | ||||
126 | qCWarning(KWIN_CORE) << "This backend does not support configuration changes."; | 131 | qCWarning(KWIN_CORE) << "This backend does not support configuration changes."; | ||
127 | | ||||
128 | config->setFailed(); | 132 | config->setFailed(); | ||
133 | return; | ||||
134 | } | ||||
135 | | ||||
136 | using Enablement = KWayland::Server::OutputDeviceInterface::Enablement; | ||||
137 | | ||||
138 | const auto changes = config->changes(); | ||||
139 | bool countChanged = false; | ||||
140 | | ||||
141 | //process all non-disabling changes | ||||
142 | for (auto it = changes.begin(); it != changes.end(); it++) { | ||||
143 | const KWayland::Server::OutputChangeSet *changeset = it.value(); | ||||
144 | | ||||
145 | auto output = findOutput(it.key()->uuid()); | ||||
146 | if (!output) { | ||||
147 | qCWarning(KWIN_CORE) << "Could NOT find output matching " << it.key()->uuid(); | ||||
148 | continue; | ||||
149 | } | ||||
150 | | ||||
151 | if (changeset->enabledChanged() && | ||||
152 | changeset->enabled() == Enablement::Enabled) { | ||||
153 | output->setEnabled(true); | ||||
154 | enableOutput(output, true); | ||||
155 | countChanged = true; | ||||
156 | } | ||||
157 | output->applyChanges(changeset); | ||||
158 | } | ||||
159 | | ||||
160 | //process any disable requests | ||||
161 | for (auto it = changes.begin(); it != changes.end(); it++) { | ||||
162 | const KWayland::Server::OutputChangeSet *changeset = it.value(); | ||||
163 | | ||||
164 | if (changeset->enabledChanged() && | ||||
165 | changeset->enabled() == Enablement::Disabled) { | ||||
166 | if (enabledOutputs().count() == 1) { | ||||
167 | // TODO: check beforehand this condition and set failed otherwise | ||||
168 | // TODO: instead create a dummy output? | ||||
169 | qCWarning(KWIN_CORE) << "Not disabling final screen" << it.key()->uuid(); | ||||
170 | continue; | ||||
171 | } | ||||
172 | auto output = findOutput(it.key()->uuid()); | ||||
173 | if (!output) { | ||||
174 | qCWarning(KWIN_CORE) << "Could NOT find output matching " << it.key()->uuid(); | ||||
175 | continue; | ||||
176 | } | ||||
177 | output->setEnabled(false); | ||||
178 | enableOutput(output, false); | ||||
179 | countChanged = true; | ||||
180 | } | ||||
181 | } | ||||
182 | | ||||
183 | if (countChanged) { | ||||
184 | emit screensQueried(); | ||||
185 | } else { | ||||
186 | emit screens()->changed(); | ||||
187 | } | ||||
188 | config->setApplied(); | ||||
189 | } | ||||
190 | | ||||
191 | AbstractOutput *Platform::findOutput(const QByteArray &uuid) | ||||
192 | { | ||||
193 | const auto outs = outputs(); | ||||
194 | auto it = std::find_if(outs.constBegin(), outs.constEnd(), | ||||
195 | [uuid](AbstractOutput *output) { | ||||
196 | return output->uuid() == uuid; } | ||||
197 | ); | ||||
198 | if (it != outs.constEnd()) { | ||||
199 | return *it; | ||||
200 | } | ||||
201 | return nullptr; | ||||
202 | } | ||||
203 | | ||||
204 | void Platform::enableOutput(AbstractOutput *output, bool enable) | ||||
205 | { | ||||
206 | Q_UNUSED(output) | ||||
207 | Q_UNUSED(enable) | ||||
129 | } | 208 | } | ||
130 | 209 | | |||
131 | void Platform::setSoftWareCursor(bool set) | 210 | void Platform::setSoftWareCursor(bool set) | ||
132 | { | 211 | { | ||
133 | if (qEnvironmentVariableIsSet("KWIN_FORCE_SW_CURSOR")) { | 212 | if (qEnvironmentVariableIsSet("KWIN_FORCE_SW_CURSOR")) { | ||
134 | set = true; | 213 | set = true; | ||
135 | } | 214 | } | ||
136 | if (m_softWareCursor == set) { | 215 | if (m_softWareCursor == set) { | ||
▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines |