Changeset View
Changeset View
Standalone View
Standalone View
main_wayland.cpp
Show All 19 Lines | |||||
20 | #include "main_wayland.h" | 20 | #include "main_wayland.h" | ||
21 | #include "composite.h" | 21 | #include "composite.h" | ||
22 | #include "virtualkeyboard.h" | 22 | #include "virtualkeyboard.h" | ||
23 | #include "workspace.h" | 23 | #include "workspace.h" | ||
24 | #include <config-kwin.h> | 24 | #include <config-kwin.h> | ||
25 | // kwin | 25 | // kwin | ||
26 | #include "platform.h" | 26 | #include "platform.h" | ||
27 | #include "effects.h" | 27 | #include "effects.h" | ||
28 | #include "screens.h" | ||||
28 | #include "tabletmodemanager.h" | 29 | #include "tabletmodemanager.h" | ||
29 | #include "wayland_server.h" | 30 | #include "wayland_server.h" | ||
30 | #include "xcbutils.h" | 31 | #include "xcbutils.h" | ||
31 | 32 | | |||
32 | // KWayland | 33 | // KWayland | ||
33 | #include <KWayland/Server/display.h> | 34 | #include <KWayland/Server/display.h> | ||
34 | #include <KWayland/Server/seat_interface.h> | 35 | #include <KWayland/Server/seat_interface.h> | ||
35 | // KDE | 36 | // KDE | ||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 132 | { | |||
160 | } | 161 | } | ||
161 | if (QStyle *s = style()) { | 162 | if (QStyle *s = style()) { | ||
162 | s->unpolish(this); | 163 | s->unpolish(this); | ||
163 | } | 164 | } | ||
164 | waylandServer()->terminateClientConnections(); | 165 | waylandServer()->terminateClientConnections(); | ||
165 | destroyCompositor(); | 166 | destroyCompositor(); | ||
166 | } | 167 | } | ||
167 | 168 | | |||
169 | void ApplicationWayland::setX11Scale(int scale) { | ||||
170 | // TODO: change this to actual release number | ||||
171 | if (m_xwaylandReleaseNumber < 12099000) { | ||||
172 | return; | ||||
173 | } | ||||
174 | m_x11Scale = scale; | ||||
175 | } | ||||
176 | | ||||
168 | void ApplicationWayland::performStartup() | 177 | void ApplicationWayland::performStartup() | ||
169 | { | 178 | { | ||
170 | if (m_startXWayland) { | 179 | if (m_startXWayland) { | ||
171 | setOperationMode(OperationModeXwayland); | 180 | setOperationMode(OperationModeXwayland); | ||
172 | } | 181 | } | ||
173 | // first load options - done internally by a different thread | 182 | // first load options - done internally by a different thread | ||
174 | createOptions(); | 183 | createOptions(); | ||
175 | waylandServer()->createInternalConnection(); | 184 | waylandServer()->createInternalConnection(); | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
221 | void ApplicationWayland::continueStartupWithX() | 230 | void ApplicationWayland::continueStartupWithX() | ||
222 | { | 231 | { | ||
223 | createX11Connection(); | 232 | createX11Connection(); | ||
224 | xcb_connection_t *c = x11Connection(); | 233 | xcb_connection_t *c = x11Connection(); | ||
225 | if (!c) { | 234 | if (!c) { | ||
226 | // about to quit | 235 | // about to quit | ||
227 | return; | 236 | return; | ||
228 | } | 237 | } | ||
238 | | ||||
239 | // Query the XWayland release number to decide if multi dpi support | ||||
240 | // should be enabled. For that force Screens to do a size update | ||||
241 | // TODO: better do this earlier when we provide the arguments for | ||||
242 | // Xwayland binary? | ||||
243 | m_xwaylandReleaseNumber = xcb_get_setup(c)->release_number; | ||||
244 | emit Screens::self()->changed(); | ||||
245 | | ||||
229 | QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(c), QSocketNotifier::Read, this); | 246 | QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(c), QSocketNotifier::Read, this); | ||
230 | auto processXcbEvents = [this, c] { | 247 | auto processXcbEvents = [this, c] { | ||
231 | while (auto event = xcb_poll_for_event(c)) { | 248 | while (auto event = xcb_poll_for_event(c)) { | ||
232 | long result = 0; | 249 | long result = 0; | ||
233 | QThread::currentThread()->eventDispatcher()->filterNativeEvent(QByteArrayLiteral("xcb_generic_event_t"), event, &result); | 250 | QThread::currentThread()->eventDispatcher()->filterNativeEvent(QByteArrayLiteral("xcb_generic_event_t"), event, &result); | ||
234 | free(event); | 251 | free(event); | ||
235 | } | 252 | } | ||
236 | xcb_flush(c); | 253 | xcb_flush(c); | ||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 359 | { | |||
377 | 394 | | |||
378 | m_xwaylandProcess = new Process(kwinApp()); | 395 | m_xwaylandProcess = new Process(kwinApp()); | ||
379 | m_xwaylandProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel); | 396 | m_xwaylandProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel); | ||
380 | m_xwaylandProcess->setProgram(QStringLiteral("Xwayland")); | 397 | m_xwaylandProcess->setProgram(QStringLiteral("Xwayland")); | ||
381 | QProcessEnvironment env = m_environment; | 398 | QProcessEnvironment env = m_environment; | ||
382 | env.insert("WAYLAND_SOCKET", QByteArray::number(wlfd)); | 399 | env.insert("WAYLAND_SOCKET", QByteArray::number(wlfd)); | ||
383 | env.insert("EGL_PLATFORM", QByteArrayLiteral("DRM")); | 400 | env.insert("EGL_PLATFORM", QByteArrayLiteral("DRM")); | ||
384 | m_xwaylandProcess->setProcessEnvironment(env); | 401 | m_xwaylandProcess->setProcessEnvironment(env); | ||
385 | m_xwaylandProcess->setArguments({QStringLiteral("-displayfd"), | 402 | | ||
403 | QStringList arguments = {QStringLiteral("-displayfd"), | ||||
386 | QString::number(pipeFds[1]), | 404 | QString::number(pipeFds[1]), | ||
387 | QStringLiteral("-rootless"), | 405 | QStringLiteral("-rootless"), | ||
388 | QStringLiteral("-wm"), | 406 | QStringLiteral("-wm"), | ||
389 | QString::number(fd)}); | 407 | QString::number(fd)}; | ||
408 | | ||||
409 | // TODO: Make this dependent on the release number. pkgconfig? | ||||
romangg: Pkgconfig wouldn't work on user installs, since it's something installed with dev packages. | |||||
410 | arguments.append(QStringLiteral("-maxFactorRescale")); | ||||
411 | | ||||
412 | m_xwaylandProcess->setArguments(arguments); | ||||
413 | | ||||
390 | m_xwaylandFailConnection = connect(m_xwaylandProcess, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), this, | 414 | m_xwaylandFailConnection = connect(m_xwaylandProcess, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), this, | ||
391 | [] (QProcess::ProcessError error) { | 415 | [] (QProcess::ProcessError error) { | ||
392 | if (error == QProcess::FailedToStart) { | 416 | if (error == QProcess::FailedToStart) { | ||
393 | std::cerr << "FATAL ERROR: failed to start Xwayland" << std::endl; | 417 | std::cerr << "FATAL ERROR: failed to start Xwayland" << std::endl; | ||
394 | } else { | 418 | } else { | ||
395 | std::cerr << "FATAL ERROR: Xwayland failed, going to exit now" << std::endl; | 419 | std::cerr << "FATAL ERROR: Xwayland failed, going to exit now" << std::endl; | ||
396 | } | 420 | } | ||
397 | exit(1); | 421 | exit(1); | ||
▲ Show 20 Lines • Show All 434 Lines • Show Last 20 Lines |
Pkgconfig wouldn't work on user installs, since it's something installed with dev packages.
I'm thinking about adding a -version argument to XWayland, that just returns its version in the raw format the same way it is returned by xcb_get_setup(c)->release_number above (for example 12099000) and then quits.
Then before launching XWayland with all arguments compositors would need to launch XWayland -version first and see if an error is returned because the argument is not known or if not, what's the version number.
Of course one could also just directly try to launch XWayland with the option, but then one would need to redo all the process afterwards in case it fails.