From d53f19c249518a3d06731c85e79b61a25ebb27ea Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 3 Apr 2024 19:03:48 +0900 Subject: [PATCH] Add view_id for FlutterPointerEvent (#60) --- flutter/shell/platform/tizen/flutter_tizen.cc | 3 ++- flutter/shell/platform/tizen/flutter_tizen_elementary.cc | 4 ++-- flutter/shell/platform/tizen/flutter_tizen_engine.h | 6 ++++++ flutter/shell/platform/tizen/flutter_tizen_nui.cc | 4 ++-- flutter/shell/platform/tizen/flutter_tizen_view.cc | 7 +++++-- flutter/shell/platform/tizen/flutter_tizen_view.h | 9 ++++++++- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/flutter/shell/platform/tizen/flutter_tizen.cc b/flutter/shell/platform/tizen/flutter_tizen.cc index ec31a83..977d085 100644 --- a/flutter/shell/platform/tizen/flutter_tizen.cc +++ b/flutter/shell/platform/tizen/flutter_tizen.cc @@ -218,7 +218,8 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromNewWindow( #endif } - auto view = std::make_unique(std::move(window)); + auto view = std::make_unique( + flutter::kImplicitViewId, std::move(window)); // Take ownership of the engine, starting it if necessary. view->SetEngine( diff --git a/flutter/shell/platform/tizen/flutter_tizen_elementary.cc b/flutter/shell/platform/tizen/flutter_tizen_elementary.cc index 9123930..c5640ce 100644 --- a/flutter/shell/platform/tizen/flutter_tizen_elementary.cc +++ b/flutter/shell/platform/tizen/flutter_tizen_elementary.cc @@ -30,8 +30,8 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromElmParent( view_properties.width, view_properties.height, static_cast(parent)); - auto view = - std::make_unique(std::move(tizen_view)); + auto view = std::make_unique( + flutter::kImplicitViewId, std::move(tizen_view)); // Take ownership of the engine, starting it if necessary. view->SetEngine( diff --git a/flutter/shell/platform/tizen/flutter_tizen_engine.h b/flutter/shell/platform/tizen/flutter_tizen_engine.h index a3525a9..7e160bb 100644 --- a/flutter/shell/platform/tizen/flutter_tizen_engine.h +++ b/flutter/shell/platform/tizen/flutter_tizen_engine.h @@ -45,6 +45,12 @@ struct FlutterDesktopMessenger { namespace flutter { +// The view ID for a single-view Flutter app. +// +// See: +// https://api.flutter.dev/flutter/dart-ui/PlatformDispatcher/implicitView.html +constexpr FlutterViewId kImplicitViewId = 0; + class FlutterTizenView; // Manages state associated with the underlying FlutterEngine. diff --git a/flutter/shell/platform/tizen/flutter_tizen_nui.cc b/flutter/shell/platform/tizen/flutter_tizen_nui.cc index f9ad52e..74fae07 100644 --- a/flutter/shell/platform/tizen/flutter_tizen_nui.cc +++ b/flutter/shell/platform/tizen/flutter_tizen_nui.cc @@ -39,8 +39,8 @@ FlutterDesktopViewRef FlutterDesktopViewCreateFromImageView( reinterpret_cast(native_image_queue), default_window_id); - auto view = - std::make_unique(std::move(tizen_view)); + auto view = std::make_unique( + flutter::kImplicitViewId, std::move(tizen_view)); // Take ownership of the engine, starting it if necessary. view->SetEngine( diff --git a/flutter/shell/platform/tizen/flutter_tizen_view.cc b/flutter/shell/platform/tizen/flutter_tizen_view.cc index 6a66fb3..5074790 100644 --- a/flutter/shell/platform/tizen/flutter_tizen_view.cc +++ b/flutter/shell/platform/tizen/flutter_tizen_view.cc @@ -66,8 +66,9 @@ double ComputePixelRatio(flutter::TizenViewBase* view) { namespace flutter { -FlutterTizenView::FlutterTizenView(std::unique_ptr tizen_view) - : tizen_view_(std::move(tizen_view)) { +FlutterTizenView::FlutterTizenView(FlutterViewId view_id, + std::unique_ptr tizen_view) + : view_id_(view_id), tizen_view_(std::move(tizen_view)) { tizen_view_->SetView(this); if (auto* window = dynamic_cast(tizen_view_.get())) { @@ -442,6 +443,7 @@ void FlutterTizenView::SendFlutterPointerEvent(FlutterPointerPhase phase, event.device = state->pointer_id; event.device_kind = state->device_kind; event.buttons = state->buttons; + event.view_id = view_id(); engine_->SendPointerEvent(event); state->flutter_state_is_added = true; @@ -461,6 +463,7 @@ void FlutterTizenView::SendFlutterPointerEvent(FlutterPointerPhase phase, event.device = state->pointer_id; event.device_kind = state->device_kind; event.buttons = state->buttons; + event.view_id = view_id(); engine_->SendPointerEvent(event); } diff --git a/flutter/shell/platform/tizen/flutter_tizen_view.h b/flutter/shell/platform/tizen/flutter_tizen_view.h index dddbdd1..f0e58de 100644 --- a/flutter/shell/platform/tizen/flutter_tizen_view.h +++ b/flutter/shell/platform/tizen/flutter_tizen_view.h @@ -25,10 +25,14 @@ namespace flutter { class FlutterTizenView : public TizenViewEventHandlerDelegate { public: - FlutterTizenView(std::unique_ptr tizen_view); + FlutterTizenView(FlutterViewId view_id, + std::unique_ptr tizen_view); virtual ~FlutterTizenView(); + // Get the view's unique identifier. + FlutterViewId view_id() const { return view_id_; } + // Configures the window instance with an instance of a running Flutter // engine. void SetEngine(std::unique_ptr engine); @@ -170,6 +174,9 @@ class FlutterTizenView : public TizenViewEventHandlerDelegate { // The engine associated with this view. std::unique_ptr engine_; + // The view's unique identifier. + FlutterViewId view_id_; + // The platform view associated with this Flutter view. std::unique_ptr tizen_view_;