1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:17:35 +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:
circl 2022-03-26 23:04:47 +01:00 committed by Andreas Kling
parent 148f8169a4
commit eeeaf410fb
11 changed files with 49 additions and 33 deletions

View file

@ -88,7 +88,7 @@ private:
class MouseEvent final : public Event {
public:
MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta_x = 0, int wheel_delta_y = 0)
MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta_x = 0, int wheel_delta_y = 0, int wheel_raw_delta_x = 0, int wheel_raw_delta_y = 0)
: Event(type)
, m_position(position)
, m_buttons(buttons)
@ -96,6 +96,8 @@ public:
, m_modifiers(modifiers)
, m_wheel_delta_x(wheel_delta_x)
, m_wheel_delta_y(wheel_delta_y)
, m_wheel_raw_delta_x(wheel_raw_delta_x)
, m_wheel_raw_delta_y(wheel_raw_delta_y)
{
}
@ -107,6 +109,8 @@ public:
unsigned modifiers() const { return m_modifiers; }
int wheel_delta_x() const { return m_wheel_delta_x; }
int wheel_delta_y() const { return m_wheel_delta_y; }
int wheel_raw_delta_x() const { return m_wheel_raw_delta_x; }
int wheel_raw_delta_y() const { return m_wheel_raw_delta_y; }
bool is_drag() const { return m_drag; }
Vector<String> mime_types() const
@ -133,6 +137,8 @@ private:
unsigned m_modifiers { 0 };
int m_wheel_delta_x { 0 };
int m_wheel_delta_y { 0 };
int m_wheel_raw_delta_x { 0 };
int m_wheel_raw_delta_y { 0 };
bool m_drag { false };
RefPtr<const Core::MimeData> m_mime_data;
};