diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-12-05 17:21:09 +0000 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-12-05 17:21:09 +0000 |
| commit | 9fb24ac1e974c399979190b0d4c86643304dfc7e (patch) | |
| tree | f828bbf4d173f170d3a050a69f64af75d0dee557 /src/Compositor.cpp | |
| parent | 66fb0830032572c9729278b7e15525cb41bbf59e (diff) | |
avoid using wayland-0 as a socket name
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); |
