diff options
author | Robert Griebl <robert.griebl@pelagicore.com> | 2019-08-08 13:03:59 +0200 |
---|---|---|
committer | Robert Griebl <robert.griebl@pelagicore.com> | 2019-08-08 16:30:54 +0200 |
commit | 1e46e362b2032264254c479acd5a32174f7c8450 (patch) | |
tree | 8f03a864ee5a0c05e0a834bf72c4dd1b2ad0fe5f | |
parent | 436cde32425b52dae88d8c932d8d0ab0a7f7d502 (diff) |
Ignore $WAYLAND_DISPLAY when starting on Wayland desktop environments
Normally the AM would honor the $WAYLAND_DISPLAY environment variable, but
this is always set to "wayland-0" on Wayland desktop environments which
messes up the AM.
We now ignore the env. variable if the the platform is "wayland" and the
value of the variable is "wayland-0".
Change-Id: I831660879b877ecfa2b03e8b01b4fa501a90517f
Reviewed-by: Vladimir Minenko <vladimir.minenko@pelagicore.com>
Reviewed-by: Bernd Weimer <bernd.weimer@pelagicore.com>
-rw-r--r-- | src/main-lib/defaultconfiguration.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/main-lib/defaultconfiguration.cpp b/src/main-lib/defaultconfiguration.cpp index 9802fa98..6ba3bada 100644 --- a/src/main-lib/defaultconfiguration.cpp +++ b/src/main-lib/defaultconfiguration.cpp @@ -49,6 +49,10 @@ # include <sys/file.h> #endif +#if !defined(AM_HEADLESS) +# include <QGuiApplication> +#endif + #include <QtAppManCommon/logging.h> #include "defaultconfiguration.h" @@ -454,22 +458,26 @@ int DefaultConfiguration::quickLaunchRuntimesPerContainer() const QString DefaultConfiguration::waylandSocketName() const { - const QString socket = m_clp.value(qSL("wayland-socket-name")); // get the default value - if (!socket.isEmpty()) - return socket; +#if !defined(AM_HEADLESS) + QString socketName = m_clp.value(qSL("wayland-socket-name")); // get the default value + if (!socketName.isEmpty()) + return socketName; const char *envName = "WAYLAND_DISPLAY"; - if (qEnvironmentVariableIsSet(envName)) - return qEnvironmentVariable(envName); + if (qEnvironmentVariableIsSet(envName)) { + socketName = qEnvironmentVariable(envName); + if (!QGuiApplication::platformName().startsWith(qSL("wayland")) || (socketName != qSL("wayland-0"))) + return socketName; + } -#if defined(Q_OS_LINUX) +# if defined(Q_OS_LINUX) // modelled after wl_socket_lock() in wayland_server.c const QString xdgDir = qEnvironmentVariable("XDG_RUNTIME_DIR") + qSL("/"); const QString pattern = qSL("qtam-wayland-%1"); const QString lockSuffix = qSL(".lock"); for (int i = 0; i < 32; ++i) { - const QString socketName = pattern.arg(i); + socketName = pattern.arg(i); QFile lock(xdgDir + socketName + lockSuffix); if (lock.open(QIODevice::ReadWrite)) { if (::flock(lock.handle(), LOCK_EX | LOCK_NB) == 0) { @@ -479,6 +487,7 @@ QString DefaultConfiguration::waylandSocketName() const } } } +# endif #endif return QString(); } |