@@ -66,6 +66,12 @@ void WaylandDisplay::InitializeApplication(
66
66
return reinterpret_cast <WaylandDisplay*>(userdata)
67
67
->OnApplicationGetOnscreenFBO ();
68
68
};
69
+ #if 0
70
+ config.open_gl.make_resource_current = [](void* userdata) -> bool {
71
+ return reinterpret_cast<WaylandDisplay*>(userdata)
72
+ ->OnApplicationMakeResouceCurrent();
73
+ };
74
+ #endif
69
75
config.open_gl .gl_proc_resolver = [](void * userdata,
70
76
const char * name) -> void * {
71
77
auto address = eglGetProcAddress (name);
@@ -91,12 +97,15 @@ void WaylandDisplay::InitializeApplication(
91
97
command_line_args_c.push_back (arg.c_str ());
92
98
}
93
99
94
- FlutterProjectArgs args = {
95
- .struct_size = sizeof (FlutterProjectArgs),
96
- .assets_path = bundle_path.c_str (),
97
- .icu_data_path = icu_data_path.c_str (),
98
- .command_line_argc = static_cast <int >(command_line_args_c.size ()),
99
- .command_line_argv = command_line_args_c.data (),
100
+ FlutterProjectArgs args = {};
101
+ args.struct_size = sizeof (FlutterProjectArgs);
102
+ args.assets_path = bundle_path.c_str ();
103
+ args.icu_data_path = icu_data_path.c_str ();
104
+ args.command_line_argc = static_cast <int >(command_line_args_c.size ());
105
+ args.command_line_argv = command_line_args_c.data ();
106
+ args.platform_message_callback = [](const FlutterPlatformMessage* msg,
107
+ void * userdata) -> void {
108
+ return reinterpret_cast <WaylandDisplay*>(userdata)->OnPlatformMessage (msg);
100
109
};
101
110
102
111
FlutterEngine engine = nullptr ;
@@ -187,9 +196,6 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height,
187
196
188
197
display.roundtrip ();
189
198
190
- // Get input devices
191
- // touch = seat.get_touch();
192
-
193
199
// load cursor theme
194
200
#if 0
195
201
cursor_theme_t cursor_theme = cursor_theme_t("default", 16, shm);
@@ -203,13 +209,16 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height,
203
209
204
210
if (has_touch)
205
211
{
212
+ std::cout << " Touch Present" << std::endl;
206
213
touch = seat.get_touch ();
214
+ static FlutterPointerPhase TouchPhase = kUp ;
207
215
208
216
touch.on_down () = [&] (uint32_t serial, uint32_t time, surface_t surface, int32_t id, double x, double y)
209
217
{
210
218
FlutterPointerEvent event = {};
211
219
event.struct_size = sizeof (event);
212
220
event.phase = kDown ;
221
+ TouchPhase = event.phase ;
213
222
cur_x = x;
214
223
cur_y = y;
215
224
event.x = x;
@@ -226,6 +235,7 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height,
226
235
FlutterPointerEvent event = {};
227
236
event.struct_size = sizeof (event);
228
237
event.phase = kUp ;
238
+ TouchPhase = event.phase ;
229
239
event.x = cur_x;
230
240
event.y = cur_y;
231
241
event.timestamp =
@@ -242,7 +252,7 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height,
242
252
243
253
FlutterPointerEvent event = {};
244
254
event.struct_size = sizeof (event);
245
- event.phase = kMove ;
255
+ event.phase = (TouchPhase == kUp ) ? kHover : kMove ;
246
256
event.x = cur_x;
247
257
event.y = cur_y;
248
258
event.timestamp =
@@ -255,7 +265,9 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height,
255
265
256
266
if (has_pointer)
257
267
{
268
+ std::cout << " Pointer Present" << std::endl;
258
269
pointer = seat.get_pointer ();
270
+ static FlutterPointerPhase PointerPhase = kUp ;
259
271
260
272
pointer.on_enter () = [&] (uint32_t serial, surface_t surface, int32_t surface_x, int32_t surface_y)
261
273
{
@@ -283,14 +295,15 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height,
283
295
FlutterEngineSendPointerEvent (engine_, &event, 1 );
284
296
};
285
297
286
- pointer.on_motion () = [&] (uint32_t time, double surface_x, double surface_y)
298
+ static bool button = false ;
299
+ pointer.on_motion () = [&] (uint32_t time, double surface_x, double surface_y)
287
300
{
288
301
cur_x = surface_x;
289
302
cur_y = surface_y;
290
303
291
304
FlutterPointerEvent event = {};
292
305
event.struct_size = sizeof (event);
293
- event.phase = kMove ;
306
+ event.phase = (PointerPhase == kUp ) ? kHover : kMove ;
294
307
event.x = surface_x;
295
308
event.y = surface_y;
296
309
event.timestamp =
@@ -305,6 +318,7 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height,
305
318
FlutterPointerEvent event = {};
306
319
event.struct_size = sizeof (event);
307
320
event.phase = (state == pointer_button_state::pressed) ? kDown : kUp ;
321
+ PointerPhase = event.phase ;
308
322
switch (button)
309
323
{
310
324
case BTN_LEFT:
@@ -324,15 +338,6 @@ WaylandDisplay::WaylandDisplay(size_t width, size_t height,
324
338
std::chrono::high_resolution_clock::now ().time_since_epoch ())
325
339
.count ();
326
340
FlutterEngineSendPointerEvent (engine_, &event, 1 );
327
- #if 0
328
- if(button == BTN_LEFT && state == pointer_button_state::pressed)
329
- {
330
- if(xdg_toplevel)
331
- xdg_toplevel.move(seat, serial);
332
- else
333
- shell_surface.move(seat, serial);
334
- }
335
- #endif
336
341
};
337
342
338
343
pointer.on_axis () = [&] (uint32_t time, pointer_axis axis, double value)
@@ -381,7 +386,7 @@ WaylandDisplay::~WaylandDisplay() noexcept(false) {
381
386
382
387
void WaylandDisplay::init_egl ()
383
388
{
384
- if (eglBindAPI (EGL_OPENGL_ES_API ) == EGL_FALSE)
389
+ if (eglBindAPI (EGL_OPENGL_API ) == EGL_FALSE)
385
390
throw std::runtime_error (" eglBindAPI" );
386
391
387
392
egldisplay = eglGetDisplay (display);
@@ -543,4 +548,26 @@ uint32_t WaylandDisplay::OnApplicationGetOnscreenFBO() {
543
548
return 0 ; // FBO0
544
549
}
545
550
551
+ // / This is an optional callback. Flutter will ask the emebdder to create a GL
552
+ // / context current on a background thread. If the embedder is able to do so,
553
+ // / Flutter will assume that this context is in the same sharegroup as the
554
+ // / main rendering context and use this context for asynchronous texture
555
+ // / uploads.
556
+ bool WaylandDisplay::OnApplicationMakeResouceCurrent () {
557
+ return true ;
558
+ }
559
+
560
+ void WaylandDisplay::OnPlatformMessage (const FlutterPlatformMessage* msg)
561
+ {
562
+ FLWAY_LOG << " Channel: " << msg->channel << std::endl;
563
+ FLWAY_LOG << " Message Size: " << msg->message_size << std::endl;
564
+ FLWAY_LOG << " Message: " << msg->message << std::endl;
565
+
566
+ auto result = FlutterEngineSendPlatformMessageResponse (engine_, msg->response_handle , NULL , 0 );
567
+ if (result != kSuccess ) {
568
+ FLWAY_ERROR << " Could not send platform message response" << std::endl;
569
+ return ;
570
+ }
571
+ }
572
+
546
573
} // namespace flutter
0 commit comments