mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-11 04:50:38 +01:00
ei: tighten the event type checks
Require exact event types, not just approximate ones. It's always a bug to call any of these functions for an event type that's something else.
This commit is contained in:
parent
c076c48336
commit
b3c202af23
1 changed files with 10 additions and 60 deletions
|
|
@ -206,12 +206,7 @@ ei_event_keyboard_get_xkb_group(struct ei_event *event)
|
|||
_public_ double
|
||||
ei_event_pointer_get_dx(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0.0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0.0, EI_EVENT_POINTER_MOTION)
|
||||
|
||||
return event->pointer.dx;
|
||||
}
|
||||
|
|
@ -219,12 +214,7 @@ ei_event_pointer_get_dx(struct ei_event *event)
|
|||
_public_ double
|
||||
ei_event_pointer_get_dy(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0.0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0.0, EI_EVENT_POINTER_MOTION);
|
||||
|
||||
return event->pointer.dy;
|
||||
}
|
||||
|
|
@ -232,12 +222,7 @@ ei_event_pointer_get_dy(struct ei_event *event)
|
|||
_public_ double
|
||||
ei_event_pointer_get_absolute_x(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0.0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0.0, EI_EVENT_POINTER_MOTION_ABSOLUTE);
|
||||
|
||||
return event->pointer.absx;
|
||||
}
|
||||
|
|
@ -245,12 +230,7 @@ ei_event_pointer_get_absolute_x(struct ei_event *event)
|
|||
_public_ double
|
||||
ei_event_pointer_get_absolute_y(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0.0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0.0, EI_EVENT_POINTER_MOTION_ABSOLUTE);
|
||||
|
||||
return event->pointer.absy;
|
||||
}
|
||||
|
|
@ -258,12 +238,7 @@ ei_event_pointer_get_absolute_y(struct ei_event *event)
|
|||
_public_ uint32_t
|
||||
ei_event_button_get_button(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0, EI_EVENT_BUTTON_BUTTON);
|
||||
|
||||
return event->pointer.button;
|
||||
}
|
||||
|
|
@ -271,12 +246,7 @@ ei_event_button_get_button(struct ei_event *event)
|
|||
_public_ bool
|
||||
ei_event_button_get_is_press(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, false,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, false, EI_EVENT_BUTTON_BUTTON);
|
||||
|
||||
return event->pointer.button_is_press;
|
||||
}
|
||||
|
|
@ -284,48 +254,28 @@ ei_event_button_get_is_press(struct ei_event *event)
|
|||
_public_ double
|
||||
ei_event_scroll_get_dx(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0, EI_EVENT_SCROLL_DELTA);
|
||||
return event->pointer.sx;
|
||||
}
|
||||
|
||||
_public_ double
|
||||
ei_event_scroll_get_dy(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0, EI_EVENT_SCROLL_DELTA);
|
||||
return event->pointer.sy;
|
||||
}
|
||||
|
||||
_public_ int32_t
|
||||
ei_event_scroll_get_discrete_dx(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0, EI_EVENT_SCROLL_DISCRETE);
|
||||
return event->pointer.sdx;
|
||||
}
|
||||
|
||||
_public_ int32_t
|
||||
ei_event_scroll_get_discrete_dy(struct ei_event *event)
|
||||
{
|
||||
require_event_type(event, 0,
|
||||
EI_EVENT_POINTER_MOTION,
|
||||
EI_EVENT_POINTER_MOTION_ABSOLUTE,
|
||||
EI_EVENT_BUTTON_BUTTON,
|
||||
EI_EVENT_SCROLL_DELTA,
|
||||
EI_EVENT_SCROLL_DISCRETE);
|
||||
require_event_type(event, 0, EI_EVENT_SCROLL_DISCRETE);
|
||||
return event->pointer.sdy;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue