Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 2a687146 authored by Fabian Vogt's avatar Fabian Vogt Committed by Albert Vaca Cintora

Add detectPlatform to always use wayland in a wayland session

It's possible that Qt uses the xcb platform by default even in a Wayland
session, so detect such cases and switch to wayland instead to enable
proper support for remote input. Copy code from libkworkspace to not
introduce a dependency.

Test Plan: Started kdeconnectd, uses wayland platform now. Remote input works.

Reviewers: #kde_connect, nicolasfella

Reviewed By: #kde_connect, nicolasfella

Subscribers: kdeconnect

Tags: #kde_connect

Differential Revision:
parent 6c668949
......@@ -98,8 +98,35 @@ private:
QNetworkAccessManager* m_nam;
// Copied from plasma-workspace/libkworkspace/kworkspace.cpp
static void detectPlatform(int argc, char **argv)
if (qEnvironmentVariableIsSet("QT_QPA_PLATFORM")) {
for (int i = 0; i < argc; i++) {
if (qstrcmp(argv[i], "-platform") == 0 ||
qstrcmp(argv[i], "--platform") == 0 ||
QByteArray(argv[i]).startsWith("-platform=") ||
QByteArray(argv[i]).startsWith("--platform=")) {
const QByteArray sessionType = qgetenv("XDG_SESSION_TYPE");
if (sessionType.isEmpty()) {
if (qstrcmp(sessionType, "wayland") == 0) {
qputenv("QT_QPA_PLATFORM", "wayland");
} else if (qstrcmp(sessionType, "x11") == 0) {
qputenv("QT_QPA_PLATFORM", "xcb");
int main(int argc, char* argv[])
detectPlatform(argc, argv);
QApplication app(argc, argv);
KAboutData aboutData(
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment