forked from AuroraMiddleware/gtk
gdk/events: Set discrete scroll deltas in its constructor
Instead of calculating the discrete scroll deltas in GtkEventControllerScroll, move that code to the event constructor and access the precalculated values using gdk_scroll_event_get_deltas. Refactor, no functional changes.
This commit is contained in:
parent
51ca454eef
commit
6ebb38e12e
@ -2368,10 +2368,33 @@ gdk_scroll_event_new_discrete (GdkSurface *surface,
|
|||||||
GdkScrollDirection direction)
|
GdkScrollDirection direction)
|
||||||
{
|
{
|
||||||
GdkScrollEvent *self = gdk_event_alloc (GDK_SCROLL, surface, device, time);
|
GdkScrollEvent *self = gdk_event_alloc (GDK_SCROLL, surface, device, time);
|
||||||
|
double delta_x = 0, delta_y = 0;
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case GDK_SCROLL_UP:
|
||||||
|
delta_y = -1;
|
||||||
|
break;
|
||||||
|
case GDK_SCROLL_DOWN:
|
||||||
|
delta_y = 1;
|
||||||
|
break;
|
||||||
|
case GDK_SCROLL_LEFT:
|
||||||
|
delta_x = -1;
|
||||||
|
break;
|
||||||
|
case GDK_SCROLL_RIGHT:
|
||||||
|
delta_x = 1;
|
||||||
|
break;
|
||||||
|
case GDK_SCROLL_SMOOTH:
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
self->tool = tool != NULL ? g_object_ref (tool) : NULL;
|
self->tool = tool != NULL ? g_object_ref (tool) : NULL;
|
||||||
self->state = state;
|
self->state = state;
|
||||||
self->direction = direction;
|
self->direction = direction;
|
||||||
|
self->delta_x = delta_x;
|
||||||
|
self->delta_y = delta_y;
|
||||||
self->unit = GDK_SCROLL_UNIT_WHEEL;
|
self->unit = GDK_SCROLL_UNIT_WHEEL;
|
||||||
|
|
||||||
return (GdkEvent *) self;
|
return (GdkEvent *) self;
|
||||||
|
@ -416,25 +416,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (direction)
|
gdk_scroll_event_get_deltas (event, &dx, &dy);
|
||||||
{
|
|
||||||
case GDK_SCROLL_UP:
|
|
||||||
dy -= 1;
|
|
||||||
break;
|
|
||||||
case GDK_SCROLL_DOWN:
|
|
||||||
dy += 1;
|
|
||||||
break;
|
|
||||||
case GDK_SCROLL_LEFT:
|
|
||||||
dx -= 1;
|
|
||||||
break;
|
|
||||||
case GDK_SCROLL_RIGHT:
|
|
||||||
dx += 1;
|
|
||||||
break;
|
|
||||||
case GDK_SCROLL_SMOOTH:
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_VERTICAL) == 0)
|
if ((scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_VERTICAL) == 0)
|
||||||
dy = 0;
|
dy = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user