| Flutter Linux Embedder |

Macros | Functions
fl_scrolling_manager.h File Reference
`#include <gdk/gdk.h>`
`#include "flutter/shell/platform/linux/fl_scrolling_view_delegate.h"`

Go to the source code of this file.

## Macros
#define | FL_TYPE_SCROLLING_MANAGER fl_scrolling_manager_get_type()

## Functions
| G_DECLARE_FINAL_TYPE (FlScrollingManager, fl_scrolling_manager, FL, SCROLLING_MANAGER, GObject)
FlScrollingManager * | fl_scrolling_manager_new (FlScrollingViewDelegate *view_delegate)
void | fl_scrolling_manager_set_last_mouse_position (FlScrollingManager *manager, gdouble x, gdouble y)
void | fl_scrolling_manager_handle_scroll_event (FlScrollingManager *manager, GdkEventScroll *event, gint scale_factor)
void | fl_scrolling_manager_handle_rotation_begin (FlScrollingManager *manager)
void | fl_scrolling_manager_handle_rotation_update (FlScrollingManager *manager, gdouble rotation)
void | fl_scrolling_manager_handle_rotation_end (FlScrollingManager *manager)
void | fl_scrolling_manager_handle_zoom_begin (FlScrollingManager *manager)
void | fl_scrolling_manager_handle_zoom_update (FlScrollingManager *manager, gdouble scale)
void | fl_scrolling_manager_handle_zoom_end (FlScrollingManager *manager)

## Macro Definition Documentation

## ◆ FL_TYPE_SCROLLING_MANAGER

#define FL_TYPE_SCROLLING_MANAGER fl_scrolling_manager_get_type()

Definition at line 14 of file fl_scrolling_manager.h.

## Function Documentation

## ◆ fl_scrolling_manager_handle_rotation_begin()

void fl_scrolling_manager_handle_rotation_begin | ( | FlScrollingManager * | manager | ) |

fl_scrolling_manager_handle_rotation_begin: @manager: an #FlScrollingManager.

Inform the scrolling manager that a rotation gesture has begun.

Definition at line 150 of file fl_scrolling_manager.cc.

150 {
151 g_return_if_fail(FL_IS_SCROLLING_MANAGER(self));
152
153 self->rotate_started = TRUE;
154 if (!self->zoom_started) {
155 self->scale = 1;
156 self->rotation = 0;
157 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
158 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
159 kPanZoomStart, 0, 0, 0, 0);
160 }
161 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and TRUE.

Referenced by gesture_rotation_begin_cb().

## ◆ fl_scrolling_manager_handle_rotation_end()

void fl_scrolling_manager_handle_rotation_end | ( | FlScrollingManager * | manager | ) |

fl_scrolling_manager_handle_rotation_end: @manager: an #FlScrollingManager.

Inform the scrolling manager that a rotation gesture has ended.

Definition at line 173 of file fl_scrolling_manager.cc.

173 {
174 g_return_if_fail(FL_IS_SCROLLING_MANAGER(self));
175
176 self->rotate_started = FALSE;
177 if (!self->zoom_started) {
178 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
179 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
180 kPanZoomEnd, 0, 0, 0, 0);
181 }
182 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event().

Referenced by gesture_rotation_end_cb().

## ◆ fl_scrolling_manager_handle_rotation_update()

void fl_scrolling_manager_handle_rotation_update | ( | FlScrollingManager * | manager,
|  | gdouble | rotation
| ) |  |

fl_scrolling_manager_handle_rotation_update: @manager: an #FlScrollingManager. @rotation: the rotation angle, in radians.

Inform the scrolling manager that a rotation gesture has updated.

Definition at line 163 of file fl_scrolling_manager.cc.

164 {
165 g_return_if_fail(FL_IS_SCROLLING_MANAGER(self));
166
167 self->rotation = rotation;
168 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
169 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
170 kPanZoomUpdate, 0, 0, self->scale, self->rotation);
171 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event().

Referenced by gesture_rotation_update_cb().

## ◆ fl_scrolling_manager_handle_scroll_event()

void fl_scrolling_manager_handle_scroll_event | ( | FlScrollingManager * | manager,
|  | GdkEventScroll * | event,
|  | gint | scale_factor
| ) |  |

fl_scrolling_manager_handle_scroll_event: @manager: an #FlScrollingManager. @event: the scroll event. @scale_factor: the GTK scaling factor of the window.

Inform the scrolling manager of a scroll event.

Definition at line 74 of file fl_scrolling_manager.cc.

76 {
77 g_return_if_fail(FL_IS_SCROLLING_MANAGER(self));
78
79 GdkEvent* event = reinterpret_cast<GdkEvent*>(scroll_event);
80
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) {
88 scroll_delta_x = 0;
89 scroll_delta_y = -1;
90 } else if (event_direction == GDK_SCROLL_DOWN) {
91 scroll_delta_x = 0;
92 scroll_delta_y = 1;
93 } else if (event_direction == GDK_SCROLL_LEFT) {
94 scroll_delta_x = -1;
95 scroll_delta_y = 0;
96 } else if (event_direction == GDK_SCROLL_RIGHT) {
97 scroll_delta_x = 1;
98 scroll_delta_y = 0;
99 }
100 } else {
101 gdk_event_get_scroll_deltas(event, &scroll_delta_x, &scroll_delta_y);
102 }
103
104 // The multiplier is taken from the Chromium source
105 // (ui/events/x/events_x_utils.cc).
106 const int kScrollOffsetMultiplier = 53;
107 scroll_delta_x *= kScrollOffsetMultiplier * scale_factor;
108 scroll_delta_y *= kScrollOffsetMultiplier * scale_factor;
109
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)) {
115 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
116 self->view_delegate, event_time * kMicrosecondsPerMillisecond,
117 event_x * scale_factor, event_y * scale_factor, kPanZoomEnd,
118 self->pan_x, self->pan_y, 0, 0);
119 self->pan_started = FALSE;
120 } else {
121 if (!self->pan_started) {
122 self->pan_x = 0;
123 self->pan_y = 0;
124 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
125 self->view_delegate, event_time * kMicrosecondsPerMillisecond,
126 event_x * scale_factor, event_y * scale_factor, kPanZoomStart, 0, 0,
127 0, 0);
128 self->pan_started = TRUE;
129 }
130 self->pan_x += scroll_delta_x;
131 self->pan_y += scroll_delta_y;
132 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
133 self->view_delegate, event_time * kMicrosecondsPerMillisecond,
134 event_x * scale_factor, event_y * scale_factor, kPanZoomUpdate,
135 self->pan_x, self->pan_y, 1, 0);
136 }
137 } else {
138 self->last_x = event_x * scale_factor;
139 self->last_y = event_y * scale_factor;
140 fl_scrolling_view_delegate_send_mouse_pointer_event(
141 self->view_delegate,
142 FlutterPointerPhase::kMove /* arbitrary value, phase will be ignored as
143 this is a discrete scroll event */
144 ,
145 event_time * kMicrosecondsPerMillisecond, event_x * scale_factor,
146 event_y * scale_factor, scroll_delta_x, scroll_delta_y, 0);
147 }
148 }

References event, fl_scrolling_view_delegate_send_mouse_pointer_event(), fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), kMicrosecondsPerMillisecond, and TRUE.

Referenced by scroll_event_cb().

## ◆ fl_scrolling_manager_handle_zoom_begin()

void fl_scrolling_manager_handle_zoom_begin | ( | FlScrollingManager * | manager | ) |

fl_scrolling_manager_handle_zoom_begin: @manager: an #FlScrollingManager.

Inform the scrolling manager that a zoom gesture has begun.

Definition at line 184 of file fl_scrolling_manager.cc.

184 {
185 g_return_if_fail(FL_IS_SCROLLING_MANAGER(self));
186
187 self->zoom_started = TRUE;
188 if (!self->rotate_started) {
189 self->scale = 1;
190 self->rotation = 0;
191 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
192 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
193 kPanZoomStart, 0, 0, 0, 0);
194 }
195 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and TRUE.

Referenced by gesture_zoom_begin_cb().

## ◆ fl_scrolling_manager_handle_zoom_end()

void fl_scrolling_manager_handle_zoom_end | ( | FlScrollingManager * | manager | ) |

fl_scrolling_manager_handle_zoom_end: @manager: an #FlScrollingManager.

Inform the scrolling manager that a zoom gesture has ended.

Definition at line 207 of file fl_scrolling_manager.cc.

207 {
208 g_return_if_fail(FL_IS_SCROLLING_MANAGER(self));
209
210 self->zoom_started = FALSE;
211 if (!self->rotate_started) {
212 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
213 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
214 kPanZoomEnd, 0, 0, 0, 0);
215 }
216 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event().

Referenced by gesture_zoom_end_cb().

## ◆ fl_scrolling_manager_handle_zoom_update()

void fl_scrolling_manager_handle_zoom_update | ( | FlScrollingManager * | manager,
|  | gdouble | scale
| ) |  |

fl_scrolling_manager_handle_zoom_update: @manager: an #FlScrollingManager. @scale: the zoom scale.

Inform the scrolling manager that a zoom gesture has updated.

Definition at line 197 of file fl_scrolling_manager.cc.

198 {
199 g_return_if_fail(FL_IS_SCROLLING_MANAGER(self));
200
201 self->scale = scale;
202 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
203 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
204 kPanZoomUpdate, 0, 0, self->scale, self->rotation);
205 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event().

Referenced by gesture_zoom_update_cb().

## ◆ fl_scrolling_manager_new()

FlScrollingManager* fl_scrolling_manager_new | ( | FlScrollingViewDelegate * | view_delegate | ) |

fl_scrolling_manager_new: @view_delegate: An interface that the manager requires to communicate with the platform. Usually implemented by FlView.

Create a new #FlScrollingManager.

Returns: a new #FlScrollingManager.

Definition at line 47 of file fl_scrolling_manager.cc.

48 {
49 g_return_val_if_fail(FL_IS_SCROLLING_VIEW_DELEGATE(view_delegate), nullptr);
50
51 FlScrollingManager* self = FL_SCROLLING_MANAGER(
52 g_object_new(fl_scrolling_manager_get_type(), nullptr));
53
54 self->view_delegate = view_delegate;
55 g_object_add_weak_pointer(
56 G_OBJECT(view_delegate),
57 reinterpret_cast<gpointer*>(&(self->view_delegate)));
58
59 self->pan_started = FALSE;
60 self->zoom_started = FALSE;
61 self->rotate_started = FALSE;
62
63 return self;
64 }

References g_object_add_weak_pointer().

Referenced by init_scrolling().

## ◆ fl_scrolling_manager_set_last_mouse_position()

void fl_scrolling_manager_set_last_mouse_position | ( | FlScrollingManager * | manager,
|  | gdouble | x,
|  | gdouble | y
| ) |  |

fl_scrolling_manager_set_last_mouse_position: @manager: an #FlScrollingManager. @x: the mouse x-position, in window coordinates. @y: the mouse y-position, in window coordinates.

Inform the scrolling manager of the mouse position. This position will be used when sending scroll pointer events.

Definition at line 66 of file fl_scrolling_manager.cc.

68 {
69 g_return_if_fail(FL_IS_SCROLLING_MANAGER(self));
70 self->last_x = x;
71 self->last_y = y;
72 }

Referenced by send_pointer_button_event().

## ◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE | ( | FlScrollingManager | ,
|  | fl_scrolling_manager | ,
|  | FL | ,
|  | SCROLLING_MANAGER | ,
|  | GObject |
| ) |  |

event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
g_object_add_weak_pointer
g_object_add_weak_pointer(G_OBJECT(self), reinterpret_cast< gpointer * >(&self->engine))
fl_scrolling_view_delegate_send_mouse_pointer_event
void fl_scrolling_view_delegate_send_mouse_pointer_event(FlScrollingViewDelegate *self, FlutterPointerPhase phase, size_t timestamp, double x, double y, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_scrolling_view_delegate.cc:14
kMicrosecondsPerMillisecond
static constexpr int kMicrosecondsPerMillisecond
Definition: fl_scrolling_manager.cc:7
fl_scrolling_view_delegate_send_pointer_pan_zoom_event
void fl_scrolling_view_delegate_send_pointer_pan_zoom_event(FlScrollingViewDelegate *self, size_t timestamp, double x, double y, FlutterPointerPhase phase, double pan_x, double pan_y, double scale, double rotation)
Definition: fl_scrolling_view_delegate.cc:28