WindowServer: Don't crash if unable to open input peripherals

Seems a bit extreme, other operating systems don't have their graphical
environment crash if there is no keyboard or no mouse.
This commit is contained in:
Jean-Baptiste Boric 2021-01-24 19:15:13 +01:00 committed by Andreas Kling
parent 4d755725bf
commit 491a67ddc4
Notes: sideshowbarker 2024-07-18 22:53:25 +09:00

View File

@ -66,14 +66,19 @@ EventLoop::EventLoop()
IPC::new_client_connection<ClientConnection>(client_socket.release_nonnull(), client_id);
};
ASSERT(m_keyboard_fd >= 0);
ASSERT(m_mouse_fd >= 0);
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(); };
} else {
dbgln("Couldn't open /dev/keyboard");
}
m_keyboard_notifier = Core::Notifier::construct(m_keyboard_fd, Core::Notifier::Read);
m_keyboard_notifier->on_ready_to_read = [this] { drain_keyboard(); };
m_mouse_notifier = Core::Notifier::construct(m_mouse_fd, Core::Notifier::Read);
m_mouse_notifier->on_ready_to_read = [this] { drain_mouse(); };
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(); };
} else {
dbgln("Couldn't open /dev/mouse");
}
}
EventLoop::~EventLoop()