mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
WindowServer: Simplify mouse button handling logic in EventLoop
The `buttons` variable is a bit superfluous here.
This commit is contained in:
parent
4131b35851
commit
bbaf8e3b70
1 changed files with 2 additions and 4 deletions
|
@ -76,7 +76,6 @@ void EventLoop::drain_mouse()
|
||||||
auto& screen_input = ScreenInput::the();
|
auto& screen_input = ScreenInput::the();
|
||||||
MousePacket state;
|
MousePacket state;
|
||||||
state.buttons = screen_input.mouse_button_state();
|
state.buttons = screen_input.mouse_button_state();
|
||||||
unsigned buttons = state.buttons;
|
|
||||||
MousePacket packets[32];
|
MousePacket packets[32];
|
||||||
|
|
||||||
ssize_t nread = read(m_mouse_fd, &packets, sizeof(packets));
|
ssize_t nread = read(m_mouse_fd, &packets, sizeof(packets));
|
||||||
|
@ -90,7 +89,6 @@ void EventLoop::drain_mouse()
|
||||||
for (size_t i = 0; i < npackets; ++i) {
|
for (size_t i = 0; i < npackets; ++i) {
|
||||||
auto& packet = packets[i];
|
auto& packet = packets[i];
|
||||||
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse X {}, Y {}, Z {}, relative={}", packet.x, packet.y, packet.z, packet.is_relative);
|
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse X {}, Y {}, Z {}, relative={}", packet.x, packet.y, packet.z, packet.is_relative);
|
||||||
buttons = packet.buttons;
|
|
||||||
|
|
||||||
state.is_relative = packet.is_relative;
|
state.is_relative = packet.is_relative;
|
||||||
if (packet.is_relative) {
|
if (packet.is_relative) {
|
||||||
|
@ -103,8 +101,8 @@ void EventLoop::drain_mouse()
|
||||||
state.z += packet.z;
|
state.z += packet.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttons != state.buttons) {
|
if (packet.buttons != state.buttons) {
|
||||||
state.buttons = buttons;
|
state.buttons = packet.buttons;
|
||||||
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse Button Event");
|
dbgln_if(WSMESSAGELOOP_DEBUG, "EventLoop: Mouse Button Event");
|
||||||
screen_input.on_receive_mouse_data(state);
|
screen_input.on_receive_mouse_data(state);
|
||||||
if (state.is_relative) {
|
if (state.is_relative) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue