mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
WindowServer+LibGUI: Expose raw scroll wheel values to applications
This is useful, for instance, in games in which you can switch held items using the scroll wheel. In order to implement this, they previously would have to either add a hard-coded division by 4, or look up your mouse settings to adjust correctly. This commit adds an MouseEvent.wheel_raw_delta_x() and MouseEvent.wheel_raw_delta_y().
This commit is contained in:
parent
148f8169a4
commit
eeeaf410fb
11 changed files with 49 additions and 33 deletions
|
@ -366,7 +366,7 @@ void Window::handle_mouse_event(MouseEvent& event)
|
|||
if (m_automatic_cursor_tracking_widget) {
|
||||
auto window_relative_rect = m_automatic_cursor_tracking_widget->window_relative_rect();
|
||||
Gfx::IntPoint local_point { event.x() - window_relative_rect.x(), event.y() - window_relative_rect.y() };
|
||||
auto local_event = MouseEvent((Event::Type)event.type(), local_point, event.buttons(), event.button(), event.modifiers(), event.wheel_delta_x(), event.wheel_delta_y());
|
||||
auto local_event = MouseEvent((Event::Type)event.type(), local_point, event.buttons(), event.button(), event.modifiers(), event.wheel_delta_x(), event.wheel_delta_y(), event.wheel_raw_delta_x(), event.wheel_raw_delta_y());
|
||||
m_automatic_cursor_tracking_widget->dispatch_event(local_event, this);
|
||||
if (event.buttons() == 0)
|
||||
m_automatic_cursor_tracking_widget = nullptr;
|
||||
|
@ -375,7 +375,7 @@ void Window::handle_mouse_event(MouseEvent& event)
|
|||
if (!m_main_widget)
|
||||
return;
|
||||
auto result = m_main_widget->hit_test(event.position());
|
||||
auto local_event = MouseEvent((Event::Type)event.type(), result.local_position, event.buttons(), event.button(), event.modifiers(), event.wheel_delta_x(), event.wheel_delta_y());
|
||||
auto local_event = MouseEvent((Event::Type)event.type(), result.local_position, event.buttons(), event.button(), event.modifiers(), event.wheel_delta_x(), event.wheel_delta_y(), event.wheel_raw_delta_x(), event.wheel_raw_delta_y());
|
||||
VERIFY(result.widget);
|
||||
set_hovered_widget(result.widget);
|
||||
if (event.buttons() != 0 && !m_automatic_cursor_tracking_widget)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue