mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-19 22:54:50 -04:00
adapt new window manager
Signed-off-by: sunfei <sunfei.sun@huawei.com> Change-Id: I0369bb9e317b2e8d030647b0dd2a18c8febea1fb
This commit is contained in:
@@ -62,8 +62,9 @@ template("ace_ohos_standard_source_set") {
|
||||
"$ace_flutter_engine_root/skia:ace_skia_$platform",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native",
|
||||
"//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri",
|
||||
"//foundation/graphic/standard:libwmclient",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-client",
|
||||
"//foundation/multimodalinput/input/frameworks/proxy:libmmi-common",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
"//third_party/zlib:libz",
|
||||
]
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "render_service_client/core/ui/rs_ui_director.h"
|
||||
#endif
|
||||
|
||||
#include "window.h"
|
||||
|
||||
#include "adapter/ohos/entrance/ace_application_info.h"
|
||||
#include "adapter/ohos/entrance/ace_container.h"
|
||||
#include "adapter/ohos/entrance/flutter_ace_view.h"
|
||||
@@ -209,40 +211,22 @@ void AceAbility::OnStart(const Want& want)
|
||||
|
||||
// create view.
|
||||
auto flutterAceView = Platform::FlutterAceView::CreateView(abilityId_);
|
||||
OHOS::sptr<OHOS::Window> window = Ability::GetWindow();
|
||||
OHOS::sptr<OHOS::Rosen::Window> window = Ability::GetWindow();
|
||||
|
||||
// regist touch event
|
||||
auto&& touchEventCallback = [aceView = flutterAceView](OHOS::TouchEvent event) -> bool {
|
||||
LOGD("RegistOnTouchCb touchEventCallback called");
|
||||
return aceView->DispatchTouchEvent(aceView, event);
|
||||
};
|
||||
window->OnTouch(touchEventCallback);
|
||||
// register surface change callback
|
||||
auto&& surfaceChangedCallBack = [flutterAceView](uint32_t width, uint32_t height) {
|
||||
LOGD("RegistWindowInfoChangeCb surfaceChangedCallBack called");
|
||||
flutter::ViewportMetrics metrics;
|
||||
metrics.physical_width = width;
|
||||
metrics.physical_height = height;
|
||||
Platform::FlutterAceView::SetViewportMetrics(flutterAceView, metrics);
|
||||
Platform::FlutterAceView::SurfaceChanged(flutterAceView, width, height, 0);
|
||||
};
|
||||
window->OnSizeChange(surfaceChangedCallBack);
|
||||
OHOS::sptr<OHOS::Rosen::IWindowChangeListener> thisAbility(this);
|
||||
window->RegisterWindowChangeListener(thisAbility);
|
||||
|
||||
Platform::FlutterAceView::SurfaceCreated(flutterAceView, window);
|
||||
|
||||
// set metrics
|
||||
BufferRequestConfig windowConfig = {
|
||||
.width = window->GetSurface()->GetDefaultWidth(),
|
||||
.height = window->GetSurface()->GetDefaultHeight(),
|
||||
.strideAlignment = 0x8,
|
||||
.format = PIXEL_FMT_RGBA_8888,
|
||||
.usage = window->GetSurface()->GetDefaultUsage(),
|
||||
};
|
||||
LOGI("AceAbility: windowConfig: width: %{public}d, height: %{public}d", windowConfig.width, windowConfig.height);
|
||||
int32_t width = window->GetRect().width_;
|
||||
int32_t height = window->GetRect().height_;
|
||||
LOGI("AceAbility: windowConfig: width: %{public}d, height: %{public}d", width, height);
|
||||
|
||||
flutter::ViewportMetrics metrics;
|
||||
metrics.physical_width = windowConfig.width;
|
||||
metrics.physical_height = windowConfig.height;
|
||||
metrics.physical_width = width;
|
||||
metrics.physical_height = height;
|
||||
Platform::FlutterAceView::SetViewportMetrics(flutterAceView, metrics);
|
||||
|
||||
if (srcPath.empty()) {
|
||||
@@ -254,8 +238,8 @@ void AceAbility::OnStart(const Want& want)
|
||||
}
|
||||
|
||||
// set view
|
||||
Platform::AceContainer::SetView(flutterAceView, density_, windowConfig.width, windowConfig.height);
|
||||
Platform::FlutterAceView::SurfaceChanged(flutterAceView, windowConfig.width, windowConfig.height, 0);
|
||||
Platform::AceContainer::SetView(flutterAceView, density_, width, height);
|
||||
Platform::FlutterAceView::SurfaceChanged(flutterAceView, width, height, 0);
|
||||
|
||||
// get url
|
||||
std::string parsedPageUrl;
|
||||
@@ -295,7 +279,6 @@ void AceAbility::OnStart(const Want& want)
|
||||
// set window id & action event handler
|
||||
auto context = Platform::AceContainer::GetContainer(abilityId_)->GetPipelineContext();
|
||||
if (context != nullptr) {
|
||||
context->SetWindowId(window->GetID());
|
||||
context->SetActionEventHandler(actionEventHandler);
|
||||
}
|
||||
|
||||
@@ -303,13 +286,12 @@ void AceAbility::OnStart(const Want& want)
|
||||
if (SystemProperties::GetRosenBackendEnabled()) {
|
||||
auto rsUiDirector = OHOS::Rosen::RSUIDirector::Create();
|
||||
if (rsUiDirector != nullptr) {
|
||||
rsUiDirector->SetPlatformSurface(window->GetSurface());
|
||||
auto&& rsSurfaceChangedCallBack = [surfaceChangedCallBack, rsUiDirector](uint32_t width, uint32_t height) {
|
||||
rsUiDirector->SetSurfaceSize(width, height);
|
||||
surfaceChangedCallBack(width, height);
|
||||
};
|
||||
window->OnSizeChange(rsSurfaceChangedCallBack);
|
||||
rsUiDirector->SetSurfaceSize(windowConfig.width, windowConfig.height);
|
||||
rsUiDirector->SetRSSurfaceNode(window->GetSurfaceNode());
|
||||
|
||||
// todo regist on size change()
|
||||
window->RegisterWindowChangeListener(thisAbility);
|
||||
|
||||
rsUiDirector->SetSurfaceNodeSize(width, height);
|
||||
rsUiDirector->SetUITaskRunner(
|
||||
[taskExecutor = Platform::AceContainer::GetContainer(abilityId_)->GetTaskExecutor()]
|
||||
(const std::function<void()>& task) {
|
||||
@@ -389,19 +371,16 @@ void AceAbility::OnBackPressed()
|
||||
LOGI("AceAbility::OnBackPressed called End");
|
||||
}
|
||||
|
||||
bool AceAbility::OnTouchEvent(const TouchEvent &touchEvent)
|
||||
void AceAbility::OnPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
LOGI("AceAbility::OnTouchEvent called ");
|
||||
LOGI("AceAbility::OnPointerEvent called ");
|
||||
auto flutterAceView = static_cast<Platform::FlutterAceView*>(
|
||||
Platform::AceContainer::GetContainer(abilityId_)->GetView());
|
||||
if (!flutterAceView) {
|
||||
LOGE("flutterAceView is null");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
TouchEvent event = touchEvent;
|
||||
bool ret = flutterAceView->DispatchTouchEvent(flutterAceView, event);
|
||||
LOGI("AceAbility::OnTouchEvent called End: ret: %{public}d", ret);
|
||||
return ret;
|
||||
flutterAceView->DispatchTouchEvent(flutterAceView, pointerEvent);
|
||||
}
|
||||
|
||||
void AceAbility::OnNewWant(const Want& want)
|
||||
@@ -516,5 +495,36 @@ void AceAbility::OnRemoteTerminated()
|
||||
LOGI("AceAbility::OnRemoteTerminated finish.");
|
||||
}
|
||||
|
||||
void AceAbility::OnSizeChange(OHOS::Rosen::Rect rect)
|
||||
{
|
||||
uint32_t width = rect.width_;
|
||||
uint32_t height = rect.height_;
|
||||
#ifdef ENABLE_ROSEN_BACKEND
|
||||
auto context = Platform::AceContainer::GetContainer(abilityId_)->GetPipelineContext();
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
auto rsUIDirector = context->GetRSUIDirector();
|
||||
if (!rsUIDirector) {
|
||||
LOGE("rsUIDirector is null");
|
||||
return;
|
||||
}
|
||||
rsUIDirector->SetSurfaceNodeSize(width, height);
|
||||
#endif
|
||||
auto flutterAceView = static_cast<Platform::FlutterAceView*>(
|
||||
Platform::AceContainer::GetContainer(abilityId_)->GetView());
|
||||
|
||||
if (!flutterAceView) {
|
||||
LOGE("flutterAceView is null");
|
||||
return;
|
||||
}
|
||||
|
||||
flutter::ViewportMetrics metrics;
|
||||
metrics.physical_width = width;
|
||||
metrics.physical_height = height;
|
||||
Platform::FlutterAceView::SetViewportMetrics(flutterAceView, metrics);
|
||||
Platform::FlutterAceView::SurfaceChanged(flutterAceView, width, height, 0);
|
||||
}
|
||||
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -23,10 +23,11 @@
|
||||
#include "ability_loader.h"
|
||||
#include "touch_event.h"
|
||||
#include "want.h"
|
||||
#include "window.h"
|
||||
|
||||
namespace OHOS::Ace {
|
||||
|
||||
class AceAbility final : public OHOS::AppExecFwk::Ability {
|
||||
class AceAbility final : public OHOS::AppExecFwk::Ability, public OHOS::Rosen::IWindowChangeListener {
|
||||
public:
|
||||
AceAbility()
|
||||
{
|
||||
@@ -42,7 +43,7 @@ public:
|
||||
void OnForeground(const OHOS::AAFwk::Want& want) override;
|
||||
void OnBackground() override;
|
||||
void OnBackPressed() override;
|
||||
bool OnTouchEvent(const TouchEvent &touchEvent) override;
|
||||
void OnPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
|
||||
void OnNewWant(const OHOS::AAFwk::Want& want) override;
|
||||
void OnRestoreAbilityState(const OHOS::AppExecFwk::PacMap& inState) override;
|
||||
void OnSaveAbilityState(OHOS::AppExecFwk::PacMap& outState) override;
|
||||
@@ -57,6 +58,9 @@ public:
|
||||
void OnCompleteContinuation(int result) override;
|
||||
void OnRemoteTerminated() override;
|
||||
|
||||
// override Rosen::IWindowChangeListener virtual callback function
|
||||
void OnSizeChange(OHOS::Rosen::Rect rect) override;
|
||||
|
||||
private:
|
||||
static int32_t instanceId_;
|
||||
static const std::string START_PARAMS_KEY;
|
||||
@@ -64,7 +68,7 @@ private:
|
||||
static const std::string CONTINUE_PARAMS_KEY;
|
||||
|
||||
int32_t abilityId_ = 0;
|
||||
float density_ = 2.0f; // 2.0 for wgr, 3.0 for phone
|
||||
float density_ = 1.5f; // 1.5 for wgr, 3.0 for phone
|
||||
std::string remotePageUrl_;
|
||||
std::string remoteData_;
|
||||
std::string pageUrl_;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "adapter/ohos/entrance/flutter_ace_view.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
#include "base/log/dump_log.h"
|
||||
@@ -37,31 +38,34 @@ namespace {
|
||||
constexpr int32_t ROTATION_DIVISOR = 64;
|
||||
constexpr double PERMIT_ANGLE_VALUE = 0.5;
|
||||
|
||||
TouchPoint ConvertTouchEvent(const OHOS::TouchEvent& touchEvent)
|
||||
TouchPoint ConvertTouchEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
int32_t id = static_cast<int32_t>(touchEvent.GetIndex());
|
||||
MmiPoint mmiPoint = touchEvent.GetPointerPosition(id);
|
||||
std::chrono::microseconds micros(touchEvent.GetOccurredTime());
|
||||
int32_t pointerID = pointerEvent->GetPointerId();
|
||||
MMI::PointerEvent::PointerItem item;
|
||||
bool ret = pointerEvent->GetPointerItem(pointerID, item);
|
||||
if (!ret) {
|
||||
LOGE("get pointer item failed.");
|
||||
return TouchPoint();
|
||||
}
|
||||
std::chrono::microseconds micros(item.GetDownTime());
|
||||
TimeStamp time(micros);
|
||||
TouchPoint point { id, mmiPoint.GetX(), mmiPoint.GetY(), TouchType::UNKNOWN, time, touchEvent.GetRadius(id) };
|
||||
switch (touchEvent.GetAction()) {
|
||||
case OHOS::TouchEnum::CANCEL:
|
||||
|
||||
int32_t pressWidth = item.GetWidth();
|
||||
int32_t pressHeight = item.GetHeight();
|
||||
double size = std::max(pressWidth, pressHeight) / 2.0; // just get the max of width and height
|
||||
TouchPoint point { pointerID, item.GetLocalX(), item.GetLocalX(), TouchType::UNKNOWN, time, size };
|
||||
int32_t action = pointerEvent->GetPointerAction();
|
||||
switch (action) {
|
||||
case OHOS::MMI::PointerEvent::POINTER_ACTION_CANCEL:
|
||||
point.type = TouchType::CANCEL;
|
||||
break;
|
||||
case OHOS::TouchEnum::HOVER_POINTER_ENTER:
|
||||
case OHOS::TouchEnum::HOVER_POINTER_MOVE:
|
||||
case OHOS::TouchEnum::HOVER_POINTER_EXIT:
|
||||
LOGD("ConvertTouchEvent not implement type:%{public}d", touchEvent.GetAction());
|
||||
break;
|
||||
case OHOS::TouchEnum::PRIMARY_POINT_DOWN:
|
||||
case OHOS::TouchEnum::OTHER_POINT_DOWN:
|
||||
case OHOS::MMI::PointerEvent::POINTER_ACTION_DOWN:
|
||||
point.type = TouchType::DOWN;
|
||||
break;
|
||||
case OHOS::TouchEnum::POINT_MOVE:
|
||||
case OHOS::MMI::PointerEvent::POINTER_ACTION_MOVE:
|
||||
point.type = TouchType::MOVE;
|
||||
break;
|
||||
case OHOS::TouchEnum::PRIMARY_POINT_UP:
|
||||
case OHOS::TouchEnum::OTHER_POINT_UP:
|
||||
case OHOS::MMI::PointerEvent::POINTER_ACTION_UP:
|
||||
point.type = TouchType::UP;
|
||||
break;
|
||||
default:
|
||||
@@ -71,70 +75,73 @@ TouchPoint ConvertTouchEvent(const OHOS::TouchEvent& touchEvent)
|
||||
return point;
|
||||
}
|
||||
|
||||
void GetMouseEventAction(const OHOS::MouseEvent& mouseEvent, MouseEvent& events)
|
||||
void GetMouseEventAction(int32_t action, MouseEvent& events)
|
||||
{
|
||||
const MouseActionEnum action = static_cast<MouseActionEnum>(mouseEvent.GetAction());
|
||||
switch (action) {
|
||||
case MouseActionEnum::PRESS:
|
||||
case OHOS::MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN:
|
||||
events.action = MouseAction::PRESS;
|
||||
break;
|
||||
case MouseActionEnum::RELEASE:
|
||||
case OHOS::MMI::PointerEvent::POINTER_ACTION_BUTTON_UP:
|
||||
events.action = MouseAction::RELEASE;
|
||||
break;
|
||||
case MouseActionEnum::MOVE:
|
||||
case OHOS::MMI::PointerEvent::POINTER_ACTION_MOVE:
|
||||
events.action = MouseAction::MOVE;
|
||||
break;
|
||||
case MouseActionEnum::HOVER_ENTER:
|
||||
events.action = MouseAction::HOVER_ENTER;
|
||||
break;
|
||||
case MouseActionEnum::HOVER_MOVE:
|
||||
events.action = MouseAction::HOVER_MOVE;
|
||||
break;
|
||||
case MouseActionEnum::HOVER_EXIT:
|
||||
events.action = MouseAction::HOVER_EXIT;
|
||||
break;
|
||||
default:
|
||||
events.action = MouseAction::NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GetMouseEventButton(const OHOS::MouseEvent& mouseEvent, MouseEvent& events)
|
||||
void GetMouseEventButton(int32_t button, MouseEvent& events)
|
||||
{
|
||||
switch (mouseEvent.GetActionButton()) {
|
||||
case MouseButtonEnum::LEFT_BUTTON:
|
||||
switch (button) {
|
||||
case OHOS::MMI::PointerEvent::MOUSE_BUTTON_LEFT:
|
||||
events.button = MouseButton::LEFT_BUTTON;
|
||||
break;
|
||||
case MouseButtonEnum::RIGHT_BUTTON:
|
||||
case OHOS::MMI::PointerEvent::MOUSE_BUTTON_RIGHT:
|
||||
events.button = MouseButton::RIGHT_BUTTON;
|
||||
break;
|
||||
case MouseButtonEnum::MIDDLE_BUTTON:
|
||||
case OHOS::MMI::PointerEvent::MOUSE_BUTTON_MIDDLE:
|
||||
events.button = MouseButton::MIDDLE_BUTTON;
|
||||
break;
|
||||
case MouseButtonEnum::BACK_BUTTON:
|
||||
events.button = MouseButton::BACK_BUTTON;
|
||||
break;
|
||||
case MouseButtonEnum::FORWARD_BUTTON:
|
||||
events.button = MouseButton::FORWARD_BUTTON;
|
||||
break;
|
||||
default:
|
||||
events.button = MouseButton::NONE_BUTTON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertMouseEvent(OHOS::MouseEvent& mouseEvent, MouseEvent& events)
|
||||
void ConvertMouseEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, MouseEvent& events)
|
||||
{
|
||||
MmiPoint mmiPoint = mouseEvent.GetCursor();
|
||||
events.x = mmiPoint.GetX();
|
||||
events.y = mmiPoint.GetY();
|
||||
events.z = mmiPoint.GetZ();
|
||||
int32_t pointerID = pointerEvent->GetPointerId();
|
||||
MMI::PointerEvent::PointerItem item;
|
||||
bool ret = pointerEvent->GetPointerItem(pointerID, item);
|
||||
if (!ret) {
|
||||
LOGE("get pointer item failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
GetMouseEventAction(mouseEvent, events);
|
||||
GetMouseEventButton(mouseEvent, events);
|
||||
events.x = item.GetLocalX();
|
||||
events.y = item.GetLocalX();
|
||||
int32_t action = pointerEvent->GetPointerAction();
|
||||
GetMouseEventAction(action, events);
|
||||
int32_t button = pointerEvent->GetButtonId();
|
||||
GetMouseEventButton(button, events);
|
||||
|
||||
events.pressedButtons = static_cast<size_t>(mouseEvent.GetPressedButtons());
|
||||
std::chrono::microseconds micros(mouseEvent.GetOccurredTime());
|
||||
std::set<int32_t> pressedSet = pointerEvent->GetPressedButtons();
|
||||
uint32_t pressedButtons = 0;
|
||||
if (pressedSet.find(OHOS::MMI::PointerEvent::MOUSE_BUTTON_LEFT) != pressedSet.end()) {
|
||||
pressedButtons &= static_cast<uint32_t>(MouseButton::LEFT_BUTTON);
|
||||
}
|
||||
if (pressedSet.find(OHOS::MMI::PointerEvent::MOUSE_BUTTON_RIGHT) != pressedSet.end()) {
|
||||
pressedButtons &= static_cast<uint32_t>(MouseButton::RIGHT_BUTTON);
|
||||
}
|
||||
if (pressedSet.find(OHOS::MMI::PointerEvent::MOUSE_BUTTON_MIDDLE) != pressedSet.end()) {
|
||||
pressedButtons &= static_cast<uint32_t>(MouseButton::MIDDLE_BUTTON);
|
||||
}
|
||||
events.pressedButtons = static_cast<int32_t>(pressedButtons);
|
||||
|
||||
std::chrono::microseconds micros(item.GetDownTime());
|
||||
TimeStamp time(micros);
|
||||
events.time = time;
|
||||
}
|
||||
@@ -165,9 +172,9 @@ FlutterAceView* FlutterAceView::CreateView(int32_t instanceId)
|
||||
return aceSurface;
|
||||
}
|
||||
|
||||
void FlutterAceView::SurfaceCreated(FlutterAceView* view, OHOS::Window* window)
|
||||
void FlutterAceView::SurfaceCreated(FlutterAceView* view, OHOS::sptr<OHOS::Rosen::Window> window)
|
||||
{
|
||||
LOGI(">>> FlutterAceView::SurfaceCreated, pWnd:%{public}p", window);
|
||||
LOGI(">>> FlutterAceView::SurfaceCreated, pWnd:%{public}p", &(*window));
|
||||
if (window == nullptr) {
|
||||
LOGE("FlutterAceView::SurfaceCreated, window is nullptr");
|
||||
return;
|
||||
@@ -216,24 +223,17 @@ void FlutterAceView::SetViewportMetrics(FlutterAceView* view, const flutter::Vie
|
||||
}
|
||||
}
|
||||
|
||||
bool FlutterAceView::DispatchTouchEvent(FlutterAceView* view, const OHOS::TouchEvent& touchEvent)
|
||||
void FlutterAceView::DispatchTouchEvent(FlutterAceView* view, const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
if (touchEvent.GetSourceDevice() == OHOS::SourceDevice::MOUSE) {
|
||||
if (pointerEvent->GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_MOUSE) {
|
||||
// mouse event
|
||||
LOGD("DispatchTouchEvent MouseEvent");
|
||||
const MultimodalEvent* multimodalEvent = touchEvent.GetMultimodalEvent();
|
||||
OHOS::MouseEvent* mouseEvent = (OHOS::MouseEvent*)multimodalEvent;
|
||||
if (mouseEvent == nullptr) {
|
||||
LOGE("mouseEvent is nullptr");
|
||||
return false;
|
||||
}
|
||||
view->ProcessMouseEvent(*mouseEvent);
|
||||
view->ProcessMouseEvent(pointerEvent);
|
||||
} else {
|
||||
// touch event
|
||||
LOGD("DispatchTouchEvent TouchEvent");
|
||||
return view->ProcessTouchEvent(touchEvent);
|
||||
view->ProcessTouchEvent(pointerEvent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FlutterAceView::DispatchKeyEvent(FlutterAceView* view, int32_t keyCode, int32_t action, int32_t repeatTime,
|
||||
@@ -294,10 +294,9 @@ void FlutterAceView::SetShellHolder(std::unique_ptr<flutter::OhosShellHolder> ho
|
||||
shell_holder_ = std::move(holder);
|
||||
}
|
||||
|
||||
bool FlutterAceView::ProcessTouchEvent(const OHOS::TouchEvent& touchEvent)
|
||||
void FlutterAceView::ProcessTouchEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
TouchPoint touchPoint = ConvertTouchEvent(touchEvent);
|
||||
bool forbiddenToPlatform = false;
|
||||
TouchPoint touchPoint = ConvertTouchEvent(pointerEvent);
|
||||
if (touchPoint.type != TouchType::UNKNOWN) {
|
||||
if (touchEventCallback_) {
|
||||
touchEventCallback_(touchPoint);
|
||||
@@ -305,19 +304,12 @@ bool FlutterAceView::ProcessTouchEvent(const OHOS::TouchEvent& touchEvent)
|
||||
} else {
|
||||
LOGW("Unknown event.");
|
||||
}
|
||||
|
||||
#ifdef WEARABLE_PRODUCT
|
||||
forbiddenToPlatform = forbiddenToPlatform || IsNeedForbidToPlatform(point);
|
||||
#endif
|
||||
|
||||
// if last page, let os know so that to quit app.
|
||||
return forbiddenToPlatform || (!IsLastPage());
|
||||
}
|
||||
|
||||
void FlutterAceView::ProcessMouseEvent(OHOS::MouseEvent& mouseEvent)
|
||||
void FlutterAceView::ProcessMouseEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
MouseEvent event;
|
||||
ConvertMouseEvent(mouseEvent, event);
|
||||
ConvertMouseEvent(pointerEvent, event);
|
||||
LOGD("ProcessMouseEvent event");
|
||||
|
||||
if (mouseEventCallback_) {
|
||||
|
||||
@@ -42,11 +42,11 @@ public:
|
||||
explicit FlutterAceView(int32_t id) : instanceId_(id) {}
|
||||
~FlutterAceView() override = default;
|
||||
static FlutterAceView* CreateView(int32_t instanceId);
|
||||
static void SurfaceCreated(FlutterAceView* view, OHOS::Window* window);
|
||||
static void SurfaceCreated(FlutterAceView* view, OHOS::sptr<OHOS::Rosen::Window> window);
|
||||
static void SurfaceChanged(FlutterAceView* view, int32_t width, int32_t height, int32_t orientation);
|
||||
static void SetViewportMetrics(FlutterAceView* view, const flutter::ViewportMetrics& metrics);
|
||||
|
||||
static bool DispatchTouchEvent(FlutterAceView* view, const OHOS::TouchEvent& touchEvent);
|
||||
static void DispatchTouchEvent(FlutterAceView* view, const std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
|
||||
static bool DispatchKeyEvent(FlutterAceView* view, int32_t keyCode, int32_t action, int32_t repeatTime,
|
||||
int64_t timeStamp, int64_t timeStampStart);
|
||||
@@ -68,9 +68,9 @@ public:
|
||||
return shell_holder_.get();
|
||||
}
|
||||
|
||||
bool ProcessTouchEvent(const OHOS::TouchEvent& touchEvent);
|
||||
void ProcessTouchEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
|
||||
void ProcessMouseEvent(OHOS::MouseEvent& mouseEvent);
|
||||
void ProcessMouseEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
|
||||
bool ProcessKeyEvent(
|
||||
int32_t keyCode, int32_t keyAction, int32_t repeatTime, int64_t timeStamp = 0, int64_t timeStampStart = 0);
|
||||
|
||||
@@ -63,11 +63,6 @@ UIContentImpl::UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runti
|
||||
}
|
||||
|
||||
void UIContentImpl::Initialize(OHOS::Rosen::Window* window, const std::string& url, NativeValue* storage)
|
||||
{
|
||||
LOGI("Initialize UIContentImpl using rosen window start.");
|
||||
}
|
||||
|
||||
void UIContentImpl::Initialize(OHOS::Window* window, const std::string& url, NativeValue* storage)
|
||||
{
|
||||
window_ = window;
|
||||
startUrl_ = url;
|
||||
@@ -154,12 +149,6 @@ void UIContentImpl::Initialize(OHOS::Window* window, const std::string& url, Nat
|
||||
auto flutterAceView = Platform::FlutterAceView::CreateView(instanceId_);
|
||||
Platform::FlutterAceView::SurfaceCreated(flutterAceView, window_);
|
||||
|
||||
// set window id
|
||||
auto context = container->GetPipelineContext();
|
||||
if (context != nullptr && window_ != nullptr) {
|
||||
context->SetWindowId(window_->GetID());
|
||||
}
|
||||
|
||||
// set view
|
||||
Platform::AceContainer::SetView(flutterAceView, config_.Density(), config_.Width(), config_.Height());
|
||||
Platform::FlutterAceView::SurfaceChanged(flutterAceView, config_.Width(), config_.Height(), config_.Orientation());
|
||||
@@ -205,20 +194,15 @@ bool UIContentImpl::ProcessBackPressed()
|
||||
return Platform::AceContainer::OnBackPressed(instanceId_);
|
||||
}
|
||||
|
||||
bool UIContentImpl::ProcessTouchEvent(const OHOS::TouchEvent& touchEvent)
|
||||
{
|
||||
LOGI("UIContent ProcessTouchEvent");
|
||||
auto container = Platform::AceContainer::GetContainer(instanceId_);
|
||||
if (container) {
|
||||
auto aceView = static_cast<Platform::FlutterAceView*>(container->GetAceView());
|
||||
return Platform::FlutterAceView::DispatchTouchEvent(aceView, touchEvent);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UIContentImpl::ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
LOGI("UIContent ProcessPointerEvent");
|
||||
auto container = Platform::AceContainer::GetContainer(instanceId_);
|
||||
if (container) {
|
||||
auto aceView = static_cast<Platform::FlutterAceView*>(container->GetAceView());
|
||||
Platform::FlutterAceView::DispatchTouchEvent(aceView, pointerEvent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,14 +53,10 @@ public:
|
||||
bool ProcessVsyncEvent(uint64_t timeStampNanos) override;
|
||||
void UpdateViewportConfig(const ViewportConfig& config) override;
|
||||
|
||||
// interface for test
|
||||
bool ProcessTouchEvent(const OHOS::TouchEvent& touchEvent);
|
||||
void Initialize(OHOS::Window* window, const std::string& url, NativeValue* storage);
|
||||
|
||||
private:
|
||||
OHOS::AbilityRuntime::Context* context_ = nullptr;
|
||||
void* runtime_ = nullptr;
|
||||
OHOS::Window* window_ = nullptr;
|
||||
OHOS::Rosen::Window* window_ = nullptr;
|
||||
ViewportConfig config_;
|
||||
std::string startUrl_;
|
||||
int32_t instanceId_ = -1;
|
||||
|
||||
@@ -73,7 +73,7 @@ bool SystemProperties::accessibilityEnabled_ = IsAccessibilityEnabled();
|
||||
bool SystemProperties::isRound_ = false;
|
||||
int32_t SystemProperties::deviceWidth_ = 0;
|
||||
int32_t SystemProperties::deviceHeight_ = 0;
|
||||
double SystemProperties::resolution_ = 2.0;
|
||||
double SystemProperties::resolution_ = 1.5; // 1.5 for WGR
|
||||
DeviceType SystemProperties::deviceType_ { DeviceType::UNKNOWN };
|
||||
DeviceOrientation SystemProperties::orientation_ { DeviceOrientation::PORTRAIT };
|
||||
std::string SystemProperties::brand_ = INVALID_PARAM;
|
||||
|
||||
@@ -434,7 +434,7 @@ template("flutter_engine_shell") {
|
||||
}
|
||||
deps += [
|
||||
"//foundation/graphic/standard:libvsync_client",
|
||||
"//foundation/graphic/standard:libwmclient",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
]
|
||||
external_deps = [
|
||||
"appexecfwk_standard:libeventhandler",
|
||||
|
||||
@@ -3245,4 +3245,13 @@ bool PipelineContext::SendEventByKey(const std::string& key, int action, const s
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::shared_ptr<OHOS::Rosen::RSUIDirector>& PipelineContext::GetRSUIDirector()
|
||||
{
|
||||
#ifdef ENABLE_ROSEN_BACKEND
|
||||
return rsUIDirector_;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace OHOS::Ace
|
||||
|
||||
@@ -949,6 +949,8 @@ public:
|
||||
|
||||
bool SendEventByKey(const std::string& key, int action, const std::string& params);
|
||||
|
||||
const std::shared_ptr<OHOS::Rosen::RSUIDirector>& GetRSUIDirector();
|
||||
|
||||
private:
|
||||
void FlushPipelineWithoutAnimation();
|
||||
void FlushLayout();
|
||||
|
||||
Reference in New Issue
Block a user