From: xue <2144439972@qq.com> Date: Thu, 5 Feb 2026 03:38:23 +0000 (+0800) Subject: 修复系统界面息屏失焦,表冠失效 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=db6bacfde3f1972dedaec659bbbddbe8c5220924;p=mirrors%2FFD230.git 修复系统界面息屏失焦,表冠失效 --- diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/include/SystemView.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/include/SystemView.h index d6eb50d8d..77a12d7de 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/include/SystemView.h @@ -94,6 +94,8 @@ namespace OHOS bool CheckViewParam(int16_t hideView, int16_t showView); void ChangeView(int16_t hideView, int16_t showView); UIScrollView *GetSystemScrollView(int ViewId); + /** 息屏再亮屏后表冠失效时,为当前显示的滚动视图重新申请焦点(含系统主界面、关于手表等所有 subview) */ + void RequestFocusForCurrentView(); private: SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr}; // 关于手表 @@ -121,6 +123,7 @@ namespace OHOS UIImageView *NeedToUpdateImage{nullptr}; // 提示需要系统更新的icon图片 UIImageView *temp{nullptr}; bool viewInitStatus{false}; + int16_t currentShowViewId_{SYSTEMVIEW}; // 当前显示的 subview,息屏亮屏后用于恢复表冠焦点 }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemPresenter.cpp index 1bf344a1a..c1c990eaf 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemPresenter.cpp @@ -52,6 +52,10 @@ namespace OHOS void SystemPresenter::OnResume() { RootView::GetInstance()->SetOnKeyActListener(this); + SystemView *p_SystemView = SystemView::GetInstance(); + if (p_SystemView != nullptr) { + p_SystemView->RequestFocusForCurrentView(); + } } static uint32_t time = 0; diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemView.cpp index 7275990c0..5f26afa78 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/system/src/SystemView.cpp @@ -353,12 +353,22 @@ namespace OHOS { NeedToUpdateImageinit(); } + currentShowViewId_ = SYSTEMVIEW; AddViewToRootContainer(SystemScrollView[SYSTEMVIEW]); } - + void SystemView::RequestFocusForCurrentView() + { + // 系统主界面、关于手表等任意当前 subview 息屏亮屏后恢复表冠焦点 + if (currentShowViewId_ >= 0 && currentShowViewId_ < MAX_SYSTEMVIEWID && + SystemScrollView[currentShowViewId_] != nullptr) { + SystemScrollView[currentShowViewId_]->RequestFocus(); + } + } + + // 0.跳转到系统视图,其他视图都市通过这个视图跳转 bool SystemView::ChangeToSystemView(int16_t thisView) { @@ -542,6 +552,10 @@ namespace OHOS SystemScrollView[hideView]->SetVisible(false); ClickFunc(showView); SystemScrollView[showView]->SetVisible(true); + currentShowViewId_ = showView; + if (SystemScrollView[showView] != nullptr) { + SystemScrollView[showView]->RequestFocus(); + } Draw(); }