From ca2be5c51b208e2e43481fd91469b421217d6567 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 6 Oct 2023 22:01:49 +0300 Subject: [PATCH] WindowServer: Read from /dev/input/mice for mouse packets Instead of trying to acquire from an individual mouse device, let's read from /dev/input/mice, where all mouse packets are blended together from all mouse devices that are attached to the machine. --- Userland/Services/WindowServer/EventLoop.cpp | 10 +++++----- Userland/Services/WindowServer/EventLoop.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Services/WindowServer/EventLoop.cpp b/Userland/Services/WindowServer/EventLoop.cpp index 0068a25583..b733a8646d 100644 --- a/Userland/Services/WindowServer/EventLoop.cpp +++ b/Userland/Services/WindowServer/EventLoop.cpp @@ -21,7 +21,7 @@ namespace WindowServer { EventLoop::EventLoop() { m_keyboard_fd = open("/dev/input/keyboard/0", O_RDONLY | O_NONBLOCK | O_CLOEXEC); - m_mouse_fd = open("/dev/input/mouse/0", O_RDONLY | O_NONBLOCK | O_CLOEXEC); + m_mice_fd = open("/dev/input/mice", O_RDONLY | O_NONBLOCK | O_CLOEXEC); m_window_server = MUST(IPC::MultiServer::try_create("/tmp/portal/window")); m_wm_server = MUST(IPC::MultiServer::try_create("/tmp/portal/wm")); @@ -33,11 +33,11 @@ EventLoop::EventLoop() dbgln("Couldn't open /dev/input/keyboard/0"); } - if (m_mouse_fd >= 0) { - m_mouse_notifier = Core::Notifier::construct(m_mouse_fd, Core::Notifier::Type::Read); + if (m_mice_fd >= 0) { + m_mouse_notifier = Core::Notifier::construct(m_mice_fd, Core::Notifier::Type::Read); m_mouse_notifier->on_activation = [this] { drain_mouse(); }; } else { - dbgln("Couldn't open /dev/input/mouse/0"); + dbgln("Couldn't open /dev/input/mice"); } } @@ -48,7 +48,7 @@ void EventLoop::drain_mouse() state.buttons = screen_input.mouse_button_state(); MousePacket packets[32]; - ssize_t nread = read(m_mouse_fd, &packets, sizeof(packets)); + ssize_t nread = read(m_mice_fd, &packets, sizeof(packets)); if (nread < 0) { perror("EventLoop::drain_mouse read"); return; diff --git a/Userland/Services/WindowServer/EventLoop.h b/Userland/Services/WindowServer/EventLoop.h index f0125bc119..e9f17d3d9a 100644 --- a/Userland/Services/WindowServer/EventLoop.h +++ b/Userland/Services/WindowServer/EventLoop.h @@ -31,7 +31,7 @@ private: Core::EventLoop m_event_loop; int m_keyboard_fd { -1 }; RefPtr m_keyboard_notifier; - int m_mouse_fd { -1 }; + int m_mice_fd { -1 }; RefPtr m_mouse_notifier; OwnPtr> m_window_server; OwnPtr> m_wm_server;