| Flutter Linux Embedder |

Classes | Functions | Variables
fl_scrolling_manager.cc File Reference
`#include "flutter/shell/platform/linux/fl_scrolling_manager.h"`

Go to the source code of this file.

## Classes
struct | _FlScrollingManager

## Functions
| G_DEFINE_TYPE (FlScrollingManager, fl_scrolling_manager, G_TYPE_OBJECT)
static void | fl_scrolling_manager_dispose (GObject *object)
static void | fl_scrolling_manager_class_init (FlScrollingManagerClass *klass)
static void | fl_scrolling_manager_init (FlScrollingManager *self)
FlScrollingManager * | fl_scrolling_manager_new (FlScrollingViewDelegate *view_delegate)
void | fl_scrolling_manager_set_last_mouse_position (FlScrollingManager *self, gdouble x, gdouble y)
void | fl_scrolling_manager_handle_scroll_event (FlScrollingManager *self, GdkEventScroll *event, gint scale_factor)
void | fl_scrolling_manager_handle_rotation_begin (FlScrollingManager *self)
void | fl_scrolling_manager_handle_rotation_update (FlScrollingManager *self, gdouble rotation)
void | fl_scrolling_manager_handle_rotation_end (FlScrollingManager *self)
void | fl_scrolling_manager_handle_zoom_begin (FlScrollingManager *self)
void | fl_scrolling_manager_handle_zoom_update (FlScrollingManager *self, gdouble scale)
void | fl_scrolling_manager_handle_zoom_end (FlScrollingManager *self)

## Variables
static constexpr int | kMicrosecondsPerMillisecond = 1000

## Function Documentation

## ◆ fl_scrolling_manager_class_init()

static void fl_scrolling_manager_class_init | ( | FlScrollingManagerClass * | klass | ) |
| static

Definition at line 31 of file fl_scrolling_manager.cc.

31 {
32 G_OBJECT_CLASS(klass)->dispose = fl_scrolling_manager_dispose;
33 }

References fl_scrolling_manager_dispose().

## ◆ fl_scrolling_manager_dispose()

static void fl_scrolling_manager_dispose | ( | GObject * | object | ) |
| static

Definition at line 37 of file fl_scrolling_manager.cc.

37 {
38 G_OBJECT_CLASS(fl_scrolling_manager_parent_class)->dispose(object);
39 }

Referenced by fl_scrolling_manager_class_init().

## ◆ 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 130 of file fl_scrolling_manager.cc.

130 {
131 self->rotate_started = true;
132 if (!self->zoom_started) {
133 self->scale = 1;
134 self->rotation = 0;
135 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
136 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
137 kPanZoomStart, 0, 0, 0, 0);
138 }
139 }

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

148 {
149 self->rotate_started = false;
150 if (!self->zoom_started) {
151 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
152 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
153 kPanZoomEnd, 0, 0, 0, 0);
154 }
155 }

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

142 {
143 self->rotation = rotation;
144 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
145 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
146 kPanZoomUpdate, 0, 0, self->scale, self->rotation);
147 }

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

References event, fl_scrolling_view_delegate_send_mouse_pointer_event(), fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), kMicrosecondsPerMillisecond, self, _FlKeyEvent::time, 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 157 of file fl_scrolling_manager.cc.

157 {
158 self->zoom_started = true;
159 if (!self->rotate_started) {
160 self->scale = 1;
161 self->rotation = 0;
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 kPanZoomStart, 0, 0, 0, 0);
165 }
166 }

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

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

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

168 {
169 self->scale = scale;
170 fl_scrolling_view_delegate_send_pointer_pan_zoom_event(
171 self->view_delegate, g_get_real_time(), self->last_x, self->last_y,
172 kPanZoomUpdate, 0, 0, self->scale, self->rotation);
173 }

References fl_scrolling_view_delegate_send_pointer_pan_zoom_event(), and self.

Referenced by gesture_zoom_update_cb().

## ◆ fl_scrolling_manager_init()

static void fl_scrolling_manager_init | ( | FlScrollingManager * | self | ) |
| static

Definition at line 35 of file fl_scrolling_manager.cc.

35 {}

## ◆ 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_DEFINE_TYPE()

G_DEFINE_TYPE | ( | FlScrollingManager | ,
|  | fl_scrolling_manager | ,
|  | G_TYPE_OBJECT |
| ) |  |

## Variable Documentation

## ◆ kMicrosecondsPerMillisecond

constexpr int kMicrosecondsPerMillisecond = 1000
| static constexpr

Definition at line 7 of file fl_scrolling_manager.cc.

Referenced by fl_scrolling_manager_handle_scroll_event().

_FlKeyEvent::time
guint32 time
Definition: fl_key_event.h:33
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
fl_scrolling_manager_dispose
static void fl_scrolling_manager_dispose(GObject *object)
Definition: fl_scrolling_manager.cc:37
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