[kwin_wrapper] Sync kwin env after spawning

This commit is contained in:
David Edmundson 2021-08-17 08:53:16 +01:00
parent bf7bdf0be8
commit b3f5f9764f
3 changed files with 21 additions and 4 deletions

View file

@ -74,6 +74,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
ConfigWidgets
CoreAddons
Crash
DBusAddons
GlobalAccel
I18n
IconThemes

View file

@ -16,6 +16,6 @@ ecm_qt_declare_logging_category(kwin_wayland_wrapper_SOURCES
add_executable(kwin_wayland_wrapper ${kwin_wayland_wrapper_SOURCES})
target_link_libraries(kwin_wayland_wrapper Qt5::Core KWinXwaylandCommon)
target_link_libraries(kwin_wayland_wrapper Qt5::Core Qt5::DBus KF5::DBusAddons KWinXwaylandCommon)
set_property(TARGET kwin_wayland_wrapper PROPERTY C_STANDARD 11)
install(TARGETS kwin_wayland_wrapper ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})

View file

@ -23,8 +23,10 @@
#include <QCoreApplication>
#include <QDebug>
#include <QProcess>
#include <QTemporaryFile>
#include <QDBusConnection>
#include <UpdateLaunchEnvironmentJob>
#include <signal.h>
@ -119,8 +121,6 @@ void KWinWrapper::run()
qApp->quit();
return;
} else if (exitCode == 133) {
// Exit code 133 asks for kwin_wayland to restart itself,
// so we make sure the crash counter is fresh at 0.
m_crashCount = 0;
} else {
m_crashCount++;
@ -136,6 +136,21 @@ void KWinWrapper::run()
});
m_kwinProcess->start();
QProcessEnvironment env;
env.insert("WAYLAND_DISPLAY", QString::fromUtf8(wl_socket_get_display_name(m_socket)));
if (m_xwlSocket) {
env.insert("DISPLAY", m_xwlSocket->name());
if (m_xauthorityFile.open()) {
env.insert("XAUTHORITY", m_xauthorityFile.fileName());
}
}
auto envSyncJob = new UpdateLaunchEnvironmentJob(env);
connect(envSyncJob, &UpdateLaunchEnvironmentJob::finished, this, []() {
// The service name is merely there to indicate to the world that we're up and ready with all envs exported
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KWinWrapper"));
});
}
void sigtermHandler(int)
@ -146,6 +161,7 @@ void sigtermHandler(int)
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
app.setQuitLockEnabled(false); // don't exit when the first KJob finishes
signal(SIGTERM, sigtermHandler);