5#include "flutter/shell/platform/linux/fl_scrolling_manager.h"
30 FlScrollingManager*
self = FL_SCROLLING_MANAGER(
object);
32 if (
self->view_delegate !=
nullptr) {
33 g_object_remove_weak_pointer(
34 object,
reinterpret_cast<gpointer*
>(&
self->view_delegate));
35 self->view_delegate =
nullptr;
38 G_OBJECT_CLASS(fl_scrolling_manager_parent_class)->dispose(
object);
48 FlScrollingViewDelegate* view_delegate) {
49 g_return_val_if_fail(FL_IS_SCROLLING_VIEW_DELEGATE(view_delegate),
nullptr);
51 FlScrollingManager*
self = FL_SCROLLING_MANAGER(
52 g_object_new(fl_scrolling_manager_get_type(),
nullptr));
54 self->view_delegate = view_delegate;
55 g_object_add_weak_pointer(
56 G_OBJECT(view_delegate),
57 reinterpret_cast<gpointer*
>(&(
self->view_delegate)));
69 g_return_if_fail(FL_IS_SCROLLING_MANAGER(
self));
75 GdkEventScroll* scroll_event,
77 g_return_if_fail(FL_IS_SCROLLING_MANAGER(
self));
79 GdkEvent*
event =
reinterpret_cast<GdkEvent*
>(scroll_event);
81 guint event_time = gdk_event_get_time(
event);
82 gdouble event_x = 0.0, event_y = 0.0;
83 gdk_event_get_coords(
event, &event_x, &event_y);
84 gdouble scroll_delta_x = 0.0, scroll_delta_y = 0.0;
85 GdkScrollDirection event_direction = GDK_SCROLL_SMOOTH;
86 if (gdk_event_get_scroll_direction(
event, &event_direction)) {
87 if (event_direction == GDK_SCROLL_UP) {
90 }
else if (event_direction == GDK_SCROLL_DOWN) {
93 }
else if (event_direction == GDK_SCROLL_LEFT) {
96 }
else if (event_direction == GDK_SCROLL_RIGHT) {
101 gdk_event_get_scroll_deltas(
event, &scroll_delta_x, &scroll_delta_y);
106 const int kScrollOffsetMultiplier = 53;
107 scroll_delta_x *= kScrollOffsetMultiplier * scale_factor;
108 scroll_delta_y *= kScrollOffsetMultiplier * scale_factor;
110 if (gdk_device_get_source(gdk_event_get_source_device(
event)) ==
111 GDK_SOURCE_TOUCHPAD) {
112 scroll_delta_x *= -1;
113 scroll_delta_y *= -1;
114 if (gdk_event_is_scroll_stop_event(
event)) {
117 event_x * scale_factor, event_y * scale_factor,
kPanZoomEnd,
121 if (!
self->pan_started) {
126 event_x * scale_factor, event_y * scale_factor,
kPanZoomStart, 0, 0,
130 self->pan_x += scroll_delta_x;
131 self->pan_y += scroll_delta_y;
138 self->last_x = event_x * scale_factor;
139 self->last_y = event_y * scale_factor;
152 g_return_if_fail(FL_IS_SCROLLING_MANAGER(
self));
155 if (!
self->zoom_started) {
159 self->view_delegate, g_get_real_time(),
self->last_x,
self->last_y,
166 g_return_if_fail(FL_IS_SCROLLING_MANAGER(
self));
168 self->rotation = rotation;
170 self->view_delegate, g_get_real_time(),
self->last_x,
self->last_y,
175 g_return_if_fail(FL_IS_SCROLLING_MANAGER(
self));
178 if (!
self->zoom_started) {
180 self->view_delegate, g_get_real_time(),
self->last_x,
self->last_y,
186 g_return_if_fail(FL_IS_SCROLLING_MANAGER(
self));
189 if (!
self->rotate_started) {
193 self->view_delegate, g_get_real_time(),
self->last_x,
self->last_y,
200 g_return_if_fail(FL_IS_SCROLLING_MANAGER(
self));
204 self->view_delegate, g_get_real_time(),
self->last_x,
self->last_y,
209 g_return_if_fail(FL_IS_SCROLLING_MANAGER(
self));
212 if (!
self->rotate_started) {
214 self->view_delegate, g_get_real_time(),
self->last_x,
self->last_y,
@ kPanZoomUpdate
The pan/zoom updated.
@ kPanZoomStart
A pan/zoom started on this pointer.
@ kPanZoomEnd
The pan/zoom ended.
@ kFlutterPointerDeviceKindMouse