Hyprland/src/xwayland/Server.hpp
Tom Englund 5489682799
internal: some minor fd/socket cleanups and make logging thread safe (#7123)
* bezier: dont loop on float values

Using a floating-point loop variable with a fixed increment can cause precision
errors over time due to the nature of floating-point arithmetic.
and cause undesired effects.

ex
iteration 1 = 0.10000000149011611938
iteration 2 = 0.20000000298023223877

eventually..

iteration 8 = 0.80000001192092895508
iteration 9 = 0.89999997615814208984

* hyprctl: close sockets on destruction

store socketpath and close the fd and unlink the socket path on exit.

* eventloopmgr: close the timerfd

close the timerfd on exit.

* debug: make logging thread safe

instead of opening and closing the logfile on each write open it on init
and close it on compositor exit. also add a mutex so accidently using
logging from a thread like the watchdog or similiar doesnt cause issues.

* xwl: clean up fd logic

check if the fd is actually opened before closing, and close the
pipesource FD on exit.
2024-07-31 21:00:14 +02:00

49 lines
1.2 KiB
C++

#pragma once
#include <array>
#include "../helpers/signal/Signal.hpp"
struct wl_event_source;
struct wl_client;
// TODO: add lazy mode
class CXWaylandServer {
public:
CXWaylandServer();
~CXWaylandServer();
// create the server.
bool create();
// starts the server, meant to be called by CXWaylandServer.
bool start();
// called on ready
int ready(int fd, uint32_t mask);
void die();
struct {
CSignal ready;
} events;
wl_client* xwaylandClient = nullptr;
private:
bool tryOpenSockets();
void runXWayland(int notifyFD);
pid_t serverPID = 0;
std::string displayName;
int display = -1;
std::array<int, 2> xFDs = {-1, -1};
std::array<wl_event_source*, 2> xFDReadEvents = {nullptr, nullptr};
wl_event_source* idleSource = nullptr;
wl_event_source* pipeSource = nullptr;
int pipeFd = -1;
std::array<int, 2> xwmFDs = {-1, -1};
std::array<int, 2> waylandFDs = {-1, -1};
friend class CXWM;
};