1 /*
2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "window_impl.h"
17
18 #include <unordered_set>
19
20 #include "dm_common.h"
21 #include "window_manager_hilog.h"
22 #include "window_helper.h"
23 #include "window_option.h"
24 #include "viewport_config.h"
25 #include "singleton_container.h"
26
27 namespace OHOS {
28 namespace Rosen {
29 namespace {
30 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowImpl"};
31 constexpr uint32_t API_VERSION_MOD = 1000;
32 constexpr int32_t API_VERSION_18 = 18;
33 }
34 std::map<std::string, std::pair<uint32_t, sptr<Window>>> WindowImpl::windowMap_;
35 std::map<uint32_t, std::vector<sptr<WindowImpl>>> WindowImpl::subWindowMap_;
36 std::map<uint32_t, std::vector<sptr<IWindowSystemBarEnableListener>>> WindowImpl::systemBarEnableListeners_;
37 std::map<uint32_t, std::vector<sptr<IIgnoreViewSafeAreaListener>>> WindowImpl::ignoreSafeAreaListeners_;
38 std::map<uint32_t, std::vector<sptr<IAvoidAreaChangedListener>>> WindowImpl::avoidAreaChangeListeners_;
39 std::mutex WindowImpl::globalMutex_;
40 static int constructorCnt = 0;
41 static int deConstructorCnt = 0;
WindowImpl(const sptr<WindowOption> & option)42 WindowImpl::WindowImpl(const sptr<WindowOption>& option)
43 {
44 if (option != nullptr) {
45 name_ = option->GetWindowName();
46 } else {
47 name_ = "main_window";
48 }
49 WLOGFI("WindowImpl constructorCnt: %{public}d",
50 ++constructorCnt);
51 }
52
~WindowImpl()53 WindowImpl::~WindowImpl()
54 {
55 WLOGFI("windowName: %{public}s, windowId: %{public}d, deConstructorCnt: %{public}d",
56 GetWindowName().c_str(), GetWindowId(), ++deConstructorCnt);
57 Destroy();
58 }
59
CreateSurfaceNode(const std::string name,const SendRenderDataCallback & callback)60 void WindowImpl::CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback)
61 {
62 WLOGFI("CreateSurfaceNode");
63 struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
64 rsSurfaceNodeConfig.SurfaceNodeName = name;
65 rsSurfaceNodeConfig.additionalData = reinterpret_cast<void*>(callback);
66 surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig);
67 if (surfaceNode_ != nullptr) {
68 vsyncStation_ = std::make_shared<VsyncStation>(surfaceNode_->GetId());
69 }
70 }
71
SetContentInfoCallback(const ContentInfoCallback & callback)72 void WindowImpl::SetContentInfoCallback(const ContentInfoCallback& callback)
73 {
74 contentInfoCallback_ = callback;
75 }
76
Find(const std::string & name)77 sptr<Window> WindowImpl::Find(const std::string& name)
78 {
79 return nullptr;
80 }
81
GetContext() const82 const std::shared_ptr<AbilityRuntime::Context> WindowImpl::GetContext() const
83 {
84 return context_;
85 }
86
FindWindowById(uint32_t windowId)87 sptr<Window> WindowImpl::FindWindowById(uint32_t windowId)
88 {
89 std::lock_guard<std::mutex> lock(globalMutex_);
90 if (windowMap_.empty()) {
91 WLOGFE("Please create mainWindow First!");
92 return nullptr;
93 }
94 for (auto iter = windowMap_.begin(); iter != windowMap_.end(); iter++) {
95 if (windowId == iter->second.first) {
96 WLOGI("FindWindow id: %{public}u", windowId);
97 return iter->second.second;
98 }
99 }
100 WLOGFE("Cannot find Window!");
101 return nullptr;
102 }
103
GetTopWindowWithId(uint32_t mainWinId)104 sptr<Window> WindowImpl::GetTopWindowWithId(uint32_t mainWinId)
105 {
106 return FindWindowById(mainWinId);
107 }
108
GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context> & context)109 sptr<Window> WindowImpl::GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context>& context)
110 {
111 return nullptr;
112 }
113
GetSubWindow(uint32_t parentId)114 std::vector<sptr<Window>> WindowImpl::GetSubWindow(uint32_t parentId)
115 {
116 return std::vector<sptr<Window>>();
117 }
118
UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration> & configuration,const std::vector<std::shared_ptr<AbilityRuntime::Context>> & ignoreWindowContexts)119 void WindowImpl::UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration,
120 const std::vector<std::shared_ptr<AbilityRuntime::Context>>& ignoreWindowContexts)
121 {
122 std::unordered_set<std::shared_ptr<AbilityRuntime::Context>> ignoreWindowCtxSet(
123 ignoreWindowContexts.begin(), ignoreWindowContexts.end());
124 std::lock_guard<std::mutex> lock(globalMutex_);
125 for (const auto& winPair : windowMap_) {
126 auto window = winPair.second.second;
127 if (window == nullptr) {
128 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "window is null");
129 continue;
130 }
131 auto context = window->GetContext();
132 if (context == nullptr) {
133 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "context is null, winId: %{public}u", window->GetWindowId());
134 continue;
135 }
136 if (ignoreWindowCtxSet.count(context) == 0) {
137 window->UpdateConfiguration(configuration);
138 }
139 }
140 }
141
UpdateConfigurationSync(const std::shared_ptr<AppExecFwk::Configuration> & configuration)142 void WindowImpl::UpdateConfigurationSync(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
143 {
144 if (uiContent_ == nullptr) {
145 TLOGE(WmsLogTag::WMS_IMMS, "uiContent is null, winId: %{public}d", GetWindowId());
146 return;
147 }
148 TLOGI(WmsLogTag::WMS_IMMS, "winId: %{public}d", GetWindowId());
149 uiContent_->UpdateConfigurationSyncForAll(configuration);
150 }
151
UpdateConfigurationSyncForAll(const std::shared_ptr<AppExecFwk::Configuration> & configuration)152 void WindowImpl::UpdateConfigurationSyncForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
153 {
154 std::lock_guard<std::mutex> lock(globalMutex_);
155 for (const auto& winPair : windowMap_) {
156 if (auto window = winPair.second.second) {
157 window->UpdateConfigurationSync(configuration);
158 }
159 }
160 }
161
GetSurfaceNode() const162 std::shared_ptr<RSSurfaceNode> WindowImpl::GetSurfaceNode() const
163 {
164 return surfaceNode_;
165 }
166
GetRect() const167 Rect WindowImpl::GetRect() const
168 {
169 return Rect{0, 0, 0, 0};
170 }
171
GetRequestRect() const172 Rect WindowImpl::GetRequestRect() const
173 {
174 return Rect{0, 0, 0, 0};
175 }
176
GetType() const177 WindowType WindowImpl::GetType() const
178 {
179 return WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
180 }
181
GetWindowMode() const182 WindowMode WindowImpl::GetWindowMode() const
183 {
184 return windowMode_;
185 }
186
GetAlpha() const187 float WindowImpl::GetAlpha() const
188 {
189 return 0.0;
190 }
191
GetWindowState() const192 WindowState WindowImpl::GetWindowState() const
193 {
194 return state_;
195 }
196
SetFocusable(bool isFocusable)197 WMError WindowImpl::SetFocusable(bool isFocusable)
198 {
199 return WMError::WM_OK;
200 }
201
GetFocusable() const202 bool WindowImpl::GetFocusable() const
203 {
204 return false;
205 }
206
SetTouchable(bool isTouchable)207 WMError WindowImpl::SetTouchable(bool isTouchable)
208 {
209 return WMError::WM_OK;
210 }
211
GetTouchable() const212 bool WindowImpl::GetTouchable() const
213 {
214 return false;
215 }
216
GetWindowName() const217 const std::string& WindowImpl::GetWindowName() const
218 {
219 return name_;
220 }
221
GetWindowId() const222 uint32_t WindowImpl::GetWindowId() const
223 {
224 return windowId_;
225 }
226
GetDisplayId() const227 uint64_t WindowImpl::GetDisplayId() const
228 {
229 return DISPLAY_ID_INVALID;
230 }
231
GetWindowFlags() const232 uint32_t WindowImpl::GetWindowFlags() const
233 {
234 return 0;
235 }
236
GetRequestWindowModeSupportType() const237 uint32_t WindowImpl::GetRequestWindowModeSupportType() const
238 {
239 return 0;
240 }
241
IsMainHandlerAvailable() const242 bool WindowImpl::IsMainHandlerAvailable() const
243 {
244 return true;
245 }
246
GetSystemBarPropertyByType(WindowType type) const247 SystemBarProperty WindowImpl::GetSystemBarPropertyByType(WindowType type) const
248 {
249 std::lock_guard<std::mutex> lock(mutex_);
250 auto it = sysBarPropMap_.find(type);
251 if (it == sysBarPropMap_.end()) {
252 return SystemBarProperty(false, 0x0, 0x0);
253 }
254 return it->second;
255 }
256
GetAvoidAreaByType(AvoidAreaType type,AvoidArea & avoidArea)257 WMError WindowImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea)
258 {
259 std::lock_guard<std::mutex> lock(mutex_);
260 auto avoidAreaPtr = avoidAreaMap_[type];
261 if (avoidAreaPtr == nullptr) {
262 return WMError::WM_OK;
263 }
264
265 avoidArea = *avoidAreaPtr;
266 return WMError::WM_OK;
267 }
268
SetWindowType(WindowType type)269 WMError WindowImpl::SetWindowType(WindowType type)
270 {
271 return WMError::WM_OK;
272 }
273
SetWindowMode(WindowMode mode)274 WMError WindowImpl::SetWindowMode(WindowMode mode)
275 {
276 windowMode_ = mode;
277 return WMError::WM_OK;
278 }
279
SetAlpha(float alpha)280 WMError WindowImpl::SetAlpha(float alpha)
281 {
282 return WMError::WM_OK;
283 }
284
SetTransform(const Transform & trans)285 WMError WindowImpl::SetTransform(const Transform& trans)
286 {
287 return WMError::WM_OK;
288 }
289
GetTransform() const290 const Transform& WindowImpl::GetTransform() const
291 {
292 return transform_;
293 }
294
AddWindowFlag(WindowFlag flag)295 WMError WindowImpl::AddWindowFlag(WindowFlag flag)
296 {
297 return WMError::WM_OK;
298 }
299
RemoveWindowFlag(WindowFlag flag)300 WMError WindowImpl::RemoveWindowFlag(WindowFlag flag)
301 {
302 return WMError::WM_OK;
303 }
304
SetWindowFlags(uint32_t flags)305 WMError WindowImpl::SetWindowFlags(uint32_t flags)
306 {
307 return WMError::WM_OK;
308 }
309
OnNewWant(const AAFwk::Want & want)310 void WindowImpl::OnNewWant(const AAFwk::Want& want)
311 {
312 return;
313 }
314
SetUIContentByName(const std::string & contentInfo,napi_env env,napi_value storage,AppExecFwk::Ability * ability)315 WMError WindowImpl::SetUIContentByName(
316 const std::string& contentInfo, napi_env env, napi_value storage, AppExecFwk::Ability* ability)
317 {
318 TLOGD(WmsLogTag::WMS_LIFE, "contentInfo: %{public}s", contentInfo.c_str());
319 if (uiContent_) {
320 uiContent_->Destroy();
321 }
322 std::unique_ptr<Ace::UIContent> uiContent;
323 if (ability != nullptr) {
324 uiContent = Ace::UIContent::Create(ability);
325 } else {
326 uiContent = Ace::UIContent::Create(context_.get(), reinterpret_cast<NativeEngine*>(env));
327 }
328 if (uiContent == nullptr) {
329 TLOGE(WmsLogTag::WMS_LIFE, "fail to SetUIContentByName");
330 return WMError::WM_ERROR_NULLPTR;
331 }
332 uiContent->InitializeByName(this, contentInfo, storage);
333 uiContent_ = std::move(uiContent);
334 NotifySetIgnoreSafeArea(isIgnoreSafeArea_);
335 UpdateViewportConfig();
336 if (contentInfoCallback_) {
337 contentInfoCallback_(contentInfo);
338 }
339 return WMError::WM_OK;
340 }
341
NapiSetUIContent(const std::string & contentInfo,napi_env env,napi_value storage,BackupAndRestoreType type,sptr<IRemoteObject> token,AppExecFwk::Ability * ability)342 WMError WindowImpl::NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage,
343 BackupAndRestoreType type, sptr<IRemoteObject> token, AppExecFwk::Ability* ability)
344 {
345 WLOGFD("NapiSetUIContent: %{public}s", contentInfo.c_str());
346 if (uiContent_) {
347 uiContent_->Destroy();
348 }
349 std::unique_ptr<Ace::UIContent> uiContent;
350 if (ability != nullptr) {
351 uiContent = Ace::UIContent::Create(ability);
352 } else {
353 uiContent = Ace::UIContent::Create(context_.get(), reinterpret_cast<NativeEngine*>(env));
354 }
355 if (uiContent == nullptr) {
356 WLOGFE("fail to NapiSetUIContent");
357 return WMError::WM_ERROR_NULLPTR;
358 }
359 if (type != BackupAndRestoreType::NONE) {
360 uiContent->Restore(this, contentInfo, storage, type == BackupAndRestoreType::CONTINUATION ?
361 Ace::ContentInfoType::CONTINUATION : Ace::ContentInfoType::APP_RECOVERY);
362 } else {
363 uiContent->Initialize(this, contentInfo, storage);
364 }
365 uiContent_ = std::move(uiContent);
366 if (uiContent_ == nullptr) {
367 WLOGFE("uiContent_ is NULL");
368 return WMError::WM_ERROR_NULLPTR;
369 }
370 NotifySetIgnoreSafeArea(isIgnoreSafeArea_);
371 UpdateViewportConfig();
372 if (contentInfoCallback_) {
373 contentInfoCallback_(contentInfo);
374 }
375 return WMError::WM_OK;
376 }
377
378
GetUIContent() const379 Ace::UIContent* WindowImpl::GetUIContent() const
380 {
381 WLOGFD("WindowImpl::GetUIContent");
382 return uiContent_.get();
383 }
384
GetContentInfo(BackupAndRestoreType type)385 std::string WindowImpl::GetContentInfo(BackupAndRestoreType type)
386 {
387 return "";
388 }
389
IsSupportWideGamut()390 bool WindowImpl::IsSupportWideGamut()
391 {
392 return true;
393 }
394
SetColorSpace(ColorSpace colorSpace)395 void WindowImpl::SetColorSpace(ColorSpace colorSpace)
396 {
397 return;
398 }
399
GetColorSpace()400 ColorSpace WindowImpl::GetColorSpace()
401 {
402 return ColorSpace::COLOR_SPACE_DEFAULT;
403 }
404
Snapshot()405 std::shared_ptr<Media::PixelMap> WindowImpl::Snapshot()
406 {
407 return nullptr;
408 }
409
SnapshotIgnorePrivacy(std::shared_ptr<Media::PixelMap> & pixelMap)410 WMError WindowImpl::SnapshotIgnorePrivacy(std::shared_ptr<Media::PixelMap>& pixelMap)
411 {
412 return WMError::WM_OK;
413 }
414
DumpInfo(const std::vector<std::string> & params,std::vector<std::string> & info)415 void WindowImpl::DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
416 {
417 return;
418 }
419
SetSystemBarProperty(WindowType type,const SystemBarProperty & property)420 WMError WindowImpl::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
421 {
422 return SetSpecificBarProperty(type, property);
423 }
424
SetSpecificBarProperty(WindowType type,const SystemBarProperty & property)425 WMError WindowImpl::SetSpecificBarProperty(WindowType type, const SystemBarProperty& property)
426 {
427 WLOGI("Window %{public}u type %{public}u enable:%{public}u, bgColor:%{public}x, Color:%{public}x",
428 GetWindowId(), static_cast<uint32_t>(type), property.enable_,
429 property.backgroundColor_, property.contentColor_);
430
431 if (GetSystemBarPropertyByType(type) == property) {
432 return WMError::WM_OK;
433 }
434 {
435 std::lock_guard<std::mutex> lock(mutex_);
436 sysBarPropMap_[type] = property;
437 }
438 NotifySystemBarChange(type, property);
439 UpdateViewportConfig();
440 return WMError::WM_OK;
441 }
442
UpdateSystemBarProperty(bool status)443 WMError WindowImpl::UpdateSystemBarProperty(bool status)
444 {
445 bool enable = !status;
446 SystemBarProperty statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR);
447 if (statusProperty.enable_ != enable) {
448 statusProperty.enable_ = enable;
449 SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, statusProperty);
450 }
451
452 SystemBarProperty naviProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR);
453 if (naviProperty.enable_ != enable) {
454 naviProperty.enable_ = enable;
455 SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_BAR, naviProperty);
456 }
457
458 SystemBarProperty naviIndicatorProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR);
459 if (naviIndicatorProperty.enable_ != enable) {
460 naviIndicatorProperty.enable_ = enable;
461 SetSystemBarProperty(WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, naviIndicatorProperty);
462 }
463
464 return WMError::WM_OK;
465 }
466
SetSystemBarProperties(const std::map<WindowType,SystemBarProperty> & properties,const std::map<WindowType,SystemBarPropertyFlag> & propertyFlags)467 WMError WindowImpl::SetSystemBarProperties(const std::map<WindowType, SystemBarProperty>& properties,
468 const std::map<WindowType, SystemBarPropertyFlag>& propertyFlags)
469 {
470 return WMError::WM_OK;
471 }
472
GetSystemBarProperties(std::map<WindowType,SystemBarProperty> & properties)473 WMError WindowImpl::GetSystemBarProperties(std::map<WindowType, SystemBarProperty>& properties)
474 {
475 return WMError::WM_OK;
476 }
477
UpdateSpecificSystemBarEnabled(bool systemBarEnable,bool systemBarEnableAnimation,SystemBarProperty & property)478 void WindowImpl::UpdateSpecificSystemBarEnabled(bool systemBarEnable, bool systemBarEnableAnimation,
479 SystemBarProperty& property)
480 {
481 property.enable_ = systemBarEnable;
482 property.enableAnimation_ = systemBarEnableAnimation;
483 // isolate on api 18
484 if (GetApiTargetVersion() >= API_VERSION_18) {
485 property.settingFlag_ |= SystemBarSettingFlag::ENABLE_SETTING;
486 }
487 }
488
SetLayoutFullScreen(bool status)489 WMError WindowImpl::SetLayoutFullScreen(bool status)
490 {
491 isIgnoreSafeArea_ = status;
492 NotifySetIgnoreSafeArea(status);
493 UpdateViewportConfig();
494 return WMError::WM_OK;
495 }
496
SetFullScreen(bool status)497 WMError WindowImpl::SetFullScreen(bool status)
498 {
499 WLOGI("status: %{public}d", status);
500 WMError ret = UpdateSystemBarProperty(status);
501 if (ret != WMError::WM_OK) {
502 WLOGFE("UpdateSystemBarProperty errCode:%{public}d", static_cast<int32_t>(ret));
503 }
504 ret = SetLayoutFullScreen(status);
505 if (ret != WMError::WM_OK) {
506 WLOGFE("SetLayoutFullScreen errCode:%{public}d", static_cast<int32_t>(ret));
507 }
508 return WMError::WM_OK;
509 }
510
Create(uint32_t parentId,const std::shared_ptr<AbilityRuntime::Context> & context)511 WMError WindowImpl::Create(uint32_t parentId, const std::shared_ptr<AbilityRuntime::Context>& context)
512 {
513 WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str());
514 context_ = context;
515 sptr<Window> self(this);
516 static std::atomic<uint32_t> tempWindowId = 0;
517 uint32_t windowId = tempWindowId++; // for test
518 windowId_ = windowId;
519 std::lock_guard<std::mutex> lock(globalMutex_);
520 windowMap_.insert(std::make_pair(name_, std::pair<uint32_t, sptr<Window>>(windowId, self)));
521 return WMError::WM_OK;
522 }
523
BindDialogTarget(sptr<IRemoteObject> targetToken)524 WMError WindowImpl::BindDialogTarget(sptr<IRemoteObject> targetToken)
525 {
526 return WMError::WM_OK;
527 }
528
SetDialogBackGestureEnabled(bool isEnabled)529 WMError WindowImpl::SetDialogBackGestureEnabled(bool isEnabled)
530 {
531 return WMError::WM_OK;
532 }
533
Destroy()534 WMError WindowImpl::Destroy()
535 {
536 if (uiContent_) {
537 uiContent_->Destroy();
538 }
539 std::lock_guard<std::mutex> lock(globalMutex_);
540 windowMap_.erase(GetWindowName());
541 return WMError::WM_OK;
542 }
543
UpdateSurfaceNodeAfterCustomAnimation(bool isAdd)544 WMError WindowImpl::UpdateSurfaceNodeAfterCustomAnimation(bool isAdd)
545 {
546 return WMError::WM_OK;
547 }
548
Show(uint32_t reason,bool withAnimation,bool withFocus)549 WMError WindowImpl::Show(uint32_t reason, bool withAnimation, bool withFocus)
550 {
551 return WMError::WM_OK;
552 }
553
Hide(uint32_t reason,bool withAnimation,bool isFromInnerkits)554 WMError WindowImpl::Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits)
555 {
556 return WMError::WM_OK;
557 }
558
MoveTo(int32_t x,int32_t y,bool isMoveToGlobal,MoveConfiguration moveConfiguration)559 WMError WindowImpl::MoveTo(int32_t x, int32_t y, bool isMoveToGlobal, MoveConfiguration moveConfiguration)
560 {
561 return WMError::WM_OK;
562 }
563
Resize(uint32_t width,uint32_t height,const RectAnimationConfig & rectAnimationConfig)564 WMError WindowImpl::Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig)
565 {
566 return WMError::WM_OK;
567 }
568
SetWindowGravity(WindowGravity gravity,uint32_t percent)569 WMError WindowImpl::SetWindowGravity(WindowGravity gravity, uint32_t percent)
570 {
571 return WMError::WM_OK;
572 }
573
SetKeepScreenOn(bool keepScreenOn)574 WMError WindowImpl::SetKeepScreenOn(bool keepScreenOn)
575 {
576 return WMError::WM_OK;
577 }
578
IsKeepScreenOn() const579 bool WindowImpl::IsKeepScreenOn() const
580 {
581 return false;
582 }
583
SetTurnScreenOn(bool turnScreenOn)584 WMError WindowImpl::SetTurnScreenOn(bool turnScreenOn)
585 {
586 return WMError::WM_OK;
587 }
588
IsTurnScreenOn() const589 bool WindowImpl::IsTurnScreenOn() const
590 {
591 return false;
592 }
593
SetBackgroundColor(const std::string & color)594 WMError WindowImpl::SetBackgroundColor(const std::string& color)
595 {
596 return WMError::WM_OK;
597 }
598
SetTransparent(bool isTransparent)599 WMError WindowImpl::SetTransparent(bool isTransparent)
600 {
601 return WMError::WM_OK;
602 }
603
IsTransparent() const604 bool WindowImpl::IsTransparent() const
605 {
606 return true;
607 }
608
SetBrightness(float brightness)609 WMError WindowImpl::SetBrightness(float brightness)
610 {
611 return WMError::WM_OK;
612 }
613
GetBrightness() const614 float WindowImpl::GetBrightness() const
615 {
616 return 0.0;
617 }
618
SetCallingWindow(uint32_t windowId)619 WMError WindowImpl::SetCallingWindow(uint32_t windowId)
620 {
621 return WMError::WM_OK;
622 }
623
SetPrivacyMode(bool isPrivacyMode)624 WMError WindowImpl::SetPrivacyMode(bool isPrivacyMode)
625 {
626 return WMError::WM_OK;
627 }
628
IsPrivacyMode() const629 bool WindowImpl::IsPrivacyMode() const
630 {
631 return false;
632 }
633
SetSystemPrivacyMode(bool isSystemPrivacyMode)634 void WindowImpl::SetSystemPrivacyMode(bool isSystemPrivacyMode)
635 {
636 }
637
SetSnapshotSkip(bool isSkip)638 WMError WindowImpl::SetSnapshotSkip(bool isSkip)
639 {
640 return WMError::WM_OK;
641 }
642
DisableAppWindowDecor()643 WMError WindowImpl::DisableAppWindowDecor()
644 {
645 return WMError::WM_OK;
646 }
647
Maximize()648 WMError WindowImpl::Maximize()
649 {
650 return WMError::WM_OK;
651 }
652
Minimize()653 WMError WindowImpl::Minimize()
654 {
655 return WMError::WM_OK;
656 }
657
Recover()658 WMError WindowImpl::Recover()
659 {
660 return WMError::WM_OK;
661 }
662
Close()663 WMError WindowImpl::Close()
664 {
665 return WMError::WM_OK;
666 }
667
StartMove()668 void WindowImpl::StartMove()
669 {
670 return;
671 }
672
RequestFocus() const673 WMError WindowImpl::RequestFocus() const
674 {
675 return WMError::WM_OK;
676 }
677
IsFocused() const678 bool WindowImpl::IsFocused() const
679 {
680 return true;
681 }
682
SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer> & inputEventConsumer)683 void WindowImpl::SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer)
684 {
685 return;
686 }
687
RegisterLifeCycleListener(const sptr<IWindowLifeCycle> & listener)688 WMError WindowImpl::RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
689 {
690 return WMError::WM_OK;
691 }
692
RegisterWindowChangeListener(const sptr<IWindowChangeListener> & listener)693 WMError WindowImpl::RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
694 {
695 return WMError::WM_OK;
696 }
697
UnregisterLifeCycleListener(const sptr<IWindowLifeCycle> & listener)698 WMError WindowImpl::UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
699 {
700 return WMError::WM_OK;
701 }
702
UnregisterWindowChangeListener(const sptr<IWindowChangeListener> & listener)703 WMError WindowImpl::UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
704 {
705 return WMError::WM_OK;
706 }
707
RegisterAvoidAreaChangeListener(const sptr<IAvoidAreaChangedListener> & listener)708 WMError WindowImpl::RegisterAvoidAreaChangeListener(const sptr<IAvoidAreaChangedListener>& listener)
709 {
710 WLOGFD("Start register");
711 std::lock_guard<std::mutex> lock(globalMutex_);
712 WMError ret = RegisterListener(avoidAreaChangeListeners_[GetWindowId()], listener);
713 return ret;
714 }
715
UnregisterAvoidAreaChangeListener(const sptr<IAvoidAreaChangedListener> & listener)716 WMError WindowImpl::UnregisterAvoidAreaChangeListener(const sptr<IAvoidAreaChangedListener>& listener)
717 {
718 WLOGFD("Start unregister");
719 std::lock_guard<std::mutex> lock(globalMutex_);
720 WMError ret = UnregisterListener(avoidAreaChangeListeners_[GetWindowId()], listener);
721 return ret;
722 }
723
RegisterDragListener(const sptr<IWindowDragListener> & listener)724 WMError WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
725 {
726 return WMError::WM_OK;
727 }
728
UnregisterDragListener(const sptr<IWindowDragListener> & listener)729 WMError WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
730 {
731 return WMError::WM_OK;
732 }
733
RegisterDisplayMoveListener(sptr<IDisplayMoveListener> & listener)734 WMError WindowImpl::RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
735 {
736 return WMError::WM_OK;
737 }
738
UnregisterDisplayMoveListener(sptr<IDisplayMoveListener> & listener)739 WMError WindowImpl::UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
740 {
741 return WMError::WM_OK;
742 }
743
RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc & func)744 void WindowImpl::RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func)
745 {
746 return;
747 }
748
RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener> & listener)749 WMError WindowImpl::RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
750 {
751 return WMError::WM_OK;
752 }
753
UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener> & listener)754 WMError WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
755 {
756 return WMError::WM_OK;
757 }
758
RegisterTouchOutsideListener(const sptr<ITouchOutsideListener> & listener)759 WMError WindowImpl::RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
760 {
761 return WMError::WM_OK;
762 }
763
UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener> & listener)764 WMError WindowImpl::UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
765 {
766 return WMError::WM_OK;
767 }
768
RegisterAnimationTransitionController(const sptr<IAnimationTransitionController> & listener)769 WMError WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener)
770 {
771 return WMError::WM_OK;
772 }
773
RegisterScreenshotListener(const sptr<IScreenshotListener> & listener)774 WMError WindowImpl::RegisterScreenshotListener(const sptr<IScreenshotListener>& listener)
775 {
776 return WMError::WM_OK;
777 }
778
UnregisterScreenshotListener(const sptr<IScreenshotListener> & listener)779 WMError WindowImpl::UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener)
780 {
781 return WMError::WM_OK;
782 }
783
RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener> & listener)784 WMError WindowImpl::RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
785 {
786 return WMError::WM_OK;
787 }
788
UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener> & listener)789 WMError WindowImpl::UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
790 {
791 return WMError::WM_OK;
792 }
793
RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener> & listener)794 void WindowImpl::RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
795 {
796 return;
797 }
798
UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener> & listener)799 void WindowImpl::UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
800 {
801 return;
802 }
803
RegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener> & listener)804 WMError WindowImpl::RegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener)
805 {
806 WLOGFI("Register");
807 std::lock_guard<std::mutex> lock(globalMutex_);
808 WMError ret = RegisterListener(systemBarEnableListeners_[GetWindowId()], listener);
809 return ret;
810 }
811
UnRegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener> & listener)812 WMError WindowImpl::UnRegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener)
813 {
814 WLOGFI("UnRegister");
815 std::lock_guard<std::mutex> lock(globalMutex_);
816 WMError ret = UnregisterListener(systemBarEnableListeners_[GetWindowId()], listener);
817 return ret;
818 }
819
RegisterIgnoreViewSafeAreaListener(const sptr<IIgnoreViewSafeAreaListener> & listener)820 WMError WindowImpl::RegisterIgnoreViewSafeAreaListener(const sptr<IIgnoreViewSafeAreaListener>& listener)
821 {
822 WLOGFI("Register");
823 std::lock_guard<std::mutex> lock(globalMutex_);
824 WMError ret = RegisterListener(ignoreSafeAreaListeners_[GetWindowId()], listener);
825 return ret;
826 }
827
UnRegisterIgnoreViewSafeAreaListener(const sptr<IIgnoreViewSafeAreaListener> & listener)828 WMError WindowImpl::UnRegisterIgnoreViewSafeAreaListener(const sptr<IIgnoreViewSafeAreaListener>& listener)
829 {
830 WLOGFI("UnRegister");
831 std::lock_guard<std::mutex> lock(globalMutex_);
832 WMError ret = UnregisterListener(ignoreSafeAreaListeners_[GetWindowId()], listener);
833 return ret;
834 }
835
836 template<typename T>
RegisterListener(std::vector<sptr<T>> & holder,const sptr<T> & listener)837 WMError WindowImpl::RegisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener)
838 {
839 if (listener == nullptr) {
840 WLOGFE("listener is nullptr");
841 return WMError::WM_ERROR_NULLPTR;
842 }
843 if (std::find(holder.begin(), holder.end(), listener) != holder.end()) {
844 WLOGFE("Listener already registered");
845 return WMError::WM_OK;
846 }
847 holder.emplace_back(listener);
848 return WMError::WM_OK;
849 }
850
851 template<typename T>
UnregisterListener(std::vector<sptr<T>> & holder,const sptr<T> & listener)852 WMError WindowImpl::UnregisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener)
853 {
854 if (listener == nullptr) {
855 WLOGFE("listener could not be null");
856 return WMError::WM_ERROR_NULLPTR;
857 }
858 holder.erase(std::remove_if(holder.begin(), holder.end(),
859 [listener](sptr<T> registeredListener) {
860 return registeredListener == listener;
861 }), holder.end());
862 return WMError::WM_OK;
863 }
864
SetAceAbilityHandler(const sptr<IAceAbilityHandler> & handler)865 void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
866 {
867 return;
868 }
869
SetRequestWindowModeSupportType(uint32_t windowModeSupportType)870 void WindowImpl::SetRequestWindowModeSupportType(uint32_t windowModeSupportType)
871 {
872 return;
873 }
874
ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent)875 void WindowImpl::ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
876 {
877 if (uiContent_ == nullptr) {
878 WLOGFE("ConsumeKeyEvent to uiContent failed,uiContent_ is null");
879 return;
880 }
881 uiContent_->ProcessKeyEvent(keyEvent);
882 }
883
ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)884 void WindowImpl::ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
885 {
886 if (uiContent_ == nullptr) {
887 WLOGFE("ConsumePointerEvent to uiContent failed,uiContent_ is null");
888 return;
889 }
890 (void)uiContent_->ProcessPointerEvent(pointerEvent);
891 }
892
893
RequestVsync(const std::shared_ptr<VsyncCallback> & vsyncCallback)894 void WindowImpl::RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback)
895 {
896 if (vsyncStation_ == nullptr) {
897 TLOGE(WmsLogTag::WMS_MAIN, "failed, vsyncStation is null");
898 return;
899 }
900 vsyncStation_->RequestVsync(vsyncCallback);
901 }
902
GetVSyncPeriod()903 int64_t WindowImpl::GetVSyncPeriod()
904 {
905 return 0;
906 }
907
UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration> & configuration)908 void WindowImpl::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
909 {
910 if (uiContent_ != nullptr) {
911 WLOGFD("notify ace winId:%{public}u", GetWindowId());
912 uiContent_->UpdateConfiguration(configuration);
913 }
914 }
915
UpdateConfigurationForSpecified(const std::shared_ptr<AppExecFwk::Configuration> & configuration,const std::shared_ptr<Global::Resource::ResourceManager> & resourceManager)916 void WindowImpl::UpdateConfigurationForSpecified(const std::shared_ptr<AppExecFwk::Configuration>& configuration,
917 const std::shared_ptr<Global::Resource::ResourceManager>& resourceManager)
918 {
919 if (uiContent_ == nullptr) {
920 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "uiContent is null, winId: %{public}u", GetWindowId());
921 return;
922 }
923 TLOGI(WmsLogTag::WMS_ATTRIBUTE, "notify ace winId: %{public}u", GetWindowId());
924 uiContent_->UpdateConfiguration(configuration, resourceManager);
925 }
926
UpdateAvoidArea(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)927 void WindowImpl::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
928 {
929 if (!avoidArea) {
930 WLOGFE("invalid avoidArea");
931 return;
932 }
933
934 WLOGFI("type:%{public}d, top:{%{public}d,%{public}d,%{public}d,%{public}d}, "
935 "left:{%{public}d,%{public}d,%{public}d,%{public}d}, right:{%{public}d,%{public}d,%{public}d,%{public}d}, "
936 "bottom:{%{public}d,%{public}d,%{public}d,%{public}d}",
937 type, avoidArea->topRect_.posX_, avoidArea->topRect_.posY_, avoidArea->topRect_.width_,
938 avoidArea->topRect_.height_, avoidArea->leftRect_.posX_, avoidArea->leftRect_.posY_,
939 avoidArea->leftRect_.width_, avoidArea->leftRect_.height_, avoidArea->rightRect_.posX_,
940 avoidArea->rightRect_.posY_, avoidArea->rightRect_.width_, avoidArea->rightRect_.height_,
941 avoidArea->bottomRect_.posX_, avoidArea->bottomRect_.posY_, avoidArea->bottomRect_.width_,
942 avoidArea->bottomRect_.height_);
943
944 {
945 std::lock_guard<std::mutex> lock(mutex_);
946 avoidAreaMap_[type] = avoidArea;
947 }
948 NotifyAvoidAreaChange(avoidArea, type);
949 }
950
NotifySystemBarChange(WindowType type,const SystemBarProperty & property)951 void WindowImpl::NotifySystemBarChange(WindowType type, const SystemBarProperty& property)
952 {
953 auto systemBarEnableListeners = GetListeners<IWindowSystemBarEnableListener>();
954 for (auto& listener : systemBarEnableListeners) {
955 if (listener != nullptr) {
956 WLOGFD("type=%{public}u", type);
957 listener->OnSetSpecificBarProperty(type, property);
958 }
959 }
960 }
961
NotifySetIgnoreSafeArea(bool value)962 void WindowImpl::NotifySetIgnoreSafeArea(bool value)
963 {
964 auto ignoreSafeAreaListeners = GetListeners<IIgnoreViewSafeAreaListener>();
965 for (auto& listener : ignoreSafeAreaListeners) {
966 if (listener != nullptr) {
967 WLOGFD("value=%{public}d", value);
968 listener->SetIgnoreViewSafeArea(value);
969 }
970 }
971 }
972
NotifyAvoidAreaChange(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)973 void WindowImpl::NotifyAvoidAreaChange(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
974 {
975 auto avoidAreaChangeListeners = GetListeners<IAvoidAreaChangedListener>();
976 for (auto& listener : avoidAreaChangeListeners) {
977 if (listener != nullptr) {
978 WLOGFD("type=%{public}u", type);
979 listener->OnAvoidAreaChanged(*avoidArea, type);
980 }
981 }
982 }
983
NotifyTouchDialogTarget(int32_t posX,int32_t posY)984 void WindowImpl::NotifyTouchDialogTarget(int32_t posX, int32_t posY)
985 {
986 return;
987 }
988
SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel)989 void WindowImpl::SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel)
990 {
991 needRemoveWindowInputChannel_ = needRemoveWindowInputChannel;
992 }
993
IsLayoutFullScreen() const994 bool WindowImpl::IsLayoutFullScreen() const
995 {
996 return isIgnoreSafeArea_;
997 }
998
IsFullScreen() const999 bool WindowImpl::IsFullScreen() const
1000 {
1001 auto statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR);
1002 auto naviProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR);
1003 return (IsLayoutFullScreen() && !statusProperty.enable_ && !naviProperty.enable_);
1004 }
1005
SetRequestedOrientation(Orientation orientation)1006 void WindowImpl::SetRequestedOrientation(Orientation orientation)
1007 {
1008 }
1009
GetRequestedOrientation()1010 Orientation WindowImpl::GetRequestedOrientation()
1011 {
1012 return Orientation::UNSPECIFIED;
1013 }
1014
SetTouchHotAreas(const std::vector<Rect> & rects)1015 WMError WindowImpl::SetTouchHotAreas(const std::vector<Rect>& rects)
1016 {
1017 return WMError::WM_OK;
1018 }
GetRequestedTouchHotAreas(std::vector<Rect> & rects) const1019 void WindowImpl::GetRequestedTouchHotAreas(std::vector<Rect>& rects) const
1020 {
1021 }
1022
SetAPPWindowLabel(const std::string & label)1023 WMError WindowImpl::SetAPPWindowLabel(const std::string& label)
1024 {
1025 if (uiContent_ == nullptr) {
1026 WLOGFE("uicontent is empty");
1027 return WMError::WM_ERROR_NULLPTR;
1028 }
1029 uiContent_->SetAppWindowTitle(label);
1030 return WMError::WM_OK;
1031 }
1032
SetAPPWindowIcon(const std::shared_ptr<Media::PixelMap> & icon)1033 WMError WindowImpl::SetAPPWindowIcon(const std::shared_ptr<Media::PixelMap>& icon)
1034 {
1035 if (icon == nullptr) {
1036 WLOGFE("window icon is empty");
1037 return WMError::WM_ERROR_NULLPTR;
1038 }
1039 if (uiContent_ == nullptr) {
1040 WLOGFE("uicontent is empty");
1041 return WMError::WM_ERROR_NULLPTR;
1042 }
1043 uiContent_->SetAppWindowIcon(icon);
1044 return WMError::WM_OK;
1045 }
1046
SetCornerRadius(float cornerRadius)1047 WMError WindowImpl::SetCornerRadius(float cornerRadius)
1048 {
1049 return WMError::WM_OK;
1050 }
1051
SetShadowRadius(float radius)1052 WMError WindowImpl::SetShadowRadius(float radius)
1053 {
1054 return WMError::WM_OK;
1055 }
1056
SetShadowColor(std::string color)1057 WMError WindowImpl::SetShadowColor(std::string color)
1058 {
1059 return WMError::WM_OK;
1060 }
1061
SetShadowOffsetX(float offsetX)1062 WMError WindowImpl::SetShadowOffsetX(float offsetX)
1063 {
1064 return WMError::WM_OK;
1065 }
1066
SetShadowOffsetY(float offsetY)1067 WMError WindowImpl::SetShadowOffsetY(float offsetY)
1068 {
1069 return WMError::WM_OK;
1070 }
1071
SetBlur(float radius)1072 WMError WindowImpl::SetBlur(float radius)
1073 {
1074 return WMError::WM_OK;
1075 }
1076
SetBackdropBlur(float radius)1077 WMError WindowImpl::SetBackdropBlur(float radius)
1078 {
1079 return WMError::WM_OK;
1080 }
1081
SetBackdropBlurStyle(WindowBlurStyle blurStyle)1082 WMError WindowImpl::SetBackdropBlurStyle(WindowBlurStyle blurStyle)
1083 {
1084 return WMError::WM_OK;
1085 }
1086
NotifyMemoryLevel(int32_t level)1087 WMError WindowImpl::NotifyMemoryLevel(int32_t level)
1088 {
1089 return WMError::WM_OK;
1090 }
1091
IsAllowHaveSystemSubWindow()1092 bool WindowImpl::IsAllowHaveSystemSubWindow()
1093 {
1094 return true;
1095 }
1096
1097 /** @note @window.hierarchy */
RaiseToAppTop()1098 WMError WindowImpl::RaiseToAppTop()
1099 {
1100 return WMError::WM_OK;
1101 }
1102
SetAspectRatio(float ratio)1103 WMError WindowImpl::SetAspectRatio(float ratio)
1104 {
1105 return WMError::WM_OK;
1106 }
1107
ResetAspectRatio()1108 WMError WindowImpl::ResetAspectRatio()
1109 {
1110 return WMError::WM_OK;
1111 }
1112
GetKeyboardAnimationConfig()1113 KeyboardAnimationConfig WindowImpl::GetKeyboardAnimationConfig()
1114 {
1115 return keyboardAnimationConfig_;
1116 }
1117
SetNeedDefaultAnimation(bool needDefaultAnimation)1118 void WindowImpl::SetNeedDefaultAnimation(bool needDefaultAnimation)
1119 {
1120 return;
1121 }
1122
SetViewportConfig(const Ace::ViewportConfig & config)1123 void WindowImpl::SetViewportConfig(const Ace::ViewportConfig& config)
1124 {
1125 bool isUpdate = false;
1126 if (width_ != config.Width()) {
1127 width_ = config.Width();
1128 isUpdate = true;
1129 }
1130 if (height_ != config.Height()) {
1131 height_ = config.Height();
1132 isUpdate = true;
1133 }
1134 if (abs(density_ - config.Density()) >= 1e-6) {
1135 density_ = config.Density();
1136 isUpdate = true;
1137 }
1138 if (orientation_ != config.Orientation()) {
1139 orientation_ = config.Orientation();
1140 isUpdate = true;
1141 }
1142 if (isUpdate) {
1143 UpdateViewportConfig();
1144 }
1145 }
1146
UpdateViewportConfig()1147 void WindowImpl::UpdateViewportConfig()
1148 {
1149 Ace::ViewportConfig config;
1150 config.SetSize(width_, height_);
1151 config.SetPosition(0, 0);
1152 config.SetDensity(density_);
1153 config.SetOrientation(orientation_);
1154 if (uiContent_ != nullptr) {
1155 uiContent_->UpdateViewportConfig(config, WindowSizeChangeReason::UNDEFINED);
1156 }
1157 }
1158
SetOrientation(Orientation orientation)1159 void WindowImpl::SetOrientation(Orientation orientation)
1160 {
1161 WLOGFD("SetOrientation : orientation=%{public}d", static_cast<int32_t>(orientation));
1162 if (orientation_ == static_cast<int32_t>(orientation)) {
1163 return;
1164 }
1165 orientation_ = static_cast<int32_t>(orientation);
1166 UpdateViewportConfig();
1167 }
1168
SetSize(int32_t width,int32_t height)1169 void WindowImpl::SetSize(int32_t width, int32_t height)
1170 {
1171 WLOGFD("SetSize : width=%{public}d, height=%{public}d", width, height);
1172 if (width_ == width && height_ == height) {
1173 return;
1174 }
1175 width_ = width;
1176 height_ = height;
1177 UpdateViewportConfig();
1178 }
1179
SetDensity(float density)1180 void WindowImpl::SetDensity(float density)
1181 {
1182 WLOGFD("SetDensity : density=%{public}f", density);
1183 if (abs(density_ - density) <= 0.000001) { // 0.000001: near zero.
1184 return;
1185 }
1186 density_ = density;
1187 UpdateViewportConfig();
1188 }
1189
SetResizeByDragEnabled(bool dragEnabled)1190 WMError WindowImpl::SetResizeByDragEnabled(bool dragEnabled)
1191 {
1192 return WMError::WM_OK;
1193 }
1194
1195 /** @note @window.hierarchy */
SetRaiseByClickEnabled(bool raiseEnabled)1196 WMError WindowImpl::SetRaiseByClickEnabled(bool raiseEnabled)
1197 {
1198 return WMError::WM_OK;
1199 }
1200
1201 /** @note @window.hierarchy */
RaiseAboveTarget(int32_t subWindowId)1202 WMError WindowImpl::RaiseAboveTarget(int32_t subWindowId)
1203 {
1204 return WMError::WM_OK;
1205 }
1206
HideNonSystemFloatingWindows(bool shouldHide)1207 WMError WindowImpl::HideNonSystemFloatingWindows(bool shouldHide)
1208 {
1209 return WMError::WM_OK;
1210 }
1211
RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr & listener)1212 WMError WindowImpl::RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener)
1213 {
1214 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
1215 }
1216
UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr & listener)1217 WMError WindowImpl::UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener)
1218 {
1219 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
1220 }
1221
KeepKeyboardOnFocus(bool keepKeyboardFlag)1222 WmErrorCode WindowImpl::KeepKeyboardOnFocus(bool keepKeyboardFlag)
1223 {
1224 return WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT;
1225 }
1226
SetSingleFrameComposerEnabled(bool enable)1227 WMError WindowImpl::SetSingleFrameComposerEnabled(bool enable)
1228 {
1229 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
1230 }
1231
SetLandscapeMultiWindow(bool isLandscapeMultiWindow)1232 WMError WindowImpl::SetLandscapeMultiWindow(bool isLandscapeMultiWindow)
1233 {
1234 return WMError::WM_OK;
1235 }
1236
SetUiDvsyncSwitch(bool dvsyncSwitch)1237 void WindowImpl::SetUiDvsyncSwitch(bool dvsyncSwitch)
1238 {
1239 }
1240
SetImmersiveModeEnabledState(bool enable)1241 WMError WindowImpl::SetImmersiveModeEnabledState(bool enable)
1242 {
1243 return WMError::WM_OK;
1244 }
1245
GetImmersiveModeEnabledState() const1246 bool WindowImpl::GetImmersiveModeEnabledState() const
1247 {
1248 return true;
1249 }
1250
GetApiTargetVersion() const1251 uint32_t WindowImpl::GetApiTargetVersion() const
1252 {
1253 uint32_t version = 0;
1254 if ((context_ != nullptr) && (context_->GetApplicationInfo() != nullptr)) {
1255 version = context_->GetApplicationInfo()->apiTargetVersion % API_VERSION_MOD;
1256 }
1257 return version;
1258 }
1259 } // namespace Rosen
1260 } // namespace OHOS
1261