avoid using wayland-0 as a socket name

This commit is contained in:
vaxerski 2022-12-05 17:21:09 +00:00
parent 66fb083003
commit 9fb24ac1e9
2 changed files with 10 additions and 4 deletions

View file

@ -345,15 +345,21 @@ void CCompositor::startCompositor() {
initAllSignals();
m_szWLDisplaySocket = wl_display_add_socket_auto(m_sWLDisplay);
// get socket, avoid using 0
for (int candidate = 1; candidate <= 32; candidate++) {
if (wl_display_add_socket(m_sWLDisplay, ("wayland-" + std::to_string(candidate)).c_str()) >= 0) {
m_szWLDisplaySocket = "wayland-" + std::to_string(candidate);
break;
}
}
if (!m_szWLDisplaySocket) {
if (m_szWLDisplaySocket.empty()) {
Debug::log(CRIT, "m_szWLDisplaySocket NULL!");
wlr_backend_destroy(m_sWLRBackend);
throw std::runtime_error("m_szWLDisplaySocket was null! (wl_display_add_socket_auto failed)");
}
setenv("WAYLAND_DISPLAY", m_szWLDisplaySocket, 1);
setenv("WAYLAND_DISPLAY", m_szWLDisplaySocket.c_str(), 1);
signal(SIGPIPE, SIG_IGN);

View file

@ -76,7 +76,7 @@ public:
// ------------------------------------------------- //
const char* m_szWLDisplaySocket;
std::string m_szWLDisplaySocket = "";
std::string m_szInstanceSignature = "";
std::string m_szCurrentSplash = "error";