From bdc02199f835c1786f6eed8d5919d05d93fa36c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E6=B8=85=E4=BA=91?= Date: Tue, 22 Oct 2024 21:27:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BC=A0=E6=A0=87=E6=A0=B7=E5=BC=8FDFX?= =?UTF-8?q?=EF=BC=9AChangeMouseStyle=E5=A2=9E=E5=8A=A0=E7=BB=B4=E6=8C=81?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡清云 --- adapter/ohos/osal/mouse_style_ohos.cpp | 16 +++++++++++----- frameworks/core/pipeline_ng/pipeline_context.cpp | 13 ++++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/adapter/ohos/osal/mouse_style_ohos.cpp b/adapter/ohos/osal/mouse_style_ohos.cpp index 5eec1ceaff8..8011b8b131c 100644 --- a/adapter/ohos/osal/mouse_style_ohos.cpp +++ b/adapter/ohos/osal/mouse_style_ohos.cpp @@ -30,10 +30,16 @@ RefPtr MouseStyle::CreateMouseStyle() bool MouseStyleOhos::SetPointerStyle(int32_t windowId, MouseFormat pointerStyle) const { auto container = Container::Current(); - CHECK_NULL_RETURN(container, false); + if (!container) { + TAG_LOGW(AceLogTag::ACE_MOUSE, "SetPointerStyle container is null!"); + return false; + } auto isUIExtension = container->IsUIExtensionWindow() && pointerStyle != MouseFormat::DEFAULT; auto inputManager = MMI::InputManager::GetInstance(); - CHECK_NULL_RETURN(inputManager, false); + if (!inputManager) { + TAG_LOGW(AceLogTag::ACE_MOUSE, "SetPointerStyle inputManager is null!"); + return false; + } static const LinearEnumMapNode mouseFormatMap[] = { { MouseFormat::DEFAULT, MMI::DEFAULT }, { MouseFormat::EAST, MMI::EAST }, @@ -91,7 +97,7 @@ bool MouseStyleOhos::SetPointerStyle(int32_t windowId, MouseFormat pointerStyle) windowId, static_cast(pointerStyle), isUIExtension); int32_t setResult = inputManager->SetPointerStyle(windowId, style, isUIExtension); if (setResult == -1) { - LOGW("SetPointerStyle result is false"); + TAG_LOGW(AceLogTag::ACE_MOUSE, "SetPointerStyle result is false"); return false; } return true; @@ -107,7 +113,7 @@ int32_t MouseStyleOhos::GetPointerStyle(int32_t windowId, int32_t& pointerStyle) MMI::PointerStyle style; int32_t getResult = inputManager->GetPointerStyle(windowId, style, isUIExtension); if (getResult == -1) { - LOGW("GetPointerStyle result is false"); + TAG_LOGW(AceLogTag::ACE_MOUSE, "GetPointerStyle result is false"); return -1; } pointerStyle = style.id; @@ -118,7 +124,7 @@ bool MouseStyleOhos::ChangePointerStyle(int32_t windowId, MouseFormat mouseForma { int32_t curPointerStyle = -1; if (GetPointerStyle(windowId, curPointerStyle) == -1) { - LOGW("ChangePointerStyle: GetPointerStyle return failed"); + TAG_LOGW(AceLogTag::ACE_MOUSE, "ChangePointerStyle: GetPointerStyle return failed"); return false; } if (curPointerStyle == static_cast(mouseFormat)) { diff --git a/frameworks/core/pipeline_ng/pipeline_context.cpp b/frameworks/core/pipeline_ng/pipeline_context.cpp index ab1b0d1ae92..73fc6b794ca 100644 --- a/frameworks/core/pipeline_ng/pipeline_context.cpp +++ b/frameworks/core/pipeline_ng/pipeline_context.cpp @@ -3632,15 +3632,24 @@ void PipelineContext::DispatchMouseEvent( bool PipelineContext::ChangeMouseStyle(int32_t nodeId, MouseFormat format, int32_t windowId, bool isByPass) { + if (static_cast(format) == 0) { + TAG_LOGI(AceLogTag::ACE_MOUSE, "ChangeMouseStyle nodeId=%{public}d style=%{public}d windowId=%{public}d " + "isByPass=%{public}d mouseStyleNodeId_=%{public}d", + nodeId, static_cast(format), windowId, isByPass, mouseStyleNodeId_.value_or(-1)); + } auto window = GetWindow(); if (window && window->IsUserSetCursor()) { + TAG_LOGD(AceLogTag::ACE_MOUSE, "ChangeMouseStyle UserSetCursor"); return false; } if (!mouseStyleNodeId_.has_value() || mouseStyleNodeId_.value() != nodeId || isByPass) { return false; } auto mouseStyle = MouseStyle::CreateMouseStyle(); - CHECK_NULL_RETURN(mouseStyle, false); + if (!mouseStyle) { + TAG_LOGW(AceLogTag::ACE_MOUSE, "ChangeMouseStyle mouseStyle is null"); + return false; + } if (windowId) { return mouseStyle->ChangePointerStyle(windowId, format); } @@ -4853,6 +4862,7 @@ void PipelineContext::SetCursor(int32_t cursorValue) auto mouseStyle = MouseStyle::CreateMouseStyle(); CHECK_NULL_VOID(mouseStyle); auto cursor = static_cast(cursorValue); + TAG_LOGI(AceLogTag::ACE_MOUSE, "user SetCursor mouseStyle=%{public}d", cursorValue); window->SetCursor(cursor); window->SetUserSetCursor(true); mouseStyle->ChangePointerStyle(GetFocusWindowId(), cursor); @@ -4867,6 +4877,7 @@ void PipelineContext::RestoreDefault(int32_t windowId) CHECK_NULL_VOID(mouseStyle); window->SetCursor(MouseFormat::DEFAULT); window->SetUserSetCursor(false); + TAG_LOGI(AceLogTag::ACE_MOUSE, "RestoreDefault param windowId=%{public}d", windowId); mouseStyle->ChangePointerStyle(windowId > 0 ? windowId : GetFocusWindowId(), MouseFormat::DEFAULT); }