mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-26 19:29:49 +01:00
better log wl socket adding and use auto if failed
This commit is contained in:
parent
d8ee624e35
commit
5112056fdb
1 changed files with 15 additions and 3 deletions
|
@ -357,16 +357,28 @@ void CCompositor::startCompositor() {
|
|||
|
||||
// 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);
|
||||
const auto CANDIDATESTR = ("wayland-" + std::to_string(candidate));
|
||||
const auto RETVAL = wl_display_add_socket(m_sWLDisplay, CANDIDATESTR.c_str());
|
||||
if (RETVAL >= 0) {
|
||||
m_szWLDisplaySocket = CANDIDATESTR;
|
||||
Debug::log(LOG, "wl_display_add_socket for %s succeeded with %i", CANDIDATESTR.c_str(), RETVAL);
|
||||
break;
|
||||
} else {
|
||||
Debug::log(WARN, "wl_display_add_socket for %s returned %i: skipping candidate %i", CANDIDATESTR.c_str(), RETVAL, candidate);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_szWLDisplaySocket.empty()) {
|
||||
Debug::log(WARN, "All candidates failed, trying wl_display_add_socket_auto");
|
||||
const auto SOCKETSTR = wl_display_add_socket_auto(m_sWLDisplay);
|
||||
if (SOCKETSTR)
|
||||
m_szWLDisplaySocket = SOCKETSTR;
|
||||
}
|
||||
|
||||
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)");
|
||||
throw std::runtime_error("m_szWLDisplaySocket was null! (wl_display_add_socket and wl_display_add_socket_auto failed)");
|
||||
}
|
||||
|
||||
setenv("WAYLAND_DISPLAY", m_szWLDisplaySocket.c_str(), 1);
|
||||
|
|
Loading…
Reference in a new issue