mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
WSEventLoop: Remove inheritance from CEventLoop
The only reason for the inheritance was to add FDs to the select set. Since CNotifier is available (and now also quite useful), we can make use of it instead, and remove the inheritance.
This commit is contained in:
committed by
Andreas Kling
parent
6eaa6826fa
commit
3837de0573
@@ -40,6 +40,12 @@ WSEventLoop::WSEventLoop()
|
||||
|
||||
m_server_notifier = make<CNotifier>(m_server_sock.fd(), CNotifier::Read);
|
||||
m_server_notifier->on_ready_to_read = [this] { drain_server(); };
|
||||
|
||||
m_keyboard_notifier = make<CNotifier>(m_keyboard_fd, CNotifier::Read);
|
||||
m_keyboard_notifier->on_ready_to_read = [this] { drain_keyboard(); };
|
||||
|
||||
m_mouse_notifier = make<CNotifier>(m_mouse_fd, CNotifier::Read);
|
||||
m_mouse_notifier->on_ready_to_read = [this] { drain_mouse(); };
|
||||
}
|
||||
|
||||
WSEventLoop::~WSEventLoop()
|
||||
@@ -57,7 +63,7 @@ void WSEventLoop::drain_server()
|
||||
static int s_next_client_id = 0;
|
||||
int client_id = ++s_next_client_id;
|
||||
|
||||
new WSClientConnection(client_fd, client_id);
|
||||
CIPCServerSideClientCreator<WSClientConnection>(client_fd, client_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,22 +111,3 @@ void WSEventLoop::drain_keyboard()
|
||||
}
|
||||
}
|
||||
|
||||
void WSEventLoop::add_file_descriptors_for_select(fd_set& fds, int& max_fd_added)
|
||||
{
|
||||
auto add_fd_to_set = [&max_fd_added](int fd, auto& set) {
|
||||
FD_SET(fd, &set);
|
||||
if (fd > max_fd_added)
|
||||
max_fd_added = fd;
|
||||
};
|
||||
add_fd_to_set(m_keyboard_fd, fds);
|
||||
add_fd_to_set(m_mouse_fd, fds);
|
||||
}
|
||||
|
||||
void WSEventLoop::process_file_descriptors_after_select(const fd_set& fds)
|
||||
{
|
||||
if (FD_ISSET(m_keyboard_fd, &fds))
|
||||
drain_keyboard();
|
||||
if (FD_ISSET(m_mouse_fd, &fds))
|
||||
drain_mouse();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user