mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-05-19 08:30:22 -07:00
xwl: dont close the fd to early (#9715)
dont close the fd until the wl_event_source is removed, so we dont get another event triggered with an already closed fd.
This commit is contained in:
parent
66470020a7
commit
c22f46768c
@ -177,8 +177,7 @@ static void startServer(void* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int xwaylandReady(int fd, uint32_t mask, void* data) {
|
static int xwaylandReady(int fd, uint32_t mask, void* data) {
|
||||||
CFileDescriptor xwlFd{fd};
|
return g_pXWayland->pServer->ready(fd, mask);
|
||||||
return g_pXWayland->pServer->ready(std::move(xwlFd), mask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool safeRemove(const std::string& path) {
|
static bool safeRemove(const std::string& path) {
|
||||||
@ -300,7 +299,7 @@ void CXWaylandServer::runXWayland(CFileDescriptor& notifyFD) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto cmd =
|
auto cmd =
|
||||||
std::format("Xwayland {} -rootless -core -listenfd {} -listenfd {} -displayfd {} -wm {}", displayName, xFDs[0].get(), xFDs[1].get(), notifyFD.get(), xwmFDs[1].get());
|
std::format("Xwayland {} -rootless -core -listenfd {} -listenfd {} -displayfd {} -wm {}", displayName, xFDs[0].get(), xFDs[1].get(), notifyFD.take(), xwmFDs[1].get());
|
||||||
|
|
||||||
auto waylandSocket = std::format("{}", waylandFDs[1].get());
|
auto waylandSocket = std::format("{}", waylandFDs[1].get());
|
||||||
setenv("WAYLAND_SOCKET", waylandSocket.c_str(), true);
|
setenv("WAYLAND_SOCKET", waylandSocket.c_str(), true);
|
||||||
@ -392,11 +391,11 @@ bool CXWaylandServer::start() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CXWaylandServer::ready(CFileDescriptor fd, uint32_t mask) {
|
int CXWaylandServer::ready(int fd, uint32_t mask) {
|
||||||
if (mask & WL_EVENT_READABLE) {
|
if (mask & WL_EVENT_READABLE) {
|
||||||
// xwayland writes twice
|
// xwayland writes twice
|
||||||
char buf[64];
|
char buf[64];
|
||||||
ssize_t n = read(fd.get(), buf, sizeof(buf));
|
ssize_t n = read(fd, buf, sizeof(buf));
|
||||||
if (n < 0 && errno != EINTR) {
|
if (n < 0 && errno != EINTR) {
|
||||||
Debug::log(ERR, "Xwayland: read from displayFd failed");
|
Debug::log(ERR, "Xwayland: read from displayFd failed");
|
||||||
mask = 0;
|
mask = 0;
|
||||||
@ -421,6 +420,7 @@ int CXWaylandServer::ready(CFileDescriptor fd, uint32_t mask) {
|
|||||||
|
|
||||||
Debug::log(LOG, "XWayland is ready");
|
Debug::log(LOG, "XWayland is ready");
|
||||||
|
|
||||||
|
close(fd);
|
||||||
wl_event_source_remove(pipeSource);
|
wl_event_source_remove(pipeSource);
|
||||||
pipeSource = nullptr;
|
pipeSource = nullptr;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class CXWaylandServer {
|
|||||||
bool start();
|
bool start();
|
||||||
|
|
||||||
// called on ready
|
// called on ready
|
||||||
int ready(Hyprutils::OS::CFileDescriptor fd, uint32_t mask);
|
int ready(int fd, uint32_t mask);
|
||||||
|
|
||||||
void die();
|
void die();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user