|
@@ -1,5 +1,6 @@
|
|
#include <Kernel/KeyCode.h>
|
|
#include <Kernel/KeyCode.h>
|
|
#include <Kernel/MousePacket.h>
|
|
#include <Kernel/MousePacket.h>
|
|
|
|
+#include <LibCore/CLocalSocket.h>
|
|
#include <LibCore/CObject.h>
|
|
#include <LibCore/CObject.h>
|
|
#include <WindowServer/WSAPITypes.h>
|
|
#include <WindowServer/WSAPITypes.h>
|
|
#include <WindowServer/WSClientConnection.h>
|
|
#include <WindowServer/WSClientConnection.h>
|
|
@@ -25,22 +26,22 @@ WSEventLoop::WSEventLoop()
|
|
m_mouse_fd = open("/dev/psaux", O_RDONLY | O_NONBLOCK | O_CLOEXEC);
|
|
m_mouse_fd = open("/dev/psaux", O_RDONLY | O_NONBLOCK | O_CLOEXEC);
|
|
|
|
|
|
unlink("/tmp/wsportal");
|
|
unlink("/tmp/wsportal");
|
|
|
|
+ m_server_sock.listen("/tmp/wsportal");
|
|
|
|
|
|
- sockaddr_un address;
|
|
|
|
- address.sun_family = AF_LOCAL;
|
|
|
|
- strcpy(address.sun_path, "/tmp/wsportal");
|
|
|
|
- int rc = bind(m_server_sock.fd(), (const sockaddr*)&address, sizeof(address));
|
|
|
|
- ASSERT(rc == 0);
|
|
|
|
- rc = listen(m_server_sock.fd(), 5);
|
|
|
|
- ASSERT(rc == 0);
|
|
|
|
|
|
+ m_server_sock.on_ready_to_accept = [this] {
|
|
|
|
+ auto* client_socket = m_server_sock.accept();
|
|
|
|
+ if (!client_socket) {
|
|
|
|
+ dbg() << "WindowServer: accept failed.";
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ static int s_next_client_id = 0;
|
|
|
|
+ int client_id = ++s_next_client_id;
|
|
|
|
+ IPC::Server::new_connection_for_client<WSClientConnection>(*client_socket, client_id);
|
|
|
|
+ };
|
|
|
|
|
|
- ASSERT(m_server_sock.fd() >= 0);
|
|
|
|
ASSERT(m_keyboard_fd >= 0);
|
|
ASSERT(m_keyboard_fd >= 0);
|
|
ASSERT(m_mouse_fd >= 0);
|
|
ASSERT(m_mouse_fd >= 0);
|
|
|
|
|
|
- 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 = make<CNotifier>(m_keyboard_fd, CNotifier::Read);
|
|
m_keyboard_notifier->on_ready_to_read = [this] { drain_keyboard(); };
|
|
m_keyboard_notifier->on_ready_to_read = [this] { drain_keyboard(); };
|
|
|
|
|
|
@@ -52,20 +53,6 @@ WSEventLoop::~WSEventLoop()
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
-void WSEventLoop::drain_server()
|
|
|
|
-{
|
|
|
|
- sockaddr_un address;
|
|
|
|
- socklen_t address_size = sizeof(address);
|
|
|
|
- int client_fd = accept(m_server_sock.fd(), (sockaddr*)&address, &address_size);
|
|
|
|
- if (client_fd < 0) {
|
|
|
|
- dbgprintf("WindowServer: accept() failed: %s\n", strerror(errno));
|
|
|
|
- } else {
|
|
|
|
- static int s_next_client_id = 0;
|
|
|
|
- int client_id = ++s_next_client_id;
|
|
|
|
- IPC::Server::new_connection_for_client<WSClientConnection>(client_fd, client_id);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void WSEventLoop::drain_mouse()
|
|
void WSEventLoop::drain_mouse()
|
|
{
|
|
{
|
|
auto& screen = WSScreen::the();
|
|
auto& screen = WSScreen::the();
|
|
@@ -109,4 +96,3 @@ void WSEventLoop::drain_keyboard()
|
|
screen.on_receive_keyboard_data(event);
|
|
screen.on_receive_keyboard_data(event);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|