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 68 Lines • ▼ Show 20 Line(s) | 114 | { | |||
111 | return new Edge(edges); | 115 | return new Edge(edges); | ||
112 | } | 116 | } | ||
113 | 117 | | |||
114 | void Platform::createPlatformCursor(QObject *parent) | 118 | void Platform::createPlatformCursor(QObject *parent) | ||
115 | { | 119 | { | ||
116 | new InputRedirectionCursor(parent); | 120 | new InputRedirectionCursor(parent); | ||
117 | } | 121 | } | ||
118 | 122 | | |||
119 | void Platform::configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) | 123 | void Platform::requestOutputsChange(KWayland::Server::OutputConfigurationInterface *config) | ||
120 | { | 124 | { | ||
125 | if (!m_supportsOutputChanges) { | ||||
121 | qCWarning(KWIN_CORE) << "This backend does not support configuration changes."; | 126 | qCWarning(KWIN_CORE) << "This backend does not support configuration changes."; | ||
122 | | ||||
123 | config->setFailed(); | 127 | config->setFailed(); | ||
128 | return; | ||||
129 | } | ||||
130 | | ||||
131 | using Enablement = KWayland::Server::OutputDeviceInterface::Enablement; | ||||
132 | | ||||
133 | const auto changes = config->changes(); | ||||
134 | bool countChanged = false; | ||||
135 | | ||||
136 | //process all non-disabling changes | ||||
137 | for (auto it = changes.begin(); it != changes.end(); it++) { | ||||
138 | const KWayland::Server::OutputChangeSet *changeset = it.value(); | ||||
139 | | ||||
140 | auto output = findOutput(it.key()->uuid()); | ||||
141 | if (!output) { | ||||
142 | qCWarning(KWIN_CORE) << "Could NOT find output matching " << it.key()->uuid(); | ||||
143 | continue; | ||||
144 | } | ||||
145 | | ||||
146 | if (changeset->enabledChanged() && | ||||
147 | changeset->enabled() == Enablement::Enabled) { | ||||
148 | output->setEnabled(true); | ||||
149 | enableOutput(output, true); | ||||
150 | countChanged = true; | ||||
151 | } | ||||
152 | output->applyChanges(changeset); | ||||
153 | } | ||||
154 | | ||||
155 | //process any disable requests | ||||
156 | for (auto it = changes.begin(); it != changes.end(); it++) { | ||||
157 | const KWayland::Server::OutputChangeSet *changeset = it.value(); | ||||
158 | | ||||
159 | if (changeset->enabledChanged() && | ||||
160 | changeset->enabled() == Enablement::Disabled) { | ||||
161 | if (enabledOutputs().count() == 1) { | ||||
162 | // TODO: check beforehand this condition and set failed otherwise | ||||
163 | // TODO: instead create a dummy output? | ||||
164 | qCWarning(KWIN_CORE) << "Not disabling final screen" << it.key()->uuid(); | ||||
165 | continue; | ||||
166 | } | ||||
167 | auto output = findOutput(it.key()->uuid()); | ||||
168 | if (!output) { | ||||
169 | qCWarning(KWIN_CORE) << "Could NOT find output matching " << it.key()->uuid(); | ||||
170 | continue; | ||||
171 | } | ||||
172 | output->setEnabled(false); | ||||
173 | enableOutput(output, false); | ||||
174 | countChanged = true; | ||||
175 | } | ||||
176 | } | ||||
177 | | ||||
178 | if (countChanged) { | ||||
179 | emit screensQueried(); | ||||
180 | } else { | ||||
181 | emit screens()->changed(); | ||||
182 | } | ||||
183 | config->setApplied(); | ||||
184 | } | ||||
185 | | ||||
186 | AbstractOutput *Platform::findOutput(const QByteArray &uuid) | ||||
187 | { | ||||
188 | const auto outs = outputs(); | ||||
189 | auto it = std::find_if(outs.constBegin(), outs.constEnd(), | ||||
190 | [uuid](AbstractOutput *output) { | ||||
191 | return output->uuid() == uuid; } | ||||
192 | ); | ||||
193 | if (it != outs.constEnd()) { | ||||
194 | return *it; | ||||
195 | } | ||||
196 | return nullptr; | ||||
197 | } | ||||
198 | | ||||
199 | void Platform::enableOutput(AbstractOutput *output, bool enable) | ||||
200 | { | ||||
201 | Q_UNUSED(output) | ||||
202 | Q_UNUSED(enable) | ||||
124 | } | 203 | } | ||
125 | 204 | | |||
126 | void Platform::setSoftWareCursor(bool set) | 205 | void Platform::setSoftWareCursor(bool set) | ||
127 | { | 206 | { | ||
128 | if (qEnvironmentVariableIsSet("KWIN_FORCE_SW_CURSOR")) { | 207 | if (qEnvironmentVariableIsSet("KWIN_FORCE_SW_CURSOR")) { | ||
129 | set = true; | 208 | set = true; | ||
130 | } | 209 | } | ||
131 | if (m_softWareCursor == set) { | 210 | if (m_softWareCursor == set) { | ||
▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines |