鼠标样式DFX:ChangeMouseStyle增加维持日志

Signed-off-by: 胡清云 <huqingyun1@huawei.com>
This commit is contained in:
胡清云 2024-10-22 21:27:59 +08:00
parent d7197ddaf4
commit bdc02199f8
2 changed files with 23 additions and 6 deletions

View File

@ -30,10 +30,16 @@ RefPtr<MouseStyle> 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<MouseFormat, int32_t> mouseFormatMap[] = {
{ MouseFormat::DEFAULT, MMI::DEFAULT },
{ MouseFormat::EAST, MMI::EAST },
@ -91,7 +97,7 @@ bool MouseStyleOhos::SetPointerStyle(int32_t windowId, MouseFormat pointerStyle)
windowId, static_cast<int32_t>(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<int32_t>(mouseFormat)) {

View File

@ -3632,15 +3632,24 @@ void PipelineContext::DispatchMouseEvent(
bool PipelineContext::ChangeMouseStyle(int32_t nodeId, MouseFormat format, int32_t windowId, bool isByPass)
{
if (static_cast<int32_t>(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<int32_t>(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<MouseFormat>(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);
}