diff options
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 5cf43334..9cf5e272 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -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); |
