| Flutter Linux Embedder |

Macros | Functions
fl_scrolling_manager.h File Reference
`#include <gdk/gdk.h>`
`#include <functional>`
`#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 15 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: the #FlScrollingManager self.

Inform the scrolling manager that a rotation gesture has begun.

Definition at line 141 of file fl_scrolling_manager.cc.

141 {
142 self->rotate_started = true;
143 if (!self->zoom_started) {
144 self->scale = 1;
145 self->rotation = 0;
146 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
147 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
148 kPanZoomStart, 0, 0, 0, 0);
149 }
150 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and self.

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: the #FlScrollingManager self.

Inform the scrolling manager that a rotation gesture has ended.

Definition at line 159 of file fl_scrolling_manager.cc.

159 {
160 self->rotate_started = false;
161 if (!self->zoom_started) {
162 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
163 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
164 kPanZoomEnd, 0, 0, 0, 0);
165 }
166 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and self.

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: the #FlScrollingManager self. @rotation: the rotation angle, in radians.

Inform the scrolling manager that a rotation gesture has updated.

Definition at line 152 of file fl_scrolling_manager.cc.

153 {
154 self->rotation = rotation;
155 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
156 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
157 kPanZoomUpdate, 0, 0, self->scale, self->rotation);
158 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and self.

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: the #FlScrollingManager self. @event: the scroll event. @scale_factor: the GTK scaling factor of the window.

Inform the scrolling manager of a scroll event.

Definition at line 67 of file fl_scrolling_manager.cc.

69 {
70 GdkEvent* event = reinterpret_cast<GdkEvent*>(scroll_event);
71
72 guint event_time = gdk_event_get_time(event);
73 gdouble event_x = 0.0, event_y = 0.0;
74 gdk_event_get_coords(event, &event_x, &event_y);
75 gdouble scroll_delta_x = 0.0, scroll_delta_y = 0.0;
76 GdkScrollDirection event_direction = GDK_SCROLL_SMOOTH;
77 if (gdk_event_get_scroll_direction(event, &event_direction)) {
78 if (event_direction == GDK_SCROLL_UP) {
79 scroll_delta_x = 0;
80 scroll_delta_y = -1;
81 } else if (event_direction == GDK_SCROLL_DOWN) {
82 scroll_delta_x = 0;
83 scroll_delta_y = 1;
84 } else if (event_direction == GDK_SCROLL_LEFT) {
85 scroll_delta_x = -1;
86 scroll_delta_y = 0;
87 } else if (event_direction == GDK_SCROLL_RIGHT) {
88 scroll_delta_x = 1;
89 scroll_delta_y = 0;
90 }
91 } else {
92 gdk_event_get_scroll_deltas(event, &scroll_delta_x, &scroll_delta_y);
93 }
94
95 // The multiplier is taken from the Chromium source
96 // (ui/events/x/events_x_utils.cc).
97 const int kScrollOffsetMultiplier = 53;
98 scroll_delta_x *= kScrollOffsetMultiplier * scale_factor;
99 scroll_delta_y *= kScrollOffsetMultiplier * scale_factor;
100
101 if (gdk_device_get_source(gdk_event_get_source_device(event)) ==
102 GDK_SOURCE_TOUCHPAD) {
103 scroll_delta_x *= -1;
104 scroll_delta_y *= -1;
105 if (gdk_event_is_scroll_stop_event(event)) {
106 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
107 self->view_delegate, event_time * kMicrosecondsPerMillisecond,
108 event_x * scale_factor, event_y * scale_factor, kPanZoomEnd,
109 self->pan_x, self->pan_y, 0, 0);
110 self->pan_started = FALSE;
111 } else {
112 if (!self->pan_started) {
113 self->pan_x = 0;
114 self->pan_y = 0;
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, kPanZoomStart, 0, 0,
118 0, 0);
119 self->pan_started = TRUE;
120 }
121 self->pan_x += scroll_delta_x;
122 self->pan_y += scroll_delta_y;
123 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
124 self->view_delegate, event_time * kMicrosecondsPerMillisecond,
125 event_x * scale_factor, event_y * scale_factor, kPanZoomUpdate,
126 self->pan_x, self->pan_y, 1, 0);
127 }
128 } else {
129 self->last_x = event_x * scale_factor;
130 self->last_y = event_y * scale_factor;
131 fl_scrolling_view_delegate_send_mouse_pointer_event(
132 self->view_delegate,
133 FlutterPointerPhase::kMove /* arbitrary value, phase will be ignored as
134 this is a discrete scroll event */
135 ,
136 event_time * kMicrosecondsPerMillisecond, event_x * scale_factor,
137 event_y * scale_factor, scroll_delta_x, scroll_delta_y, 0);
138 }
139 }

References event, fl_scrolling_view_delegate_send_mouse_pointer_event(), fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), kMicrosecondsPerMillisecond, self, 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: the #FlScrollingManager self.

Inform the scrolling manager that a zoom gesture has begun.

Definition at line 168 of file fl_scrolling_manager.cc.

168 {
169 self->zoom_started = true;
170 if (!self->rotate_started) {
171 self->scale = 1;
172 self->rotation = 0;
173 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
174 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
175 kPanZoomStart, 0, 0, 0, 0);
176 }
177 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and self.

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: the #FlScrollingManager self.

Inform the scrolling manager that a zoom gesture has ended.

Definition at line 185 of file fl_scrolling_manager.cc.

185 {
186 self->zoom_started = false;
187 if (!self->rotate_started) {
188 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
189 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
190 kPanZoomEnd, 0, 0, 0, 0);
191 }
192 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and self.

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: the #FlScrollingManager self. @scale: the zoom scale.

Inform the scrolling manager that a zoom gesture has updated.

Definition at line 178 of file fl_scrolling_manager.cc.

179 {
180 self->scale = scale;
181 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
182 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
183 kPanZoomUpdate, 0, 0, self->scale, self->rotation);
184 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and self.

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 41 of file fl_scrolling_manager.cc.

42 {
43 g_return_val_if_fail(FL_IS_SCROLLING_VIEW_DELEGATE(view_delegate), nullptr);
44
45 FlScrollingManager* self = FL_SCROLLING_MANAGER(
46 g_object_new(fl_scrolling_manager_get_type(), nullptr));
47
48 self->view_delegate = view_delegate;
49 g_object_add_weak_pointer(
50 G_OBJECT(view_delegate),
51 reinterpret_cast<gpointer*>(&(self->view_delegate)));
52
53 self->pan_started = false;
54 self->zoom_started = false;
55 self->rotate_started = false;
56
57 return self;
58 }

References g_object_add_weak_pointer(), and self.

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: the #FlScrollingManager self. @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 60 of file fl_scrolling_manager.cc.

62 {
63 self->last_x = x;
64 self->last_y = y;
65 }

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
self
GdkEvent FlView * self
Definition: fl_view.cc:100
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