mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 19:07:35 +00:00
LibCore: Simplify Core::Notifier by only allowing one event type
Not a single client of this API actually used the event mask feature to listen for readability AND writability. Let's simplify the API and have only one hook: on_activation.
This commit is contained in:
parent
1587caef84
commit
411d36719e
24 changed files with 80 additions and 99 deletions
|
@ -19,8 +19,8 @@ SpiceAgent::SpiceAgent(int fd, ConnectionToClipboardServer& connection)
|
|||
: m_fd(fd)
|
||||
, m_clipboard_connection(connection)
|
||||
{
|
||||
m_notifier = Core::Notifier::construct(fd, Core::Notifier::Read);
|
||||
m_notifier->on_ready_to_read = [this] {
|
||||
m_notifier = Core::Notifier::construct(fd, Core::Notifier::Type::Read);
|
||||
m_notifier->on_activation = [this] {
|
||||
on_message_received();
|
||||
};
|
||||
m_clipboard_connection.on_data_changed = [this] {
|
||||
|
|
|
@ -82,8 +82,8 @@ void Service::setup_notifier()
|
|||
VERIFY(m_sockets.size() == 1);
|
||||
VERIFY(!m_socket_notifier);
|
||||
|
||||
m_socket_notifier = Core::Notifier::construct(m_sockets[0].fd, Core::Notifier::Event::Read, this);
|
||||
m_socket_notifier->on_ready_to_read = [this] {
|
||||
m_socket_notifier = Core::Notifier::construct(m_sockets[0].fd, Core::Notifier::Type::Read, this);
|
||||
m_socket_notifier->on_activation = [this] {
|
||||
if (auto result = handle_socket_connection(); result.is_error())
|
||||
dbgln("{}", result.release_error());
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ Client::Client(int id, NonnullOwnPtr<Core::TCPSocket> socket, int ptm_fd)
|
|||
: m_id(id)
|
||||
, m_socket(move(socket))
|
||||
, m_ptm_fd(ptm_fd)
|
||||
, m_ptm_notifier(Core::Notifier::construct(ptm_fd, Core::Notifier::Read))
|
||||
, m_ptm_notifier(Core::Notifier::construct(ptm_fd, Core::Notifier::Type::Read))
|
||||
{
|
||||
m_socket->on_ready_to_read = [this] {
|
||||
auto result = drain_socket();
|
||||
|
@ -31,7 +31,7 @@ Client::Client(int id, NonnullOwnPtr<Core::TCPSocket> socket, int ptm_fd)
|
|||
}
|
||||
};
|
||||
|
||||
m_ptm_notifier->on_ready_to_read = [this] {
|
||||
m_ptm_notifier->on_activation = [this] {
|
||||
auto result = drain_pty();
|
||||
if (result.is_error()) {
|
||||
dbgln("Failed to drain the PTY: {}", result.error());
|
||||
|
|
|
@ -27,15 +27,15 @@ EventLoop::EventLoop()
|
|||
m_wm_server = MUST(IPC::MultiServer<WMConnectionFromClient>::try_create("/tmp/portal/wm"));
|
||||
|
||||
if (m_keyboard_fd >= 0) {
|
||||
m_keyboard_notifier = Core::Notifier::construct(m_keyboard_fd, Core::Notifier::Read);
|
||||
m_keyboard_notifier->on_ready_to_read = [this] { drain_keyboard(); };
|
||||
m_keyboard_notifier = Core::Notifier::construct(m_keyboard_fd, Core::Notifier::Type::Read);
|
||||
m_keyboard_notifier->on_activation = [this] { drain_keyboard(); };
|
||||
} else {
|
||||
dbgln("Couldn't open /dev/input/keyboard/0");
|
||||
}
|
||||
|
||||
if (m_mouse_fd >= 0) {
|
||||
m_mouse_notifier = Core::Notifier::construct(m_mouse_fd, Core::Notifier::Read);
|
||||
m_mouse_notifier->on_ready_to_read = [this] { drain_mouse(); };
|
||||
m_mouse_notifier = Core::Notifier::construct(m_mouse_fd, Core::Notifier::Type::Read);
|
||||
m_mouse_notifier->on_activation = [this] { drain_mouse(); };
|
||||
} else {
|
||||
dbgln("Couldn't open /dev/input/mouse/0");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue