Add detectPlatform to always use wayland in a wayland session
Summary: 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: https://phabricator.kde.org/D22562
This commit is contained in:
parent
086ceb6140
commit
f765ffb186
1 changed files with 27 additions and 0 deletions
|
@ -90,8 +90,35 @@ private:
|
|||
QNetworkAccessManager* m_nam;
|
||||
};
|
||||
|
||||
// Copied from plasma-workspace/libkworkspace/kworkspace.cpp
|
||||
static void detectPlatform(int argc, char **argv)
|
||||
{
|
||||
if (qEnvironmentVariableIsSet("QT_QPA_PLATFORM")) {
|
||||
return;
|
||||
}
|
||||
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=")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const QByteArray sessionType = qgetenv("XDG_SESSION_TYPE");
|
||||
if (sessionType.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
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(
|
||||
QStringLiteral("org.kde.kdeconnect.daemon"),
|
||||
|
|
Loading…
Reference in a new issue