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
SetShowWithOptions(bool showWithOptions)549 void WindowImpl::SetShowWithOptions(bool showWithOptions)
550 {
551 showWithOptions_ = showWithOptions;
552 }
553
IsShowWithOptions() const554 bool WindowImpl::IsShowWithOptions() const
555 {
556 return showWithOptions_;
557 }
558
Show(uint32_t reason,bool withAnimation,bool withFocus)559 WMError WindowImpl::Show(uint32_t reason, bool withAnimation, bool withFocus)
560 {
561 return Show(reason, withAnimation, withFocus, false);
562 }
563
Show(uint32_t reason,bool withAnimation,bool withFocus,bool waitAttach)564 WMError WindowImpl::Show(uint32_t reason, bool withAnimation, bool withFocus, bool waitAttach)
565 {
566 if (IsShowWithOptions()) {
567 SetShowWithOptions(false);
568 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
569 }
570 return WMError::WM_OK;
571 }
572
Hide(uint32_t reason,bool withAnimation,bool isFromInnerkits)573 WMError WindowImpl::Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits)
574 {
575 return Hide(reason, withAnimation, isFromInnerkits, false);
576 }
577
Hide(uint32_t reason,bool withAnimation,bool isFromInnerkits,bool waitDetach)578 WMError WindowImpl::Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits, bool waitDetach)
579 {
580 return WMError::WM_OK;
581 }
582
MoveTo(int32_t x,int32_t y,bool isMoveToGlobal,MoveConfiguration moveConfiguration)583 WMError WindowImpl::MoveTo(int32_t x, int32_t y, bool isMoveToGlobal, MoveConfiguration moveConfiguration)
584 {
585 return WMError::WM_OK;
586 }
587
Resize(uint32_t width,uint32_t height,const RectAnimationConfig & rectAnimationConfig)588 WMError WindowImpl::Resize(uint32_t width, uint32_t height, const RectAnimationConfig& rectAnimationConfig)
589 {
590 return WMError::WM_OK;
591 }
592
SetWindowGravity(WindowGravity gravity,uint32_t percent)593 WMError WindowImpl::SetWindowGravity(WindowGravity gravity, uint32_t percent)
594 {
595 return WMError::WM_OK;
596 }
597
SetKeepScreenOn(bool keepScreenOn)598 WMError WindowImpl::SetKeepScreenOn(bool keepScreenOn)
599 {
600 return WMError::WM_OK;
601 }
602
IsKeepScreenOn() const603 bool WindowImpl::IsKeepScreenOn() const
604 {
605 return false;
606 }
607
SetTurnScreenOn(bool turnScreenOn)608 WMError WindowImpl::SetTurnScreenOn(bool turnScreenOn)
609 {
610 return WMError::WM_OK;
611 }
612
IsTurnScreenOn() const613 bool WindowImpl::IsTurnScreenOn() const
614 {
615 return false;
616 }
617
SetBackgroundColor(const std::string & color)618 WMError WindowImpl::SetBackgroundColor(const std::string& color)
619 {
620 return WMError::WM_OK;
621 }
622
SetTransparent(bool isTransparent)623 WMError WindowImpl::SetTransparent(bool isTransparent)
624 {
625 return WMError::WM_OK;
626 }
627
IsTransparent() const628 bool WindowImpl::IsTransparent() const
629 {
630 return true;
631 }
632
SetBrightness(float brightness)633 WMError WindowImpl::SetBrightness(float brightness)
634 {
635 return WMError::WM_OK;
636 }
637
GetBrightness() const638 float WindowImpl::GetBrightness() const
639 {
640 return 0.0;
641 }
642
SetCallingWindow(uint32_t windowId)643 WMError WindowImpl::SetCallingWindow(uint32_t windowId)
644 {
645 return WMError::WM_OK;
646 }
647
SetPrivacyMode(bool isPrivacyMode)648 WMError WindowImpl::SetPrivacyMode(bool isPrivacyMode)
649 {
650 return WMError::WM_OK;
651 }
652
IsPrivacyMode() const653 bool WindowImpl::IsPrivacyMode() const
654 {
655 return false;
656 }
657
SetSystemPrivacyMode(bool isSystemPrivacyMode)658 void WindowImpl::SetSystemPrivacyMode(bool isSystemPrivacyMode)
659 {
660 }
661
SetSnapshotSkip(bool isSkip)662 WMError WindowImpl::SetSnapshotSkip(bool isSkip)
663 {
664 return WMError::WM_OK;
665 }
666
DisableAppWindowDecor()667 WMError WindowImpl::DisableAppWindowDecor()
668 {
669 return WMError::WM_OK;
670 }
671
Maximize()672 WMError WindowImpl::Maximize()
673 {
674 return WMError::WM_OK;
675 }
676
Minimize()677 WMError WindowImpl::Minimize()
678 {
679 return WMError::WM_OK;
680 }
681
Recover()682 WMError WindowImpl::Recover()
683 {
684 return WMError::WM_OK;
685 }
686
Close()687 WMError WindowImpl::Close()
688 {
689 return WMError::WM_OK;
690 }
691
StartMove()692 void WindowImpl::StartMove()
693 {
694 return;
695 }
696
RequestFocus() const697 WMError WindowImpl::RequestFocus() const
698 {
699 return WMError::WM_OK;
700 }
701
IsFocused() const702 bool WindowImpl::IsFocused() const
703 {
704 return true;
705 }
706
SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer> & inputEventConsumer)707 void WindowImpl::SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer)
708 {
709 return;
710 }
711
RegisterLifeCycleListener(const sptr<IWindowLifeCycle> & listener)712 WMError WindowImpl::RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
713 {
714 return WMError::WM_OK;
715 }
716
RegisterWindowChangeListener(const sptr<IWindowChangeListener> & listener)717 WMError WindowImpl::RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
718 {
719 return WMError::WM_OK;
720 }
721
UnregisterLifeCycleListener(const sptr<IWindowLifeCycle> & listener)722 WMError WindowImpl::UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
723 {
724 return WMError::WM_OK;
725 }
726
UnregisterWindowChangeListener(const sptr<IWindowChangeListener> & listener)727 WMError WindowImpl::UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
728 {
729 return WMError::WM_OK;
730 }
731
RegisterAvoidAreaChangeListener(const sptr<IAvoidAreaChangedListener> & listener)732 WMError WindowImpl::RegisterAvoidAreaChangeListener(const sptr<IAvoidAreaChangedListener>& listener)
733 {
734 WLOGFD("Start register");
735 std::lock_guard<std::mutex> lock(globalMutex_);
736 WMError ret = RegisterListener(avoidAreaChangeListeners_[GetWindowId()], listener);
737 return ret;
738 }
739
UnregisterAvoidAreaChangeListener(const sptr<IAvoidAreaChangedListener> & listener)740 WMError WindowImpl::UnregisterAvoidAreaChangeListener(const sptr<IAvoidAreaChangedListener>& listener)
741 {
742 WLOGFD("Start unregister");
743 std::lock_guard<std::mutex> lock(globalMutex_);
744 WMError ret = UnregisterListener(avoidAreaChangeListeners_[GetWindowId()], listener);
745 return ret;
746 }
747
RegisterDragListener(const sptr<IWindowDragListener> & listener)748 WMError WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
749 {
750 return WMError::WM_OK;
751 }
752
UnregisterDragListener(const sptr<IWindowDragListener> & listener)753 WMError WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
754 {
755 return WMError::WM_OK;
756 }
757
RegisterDisplayMoveListener(sptr<IDisplayMoveListener> & listener)758 WMError WindowImpl::RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
759 {
760 return WMError::WM_OK;
761 }
762
UnregisterDisplayMoveListener(sptr<IDisplayMoveListener> & listener)763 WMError WindowImpl::UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
764 {
765 return WMError::WM_OK;
766 }
767
RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc & func)768 void WindowImpl::RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func)
769 {
770 return;
771 }
772
RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener> & listener)773 WMError WindowImpl::RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
774 {
775 return WMError::WM_OK;
776 }
777
UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener> & listener)778 WMError WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
779 {
780 return WMError::WM_OK;
781 }
782
RegisterTouchOutsideListener(const sptr<ITouchOutsideListener> & listener)783 WMError WindowImpl::RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
784 {
785 return WMError::WM_OK;
786 }
787
UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener> & listener)788 WMError WindowImpl::UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
789 {
790 return WMError::WM_OK;
791 }
792
RegisterAnimationTransitionController(const sptr<IAnimationTransitionController> & listener)793 WMError WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener)
794 {
795 return WMError::WM_OK;
796 }
797
RegisterScreenshotListener(const sptr<IScreenshotListener> & listener)798 WMError WindowImpl::RegisterScreenshotListener(const sptr<IScreenshotListener>& listener)
799 {
800 return WMError::WM_OK;
801 }
802
UnregisterScreenshotListener(const sptr<IScreenshotListener> & listener)803 WMError WindowImpl::UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener)
804 {
805 return WMError::WM_OK;
806 }
807
RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener> & listener)808 WMError WindowImpl::RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
809 {
810 return WMError::WM_OK;
811 }
812
UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener> & listener)813 WMError WindowImpl::UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
814 {
815 return WMError::WM_OK;
816 }
817
RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener> & listener)818 void WindowImpl::RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
819 {
820 return;
821 }
822
UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener> & listener)823 void WindowImpl::UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
824 {
825 return;
826 }
827
RegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener> & listener)828 WMError WindowImpl::RegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener)
829 {
830 WLOGFI("Register");
831 std::lock_guard<std::mutex> lock(globalMutex_);
832 WMError ret = RegisterListener(systemBarEnableListeners_[GetWindowId()], listener);
833 return ret;
834 }
835
UnRegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener> & listener)836 WMError WindowImpl::UnRegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener)
837 {
838 WLOGFI("UnRegister");
839 std::lock_guard<std::mutex> lock(globalMutex_);
840 WMError ret = UnregisterListener(systemBarEnableListeners_[GetWindowId()], listener);
841 return ret;
842 }
843
RegisterIgnoreViewSafeAreaListener(const sptr<IIgnoreViewSafeAreaListener> & listener)844 WMError WindowImpl::RegisterIgnoreViewSafeAreaListener(const sptr<IIgnoreViewSafeAreaListener>& listener)
845 {
846 WLOGFI("Register");
847 std::lock_guard<std::mutex> lock(globalMutex_);
848 WMError ret = RegisterListener(ignoreSafeAreaListeners_[GetWindowId()], listener);
849 return ret;
850 }
851
UnRegisterIgnoreViewSafeAreaListener(const sptr<IIgnoreViewSafeAreaListener> & listener)852 WMError WindowImpl::UnRegisterIgnoreViewSafeAreaListener(const sptr<IIgnoreViewSafeAreaListener>& listener)
853 {
854 WLOGFI("UnRegister");
855 std::lock_guard<std::mutex> lock(globalMutex_);
856 WMError ret = UnregisterListener(ignoreSafeAreaListeners_[GetWindowId()], listener);
857 return ret;
858 }
859
860 template<typename T>
RegisterListener(std::vector<sptr<T>> & holder,const sptr<T> & listener)861 WMError WindowImpl::RegisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener)
862 {
863 if (listener == nullptr) {
864 WLOGFE("listener is nullptr");
865 return WMError::WM_ERROR_NULLPTR;
866 }
867 if (std::find(holder.begin(), holder.end(), listener) != holder.end()) {
868 WLOGFE("Listener already registered");
869 return WMError::WM_OK;
870 }
871 holder.emplace_back(listener);
872 return WMError::WM_OK;
873 }
874
875 template<typename T>
UnregisterListener(std::vector<sptr<T>> & holder,const sptr<T> & listener)876 WMError WindowImpl::UnregisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener)
877 {
878 if (listener == nullptr) {
879 WLOGFE("listener could not be null");
880 return WMError::WM_ERROR_NULLPTR;
881 }
882 holder.erase(std::remove_if(holder.begin(), holder.end(),
883 [listener](sptr<T> registeredListener) {
884 return registeredListener == listener;
885 }), holder.end());
886 return WMError::WM_OK;
887 }
888
SetAceAbilityHandler(const sptr<IAceAbilityHandler> & handler)889 void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
890 {
891 return;
892 }
893
SetRequestWindowModeSupportType(uint32_t windowModeSupportType)894 void WindowImpl::SetRequestWindowModeSupportType(uint32_t windowModeSupportType)
895 {
896 return;
897 }
898
ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent)899 void WindowImpl::ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
900 {
901 if (uiContent_ == nullptr) {
902 WLOGFE("ConsumeKeyEvent to uiContent failed,uiContent_ is null");
903 return;
904 }
905 uiContent_->ProcessKeyEvent(keyEvent);
906 }
907
ConsumeBackEvent()908 void WindowImpl::ConsumeBackEvent()
909 {
910 if (uiContent_ == nullptr) {
911 TLOGE(WmsLogTag::WMS_EVENT, "ConsumeBackEvent to uiContent failed, uiContent_ is null");
912 return;
913 }
914 auto isConsumed = uiContent_->ProcessBackPressed();
915 TLOGI(WmsLogTag::WMS_EVENT, "ConsumeBackEvent to uiContent, %{public}d", isConsumed);
916 }
917
IsDialogSessionBackGestureEnabled()918 bool WindowImpl::IsDialogSessionBackGestureEnabled()
919 {
920 return false;
921 }
922
ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)923 void WindowImpl::ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
924 {
925 if (uiContent_ == nullptr) {
926 WLOGFE("ConsumePointerEvent to uiContent failed,uiContent_ is null");
927 return;
928 }
929 (void)uiContent_->ProcessPointerEvent(pointerEvent);
930 }
931
932
RequestVsync(const std::shared_ptr<VsyncCallback> & vsyncCallback)933 void WindowImpl::RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback)
934 {
935 if (vsyncStation_ == nullptr) {
936 TLOGE(WmsLogTag::WMS_MAIN, "failed, vsyncStation is null");
937 return;
938 }
939 vsyncStation_->RequestVsync(vsyncCallback);
940 }
941
GetVSyncPeriod()942 int64_t WindowImpl::GetVSyncPeriod()
943 {
944 return 0;
945 }
946
UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration> & configuration)947 void WindowImpl::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
948 {
949 if (uiContent_ != nullptr) {
950 WLOGFD("notify ace winId:%{public}u", GetWindowId());
951 uiContent_->UpdateConfiguration(configuration);
952 }
953 }
954
UpdateConfigurationForSpecified(const std::shared_ptr<AppExecFwk::Configuration> & configuration,const std::shared_ptr<Global::Resource::ResourceManager> & resourceManager)955 void WindowImpl::UpdateConfigurationForSpecified(const std::shared_ptr<AppExecFwk::Configuration>& configuration,
956 const std::shared_ptr<Global::Resource::ResourceManager>& resourceManager)
957 {
958 if (uiContent_ == nullptr) {
959 TLOGE(WmsLogTag::WMS_ATTRIBUTE, "uiContent is null, winId: %{public}u", GetWindowId());
960 return;
961 }
962 TLOGI(WmsLogTag::WMS_ATTRIBUTE, "notify ace winId: %{public}u", GetWindowId());
963 uiContent_->UpdateConfiguration(configuration, resourceManager);
964 }
965
UpdateAvoidArea(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)966 void WindowImpl::UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
967 {
968 if (!avoidArea) {
969 WLOGFE("invalid avoidArea");
970 return;
971 }
972
973 WLOGFI("type:%{public}d, top:{%{public}d,%{public}d,%{public}d,%{public}d}, "
974 "left:{%{public}d,%{public}d,%{public}d,%{public}d}, right:{%{public}d,%{public}d,%{public}d,%{public}d}, "
975 "bottom:{%{public}d,%{public}d,%{public}d,%{public}d}",
976 type, avoidArea->topRect_.posX_, avoidArea->topRect_.posY_, avoidArea->topRect_.width_,
977 avoidArea->topRect_.height_, avoidArea->leftRect_.posX_, avoidArea->leftRect_.posY_,
978 avoidArea->leftRect_.width_, avoidArea->leftRect_.height_, avoidArea->rightRect_.posX_,
979 avoidArea->rightRect_.posY_, avoidArea->rightRect_.width_, avoidArea->rightRect_.height_,
980 avoidArea->bottomRect_.posX_, avoidArea->bottomRect_.posY_, avoidArea->bottomRect_.width_,
981 avoidArea->bottomRect_.height_);
982
983 {
984 std::lock_guard<std::mutex> lock(mutex_);
985 avoidAreaMap_[type] = avoidArea;
986 }
987 NotifyAvoidAreaChange(avoidArea, type);
988 }
989
NotifySystemBarChange(WindowType type,const SystemBarProperty & property)990 void WindowImpl::NotifySystemBarChange(WindowType type, const SystemBarProperty& property)
991 {
992 auto systemBarEnableListeners = GetListeners<IWindowSystemBarEnableListener>();
993 for (auto& listener : systemBarEnableListeners) {
994 if (listener != nullptr) {
995 WLOGFD("type=%{public}u", type);
996 listener->OnSetSpecificBarProperty(type, property);
997 }
998 }
999 }
1000
NotifySetIgnoreSafeArea(bool value)1001 void WindowImpl::NotifySetIgnoreSafeArea(bool value)
1002 {
1003 auto ignoreSafeAreaListeners = GetListeners<IIgnoreViewSafeAreaListener>();
1004 for (auto& listener : ignoreSafeAreaListeners) {
1005 if (listener != nullptr) {
1006 WLOGFD("value=%{public}d", value);
1007 listener->SetIgnoreViewSafeArea(value);
1008 }
1009 }
1010 }
1011
NotifyAvoidAreaChange(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)1012 void WindowImpl::NotifyAvoidAreaChange(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)
1013 {
1014 auto avoidAreaChangeListeners = GetListeners<IAvoidAreaChangedListener>();
1015 for (auto& listener : avoidAreaChangeListeners) {
1016 if (listener != nullptr) {
1017 WLOGFD("type=%{public}u", type);
1018 listener->OnAvoidAreaChanged(*avoidArea, type);
1019 }
1020 }
1021 }
1022
NotifyTouchDialogTarget(int32_t posX,int32_t posY)1023 void WindowImpl::NotifyTouchDialogTarget(int32_t posX, int32_t posY)
1024 {
1025 return;
1026 }
1027
SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel)1028 void WindowImpl::SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel)
1029 {
1030 needRemoveWindowInputChannel_ = needRemoveWindowInputChannel;
1031 }
1032
IsLayoutFullScreen() const1033 bool WindowImpl::IsLayoutFullScreen() const
1034 {
1035 return isIgnoreSafeArea_;
1036 }
1037
IsFullScreen() const1038 bool WindowImpl::IsFullScreen() const
1039 {
1040 auto statusProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_STATUS_BAR);
1041 auto naviProperty = GetSystemBarPropertyByType(WindowType::WINDOW_TYPE_NAVIGATION_BAR);
1042 return (IsLayoutFullScreen() && !statusProperty.enable_ && !naviProperty.enable_);
1043 }
1044
NotifyPreferredOrientationChange(Orientation orientation)1045 void WindowImpl::NotifyPreferredOrientationChange(Orientation orientation)
1046 {
1047 }
1048
SetUserRequestedOrientation(Orientation orientation)1049 void WindowImpl::SetUserRequestedOrientation(Orientation orientation)
1050 {
1051 }
1052
SetRequestedOrientation(Orientation orientation)1053 void WindowImpl::SetRequestedOrientation(Orientation orientation)
1054 {
1055 }
1056
GetRequestedOrientation()1057 Orientation WindowImpl::GetRequestedOrientation()
1058 {
1059 return Orientation::UNSPECIFIED;
1060 }
1061
SetTouchHotAreas(const std::vector<Rect> & rects)1062 WMError WindowImpl::SetTouchHotAreas(const std::vector<Rect>& rects)
1063 {
1064 return WMError::WM_OK;
1065 }
GetRequestedTouchHotAreas(std::vector<Rect> & rects) const1066 void WindowImpl::GetRequestedTouchHotAreas(std::vector<Rect>& rects) const
1067 {
1068 }
1069
SetAPPWindowLabel(const std::string & label)1070 WMError WindowImpl::SetAPPWindowLabel(const std::string& label)
1071 {
1072 if (uiContent_ == nullptr) {
1073 WLOGFE("uicontent is empty");
1074 return WMError::WM_ERROR_NULLPTR;
1075 }
1076 uiContent_->SetAppWindowTitle(label);
1077 return WMError::WM_OK;
1078 }
1079
SetAPPWindowIcon(const std::shared_ptr<Media::PixelMap> & icon)1080 WMError WindowImpl::SetAPPWindowIcon(const std::shared_ptr<Media::PixelMap>& icon)
1081 {
1082 if (icon == nullptr) {
1083 WLOGFE("window icon is empty");
1084 return WMError::WM_ERROR_NULLPTR;
1085 }
1086 if (uiContent_ == nullptr) {
1087 WLOGFE("uicontent is empty");
1088 return WMError::WM_ERROR_NULLPTR;
1089 }
1090 uiContent_->SetAppWindowIcon(icon);
1091 return WMError::WM_OK;
1092 }
1093
SetCornerRadius(float cornerRadius)1094 WMError WindowImpl::SetCornerRadius(float cornerRadius)
1095 {
1096 return WMError::WM_OK;
1097 }
1098
SetShadowRadius(float radius)1099 WMError WindowImpl::SetShadowRadius(float radius)
1100 {
1101 return WMError::WM_OK;
1102 }
1103
SetShadowColor(std::string color)1104 WMError WindowImpl::SetShadowColor(std::string color)
1105 {
1106 return WMError::WM_OK;
1107 }
1108
SetShadowOffsetX(float offsetX)1109 WMError WindowImpl::SetShadowOffsetX(float offsetX)
1110 {
1111 return WMError::WM_OK;
1112 }
1113
SetShadowOffsetY(float offsetY)1114 WMError WindowImpl::SetShadowOffsetY(float offsetY)
1115 {
1116 return WMError::WM_OK;
1117 }
1118
SetBlur(float radius)1119 WMError WindowImpl::SetBlur(float radius)
1120 {
1121 return WMError::WM_OK;
1122 }
1123
SetBackdropBlur(float radius)1124 WMError WindowImpl::SetBackdropBlur(float radius)
1125 {
1126 return WMError::WM_OK;
1127 }
1128
SetBackdropBlurStyle(WindowBlurStyle blurStyle)1129 WMError WindowImpl::SetBackdropBlurStyle(WindowBlurStyle blurStyle)
1130 {
1131 return WMError::WM_OK;
1132 }
1133
NotifyMemoryLevel(int32_t level)1134 WMError WindowImpl::NotifyMemoryLevel(int32_t level)
1135 {
1136 return WMError::WM_OK;
1137 }
1138
IsAllowHaveSystemSubWindow()1139 bool WindowImpl::IsAllowHaveSystemSubWindow()
1140 {
1141 return true;
1142 }
1143
1144 /** @note @window.hierarchy */
RaiseToAppTop()1145 WMError WindowImpl::RaiseToAppTop()
1146 {
1147 return WMError::WM_OK;
1148 }
1149
SetAspectRatio(float ratio)1150 WMError WindowImpl::SetAspectRatio(float ratio)
1151 {
1152 return WMError::WM_OK;
1153 }
1154
ResetAspectRatio()1155 WMError WindowImpl::ResetAspectRatio()
1156 {
1157 return WMError::WM_OK;
1158 }
1159
GetKeyboardAnimationConfig()1160 KeyboardAnimationConfig WindowImpl::GetKeyboardAnimationConfig()
1161 {
1162 return keyboardAnimationConfig_;
1163 }
1164
SetNeedDefaultAnimation(bool needDefaultAnimation)1165 void WindowImpl::SetNeedDefaultAnimation(bool needDefaultAnimation)
1166 {
1167 return;
1168 }
1169
SetViewportConfig(const Ace::ViewportConfig & config)1170 void WindowImpl::SetViewportConfig(const Ace::ViewportConfig& config)
1171 {
1172 bool isUpdate = false;
1173 if (width_ != config.Width()) {
1174 width_ = config.Width();
1175 isUpdate = true;
1176 }
1177 if (height_ != config.Height()) {
1178 height_ = config.Height();
1179 isUpdate = true;
1180 }
1181 if (abs(density_ - config.Density()) >= 1e-6) {
1182 density_ = config.Density();
1183 isUpdate = true;
1184 }
1185 if (orientation_ != config.Orientation()) {
1186 orientation_ = config.Orientation();
1187 isUpdate = true;
1188 }
1189 if (isUpdate) {
1190 UpdateViewportConfig();
1191 }
1192 }
1193
UpdateViewportConfig()1194 void WindowImpl::UpdateViewportConfig()
1195 {
1196 Ace::ViewportConfig config;
1197 config.SetSize(width_, height_);
1198 config.SetPosition(0, 0);
1199 config.SetDensity(density_);
1200 config.SetOrientation(orientation_);
1201 if (uiContent_ != nullptr) {
1202 uiContent_->UpdateViewportConfig(config, WindowSizeChangeReason::UNDEFINED);
1203 }
1204 }
1205
SetOrientation(Orientation orientation)1206 void WindowImpl::SetOrientation(Orientation orientation)
1207 {
1208 WLOGFD("SetOrientation : orientation=%{public}d", static_cast<int32_t>(orientation));
1209 if (orientation_ == static_cast<int32_t>(orientation)) {
1210 return;
1211 }
1212 orientation_ = static_cast<int32_t>(orientation);
1213 UpdateViewportConfig();
1214 }
1215
SetSize(int32_t width,int32_t height)1216 void WindowImpl::SetSize(int32_t width, int32_t height)
1217 {
1218 WLOGFD("SetSize : width=%{public}d, height=%{public}d", width, height);
1219 if (width_ == width && height_ == height) {
1220 return;
1221 }
1222 width_ = width;
1223 height_ = height;
1224 UpdateViewportConfig();
1225 }
1226
SetDensity(float density)1227 void WindowImpl::SetDensity(float density)
1228 {
1229 WLOGFD("SetDensity : density=%{public}f", density);
1230 if (abs(density_ - density) <= 0.000001) { // 0.000001: near zero.
1231 return;
1232 }
1233 density_ = density;
1234 UpdateViewportConfig();
1235 }
1236
SetResizeByDragEnabled(bool dragEnabled)1237 WMError WindowImpl::SetResizeByDragEnabled(bool dragEnabled)
1238 {
1239 return WMError::WM_OK;
1240 }
1241
1242 /** @note @window.hierarchy */
SetRaiseByClickEnabled(bool raiseEnabled)1243 WMError WindowImpl::SetRaiseByClickEnabled(bool raiseEnabled)
1244 {
1245 return WMError::WM_OK;
1246 }
1247
1248 /** @note @window.hierarchy */
RaiseAboveTarget(int32_t subWindowId)1249 WMError WindowImpl::RaiseAboveTarget(int32_t subWindowId)
1250 {
1251 return WMError::WM_OK;
1252 }
1253
HideNonSystemFloatingWindows(bool shouldHide)1254 WMError WindowImpl::HideNonSystemFloatingWindows(bool shouldHide)
1255 {
1256 return WMError::WM_OK;
1257 }
1258
RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr & listener)1259 WMError WindowImpl::RegisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener)
1260 {
1261 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
1262 }
1263
UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr & listener)1264 WMError WindowImpl::UnregisterWindowVisibilityChangeListener(const WindowVisibilityListenerSptr& listener)
1265 {
1266 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
1267 }
1268
KeepKeyboardOnFocus(bool keepKeyboardFlag)1269 WmErrorCode WindowImpl::KeepKeyboardOnFocus(bool keepKeyboardFlag)
1270 {
1271 return WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT;
1272 }
1273
SetSingleFrameComposerEnabled(bool enable)1274 WMError WindowImpl::SetSingleFrameComposerEnabled(bool enable)
1275 {
1276 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
1277 }
1278
SetLandscapeMultiWindow(bool isLandscapeMultiWindow)1279 WMError WindowImpl::SetLandscapeMultiWindow(bool isLandscapeMultiWindow)
1280 {
1281 return WMError::WM_OK;
1282 }
1283
SetUiDvsyncSwitch(bool dvsyncSwitch)1284 void WindowImpl::SetUiDvsyncSwitch(bool dvsyncSwitch)
1285 {
1286 }
1287
SetTouchEvent(int32_t touchType)1288 void WindowImpl::SetTouchEvent(int32_t touchType)
1289 {
1290 }
1291
SetImmersiveModeEnabledState(bool enable)1292 WMError WindowImpl::SetImmersiveModeEnabledState(bool enable)
1293 {
1294 return WMError::WM_OK;
1295 }
1296
GetImmersiveModeEnabledState() const1297 bool WindowImpl::GetImmersiveModeEnabledState() const
1298 {
1299 return true;
1300 }
1301
GetApiTargetVersion() const1302 uint32_t WindowImpl::GetApiTargetVersion() const
1303 {
1304 uint32_t version = 0;
1305 if ((context_ != nullptr) && (context_->GetApplicationInfo() != nullptr)) {
1306 version = context_->GetApplicationInfo()->apiTargetVersion % API_VERSION_MOD;
1307 }
1308 return version;
1309 }
1310 } // namespace Rosen
1311 } // namespace OHOS
1312