1 /*
2 * Copyright (c) 2022-2023 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 "window_manager_hilog.h"
19 #include "window_helper.h"
20 #include "window_option.h"
21 #include "viewport_config.h"
22 #include "singleton_container.h"
23 #include "vsync_station.h"
24
25 namespace OHOS {
26 namespace Rosen {
27 namespace {
28 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowImpl"};
29 }
30 std::map<std::string, std::pair<uint32_t, sptr<Window>>> WindowImpl::windowMap_;
31 std::map<uint32_t, std::vector<sptr<WindowImpl>>> WindowImpl::subWindowMap_;
32 static int constructorCnt = 0;
33 static int deConstructorCnt = 0;
WindowImpl(const sptr<WindowOption> & option)34 WindowImpl::WindowImpl(const sptr<WindowOption>& option)
35 {
36 if (option != nullptr) {
37 name_ = option->GetWindowName();
38 } else {
39 name_ = "main_window";
40 }
41 WLOGFI("WindowImpl constructorCnt: %{public}d",
42 ++constructorCnt);
43 }
44
~WindowImpl()45 WindowImpl::~WindowImpl()
46 {
47 WLOGFI("windowName: %{public}s, windowId: %{public}d, deConstructorCnt: %{public}d",
48 GetWindowName().c_str(), GetWindowId(), ++deConstructorCnt);
49 Destroy();
50 }
51
CreateSurfaceNode(const std::string name,const SendRenderDataCallback & callback)52 void WindowImpl::CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback)
53 {
54 WLOGFI("CreateSurfaceNode");
55 struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
56 rsSurfaceNodeConfig.SurfaceNodeName = name;
57 rsSurfaceNodeConfig.additionalData = reinterpret_cast<void*>(callback);
58 surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig);
59 }
60
SetContentInfoCallback(const ContentInfoCallback & callback)61 void WindowImpl::SetContentInfoCallback(const ContentInfoCallback& callback)
62 {
63 contentInfoCallback_ = callback;
64 }
65
Find(const std::string & name)66 sptr<Window> WindowImpl::Find(const std::string& name)
67 {
68 return nullptr;
69 }
70
GetContext() const71 const std::shared_ptr<AbilityRuntime::Context> WindowImpl::GetContext() const
72 {
73 return nullptr;
74 }
75
GetTopWindowWithId(uint32_t mainWinId)76 sptr<Window> WindowImpl::GetTopWindowWithId(uint32_t mainWinId)
77 {
78 return nullptr;
79 }
80
GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context> & context)81 sptr<Window> WindowImpl::GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context>& context)
82 {
83 return nullptr;
84 }
85
GetSubWindow(uint32_t parentId)86 std::vector<sptr<Window>> WindowImpl::GetSubWindow(uint32_t parentId)
87 {
88 return std::vector<sptr<Window>>();
89 }
90
UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration> & configuration)91 void WindowImpl::UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
92 {
93 for (const auto& winPair : windowMap_) {
94 auto window = winPair.second.second;
95 window->UpdateConfiguration(configuration);
96 }
97 }
98
GetSurfaceNode() const99 std::shared_ptr<RSSurfaceNode> WindowImpl::GetSurfaceNode() const
100 {
101 return surfaceNode_;
102 }
103
GetRect() const104 Rect WindowImpl::GetRect() const
105 {
106 return Rect{0, 0, 0, 0};
107 }
108
GetRequestRect() const109 Rect WindowImpl::GetRequestRect() const
110 {
111 return Rect{0, 0, 0, 0};
112 }
113
GetType() const114 WindowType WindowImpl::GetType() const
115 {
116 return WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
117 }
118
GetMode() const119 WindowMode WindowImpl::GetMode() const
120 {
121 return WindowMode::WINDOW_MODE_UNDEFINED;
122 }
123
GetAlpha() const124 float WindowImpl::GetAlpha() const
125 {
126 return 0.0;
127 }
128
GetWindowState() const129 WindowState WindowImpl::GetWindowState() const
130 {
131 return state_;
132 }
133
SetFocusable(bool isFocusable)134 WMError WindowImpl::SetFocusable(bool isFocusable)
135 {
136 return WMError::WM_OK;
137 }
138
GetFocusable() const139 bool WindowImpl::GetFocusable() const
140 {
141 return false;
142 }
143
SetTouchable(bool isTouchable)144 WMError WindowImpl::SetTouchable(bool isTouchable)
145 {
146 return WMError::WM_OK;
147 }
148
GetTouchable() const149 bool WindowImpl::GetTouchable() const
150 {
151 return false;
152 }
153
GetWindowName() const154 const std::string& WindowImpl::GetWindowName() const
155 {
156 return name_;
157 }
158
GetWindowId() const159 uint32_t WindowImpl::GetWindowId() const
160 {
161 return 0;
162 }
163
GetWindowFlags() const164 uint32_t WindowImpl::GetWindowFlags() const
165 {
166 return 0;
167 }
168
GetRequestModeSupportInfo() const169 uint32_t WindowImpl::GetRequestModeSupportInfo() const
170 {
171 return 0;
172 }
173
IsMainHandlerAvailable() const174 bool WindowImpl::IsMainHandlerAvailable() const
175 {
176 return true;
177 }
178
GetSystemBarPropertyByType(WindowType type) const179 SystemBarProperty WindowImpl::GetSystemBarPropertyByType(WindowType type) const
180 {
181
182 return SystemBarProperty();
183 }
184
GetAvoidAreaByType(AvoidAreaType type,AvoidArea & avoidArea)185 WMError WindowImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea)
186 {
187 return WMError::WM_OK;
188 }
189
SetWindowType(WindowType type)190 WMError WindowImpl::SetWindowType(WindowType type)
191 {
192 return WMError::WM_OK;
193 }
194
SetWindowMode(WindowMode mode)195 WMError WindowImpl::SetWindowMode(WindowMode mode)
196 {
197 return WMError::WM_OK;
198 }
199
SetAlpha(float alpha)200 WMError WindowImpl::SetAlpha(float alpha)
201 {
202 return WMError::WM_OK;
203 }
204
SetTransform(const Transform & trans)205 WMError WindowImpl::SetTransform(const Transform& trans)
206 {
207 return WMError::WM_OK;
208 }
209
GetTransform() const210 const Transform& WindowImpl::GetTransform() const
211 {
212 return transform_;
213 }
214
AddWindowFlag(WindowFlag flag)215 WMError WindowImpl::AddWindowFlag(WindowFlag flag)
216 {
217 return WMError::WM_OK;
218 }
219
RemoveWindowFlag(WindowFlag flag)220 WMError WindowImpl::RemoveWindowFlag(WindowFlag flag)
221 {
222 return WMError::WM_OK;
223 }
224
SetWindowFlags(uint32_t flags)225 WMError WindowImpl::SetWindowFlags(uint32_t flags)
226 {
227 return WMError::WM_OK;
228 }
229
OnNewWant(const AAFwk::Want & want)230 void WindowImpl::OnNewWant(const AAFwk::Want& want)
231 {
232 return;
233 }
234
SetUIContent(const std::string & contentInfo,NativeEngine * engine,NativeValue * storage,bool isdistributed,AppExecFwk::Ability * ability)235 WMError WindowImpl::SetUIContent(const std::string& contentInfo,
236 NativeEngine* engine, NativeValue* storage, bool isdistributed, AppExecFwk::Ability* ability)
237 {
238 WLOGFD("SetUIContent: %{public}s", contentInfo.c_str());
239 if (uiContent_) {
240 uiContent_->Destroy();
241 }
242 std::unique_ptr<Ace::UIContent> uiContent;
243 if (ability != nullptr) {
244 uiContent = Ace::UIContent::Create(ability);
245 } else {
246 uiContent = Ace::UIContent::Create(context_.get(), engine);
247 }
248 if (uiContent == nullptr) {
249 WLOGFE("fail to SetUIContent");
250 return WMError::WM_ERROR_NULLPTR;
251 }
252 if (isdistributed) {
253 uiContent->Restore(this, contentInfo, storage);
254 } else {
255 uiContent->Initialize(this, contentInfo, storage);
256 }
257 uiContent_ = std::move(uiContent);
258 if (uiContent_ == nullptr) {
259 WLOGFE("uiContent_ is NULL");
260 return WMError::WM_ERROR_NULLPTR;
261 }
262 UpdateViewportConfig();
263 if (contentInfoCallback_) {
264 contentInfoCallback_(contentInfo);
265 }
266 return WMError::WM_OK;
267 }
268
269
GetUIContent() const270 Ace::UIContent* WindowImpl::GetUIContent() const
271 {
272 return uiContent_.get();
273 }
274
GetContentInfo()275 std::string WindowImpl::GetContentInfo()
276 {
277 return "";
278 }
279
IsSupportWideGamut()280 bool WindowImpl::IsSupportWideGamut()
281 {
282 return true;
283 }
284
SetColorSpace(ColorSpace colorSpace)285 void WindowImpl::SetColorSpace(ColorSpace colorSpace)
286 {
287 return;
288 }
289
GetColorSpace()290 ColorSpace WindowImpl::GetColorSpace()
291 {
292 return ColorSpace::COLOR_SPACE_DEFAULT;
293 }
294
Snapshot()295 std::shared_ptr<Media::PixelMap> WindowImpl::Snapshot()
296 {
297 return nullptr;
298 }
299
DumpInfo(const std::vector<std::string> & params,std::vector<std::string> & info)300 void WindowImpl::DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
301 {
302 return;
303 }
304
SetSystemBarProperty(WindowType type,const SystemBarProperty & property)305 WMError WindowImpl::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
306 {
307 return WMError::WM_OK;
308 }
309
SetLayoutFullScreen(bool status)310 WMError WindowImpl::SetLayoutFullScreen(bool status)
311 {
312 return WMError::WM_OK;
313 }
314
SetFullScreen(bool status)315 WMError WindowImpl::SetFullScreen(bool status)
316 {
317 return WMError::WM_OK;
318 }
319
Create(uint32_t parentId,const std::shared_ptr<AbilityRuntime::Context> & context)320 WMError WindowImpl::Create(uint32_t parentId, const std::shared_ptr<AbilityRuntime::Context>& context)
321 {
322 WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str());
323 context_ = context;
324 return WMError::WM_OK;
325 }
326
BindDialogTarget(sptr<IRemoteObject> targetToken)327 WMError WindowImpl::BindDialogTarget(sptr<IRemoteObject> targetToken)
328 {
329 return WMError::WM_OK;
330 }
331
Destroy()332 WMError WindowImpl::Destroy()
333 {
334 if (uiContent_) {
335 uiContent_->Destroy();
336 }
337 return WMError::WM_OK;
338 }
339
UpdateSurfaceNodeAfterCustomAnimation(bool isAdd)340 WMError WindowImpl::UpdateSurfaceNodeAfterCustomAnimation(bool isAdd)
341 {
342 return WMError::WM_OK;
343 }
344
Show(uint32_t reason,bool withAnimation)345 WMError WindowImpl::Show(uint32_t reason, bool withAnimation)
346 {
347 return WMError::WM_OK;
348 }
349
Hide(uint32_t reason,bool withAnimation,bool isFromInnerkits)350 WMError WindowImpl::Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits)
351 {
352 return WMError::WM_OK;
353 }
354
MoveTo(int32_t x,int32_t y)355 WMError WindowImpl::MoveTo(int32_t x, int32_t y)
356 {
357 return WMError::WM_OK;
358 }
359
Resize(uint32_t width,uint32_t height)360 WMError WindowImpl::Resize(uint32_t width, uint32_t height)
361 {
362 return WMError::WM_OK;
363 }
364
SetWindowGravity(WindowGravity gravity,uint32_t percent)365 WMError WindowImpl::SetWindowGravity(WindowGravity gravity, uint32_t percent)
366 {
367 return WMError::WM_OK;
368 }
369
SetKeepScreenOn(bool keepScreenOn)370 WMError WindowImpl::SetKeepScreenOn(bool keepScreenOn)
371 {
372 return WMError::WM_OK;
373 }
374
IsKeepScreenOn() const375 bool WindowImpl::IsKeepScreenOn() const
376 {
377 return false;
378 }
379
SetTurnScreenOn(bool turnScreenOn)380 WMError WindowImpl::SetTurnScreenOn(bool turnScreenOn)
381 {
382 return WMError::WM_OK;
383 }
384
IsTurnScreenOn() const385 bool WindowImpl::IsTurnScreenOn() const
386 {
387 return false;
388 }
389
SetBackgroundColor(const std::string & color)390 WMError WindowImpl::SetBackgroundColor(const std::string& color)
391 {
392 return WMError::WM_OK;
393 }
394
SetTransparent(bool isTransparent)395 WMError WindowImpl::SetTransparent(bool isTransparent)
396 {
397 return WMError::WM_OK;
398 }
399
IsTransparent() const400 bool WindowImpl::IsTransparent() const
401 {
402 return true;
403 }
404
SetBrightness(float brightness)405 WMError WindowImpl::SetBrightness(float brightness)
406 {
407 return WMError::WM_OK;
408 }
409
GetBrightness() const410 float WindowImpl::GetBrightness() const
411 {
412 return 0.0;
413 }
414
SetCallingWindow(uint32_t windowId)415 WMError WindowImpl::SetCallingWindow(uint32_t windowId)
416 {
417 return WMError::WM_OK;
418 }
419
SetPrivacyMode(bool isPrivacyMode)420 WMError WindowImpl::SetPrivacyMode(bool isPrivacyMode)
421 {
422 return WMError::WM_OK;
423 }
424
IsPrivacyMode() const425 bool WindowImpl::IsPrivacyMode() const
426 {
427 return false;
428 }
429
SetSystemPrivacyMode(bool isSystemPrivacyMode)430 void WindowImpl::SetSystemPrivacyMode(bool isSystemPrivacyMode)
431 {
432 }
433
SetSnapshotSkip(bool isSkip)434 WMError WindowImpl::SetSnapshotSkip(bool isSkip)
435 {
436 return WMError::WM_OK;
437 }
438
DisableAppWindowDecor()439 WMError WindowImpl::DisableAppWindowDecor()
440 {
441 return WMError::WM_OK;
442 }
443
Maximize()444 WMError WindowImpl::Maximize()
445 {
446 return WMError::WM_OK;
447 }
448
Minimize()449 WMError WindowImpl::Minimize()
450 {
451 return WMError::WM_OK;
452 }
453
Recover()454 WMError WindowImpl::Recover()
455 {
456 return WMError::WM_OK;
457 }
458
Close()459 WMError WindowImpl::Close()
460 {
461 return WMError::WM_OK;
462 }
463
StartMove()464 void WindowImpl::StartMove()
465 {
466 return;
467 }
468
RequestFocus() const469 WMError WindowImpl::RequestFocus() const
470 {
471 return WMError::WM_OK;
472 }
473
IsFocused() const474 bool WindowImpl::IsFocused() const
475 {
476 return true;
477 }
478
SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer> & inputEventConsumer)479 void WindowImpl::SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer)
480 {
481 return;
482 }
483
RegisterLifeCycleListener(const sptr<IWindowLifeCycle> & listener)484 WMError WindowImpl::RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
485 {
486 return WMError::WM_OK;
487 }
488
RegisterWindowChangeListener(const sptr<IWindowChangeListener> & listener)489 WMError WindowImpl::RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
490 {
491 return WMError::WM_OK;
492 }
493
UnregisterLifeCycleListener(const sptr<IWindowLifeCycle> & listener)494 WMError WindowImpl::UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener)
495 {
496 return WMError::WM_OK;
497 }
498
UnregisterWindowChangeListener(const sptr<IWindowChangeListener> & listener)499 WMError WindowImpl::UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener)
500 {
501 return WMError::WM_OK;
502 }
503
RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener> & listener)504 WMError WindowImpl::RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
505 {
506 return WMError::WM_OK;
507 }
508
UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener> & listener)509 WMError WindowImpl::UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener)
510 {
511 return WMError::WM_OK;
512 }
513
RegisterDragListener(const sptr<IWindowDragListener> & listener)514 WMError WindowImpl::RegisterDragListener(const sptr<IWindowDragListener>& listener)
515 {
516 return WMError::WM_OK;
517 }
518
UnregisterDragListener(const sptr<IWindowDragListener> & listener)519 WMError WindowImpl::UnregisterDragListener(const sptr<IWindowDragListener>& listener)
520 {
521 return WMError::WM_OK;
522 }
523
RegisterDisplayMoveListener(sptr<IDisplayMoveListener> & listener)524 WMError WindowImpl::RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
525 {
526 return WMError::WM_OK;
527 }
528
UnregisterDisplayMoveListener(sptr<IDisplayMoveListener> & listener)529 WMError WindowImpl::UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener)
530 {
531 return WMError::WM_OK;
532 }
533
RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc & func)534 void WindowImpl::RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func)
535 {
536 return;
537 }
538
RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener> & listener)539 WMError WindowImpl::RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
540 {
541 return WMError::WM_OK;
542 }
543
UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener> & listener)544 WMError WindowImpl::UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener)
545 {
546 return WMError::WM_OK;
547 }
548
RegisterTouchOutsideListener(const sptr<ITouchOutsideListener> & listener)549 WMError WindowImpl::RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
550 {
551 return WMError::WM_OK;
552 }
553
UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener> & listener)554 WMError WindowImpl::UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener)
555 {
556 return WMError::WM_OK;
557 }
558
RegisterAnimationTransitionController(const sptr<IAnimationTransitionController> & listener)559 WMError WindowImpl::RegisterAnimationTransitionController(const sptr<IAnimationTransitionController>& listener)
560 {
561 return WMError::WM_OK;
562 }
563
RegisterScreenshotListener(const sptr<IScreenshotListener> & listener)564 WMError WindowImpl::RegisterScreenshotListener(const sptr<IScreenshotListener>& listener)
565 {
566 return WMError::WM_OK;
567 }
568
UnregisterScreenshotListener(const sptr<IScreenshotListener> & listener)569 WMError WindowImpl::UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener)
570 {
571 return WMError::WM_OK;
572 }
573
RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener> & listener)574 WMError WindowImpl::RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
575 {
576 return WMError::WM_OK;
577 }
578
UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener> & listener)579 WMError WindowImpl::UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener)
580 {
581 return WMError::WM_OK;
582 }
583
RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener> & listener)584 void WindowImpl::RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
585 {
586 return;
587 }
588
UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener> & listener)589 void WindowImpl::UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener)
590 {
591 return;
592 }
593
SetAceAbilityHandler(const sptr<IAceAbilityHandler> & handler)594 void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
595 {
596 return;
597 }
598
SetRequestModeSupportInfo(uint32_t modeSupportInfo)599 void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo)
600 {
601 return;
602 }
603
ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent)604 void WindowImpl::ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
605 {
606 if (uiContent_ == nullptr) {
607 WLOGFE("ConsumeKeyEvent to uiContent failed,uiContent_ is null");
608 return;
609 }
610 uiContent_->ProcessKeyEvent(keyEvent);
611 }
612
ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)613 void WindowImpl::ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
614 {
615 if (uiContent_ == nullptr) {
616 WLOGFE("ConsumePointerEvent to uiContent failed,uiContent_ is null");
617 return;
618 }
619 (void)uiContent_->ProcessPointerEvent(pointerEvent);
620 }
621
622
RequestVsync(const std::shared_ptr<VsyncCallback> & vsyncCallback)623 void WindowImpl::RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback)
624 {
625 VsyncStation::GetInstance().RequestVsync(vsyncCallback);
626 }
627
GetVSyncPeriod()628 int64_t WindowImpl::GetVSyncPeriod()
629 {
630 return 0;
631 }
632
UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration> & configuration)633 void WindowImpl::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
634 {
635 if (uiContent_ != nullptr) {
636 WLOGFD("notify ace winId:%{public}u", GetWindowId());
637 uiContent_->UpdateConfiguration(configuration);
638 }
639 }
640
NotifyTouchDialogTarget()641 void WindowImpl::NotifyTouchDialogTarget()
642 {
643 return;
644 }
645
SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel)646 void WindowImpl::SetNeedRemoveWindowInputChannel(bool needRemoveWindowInputChannel)
647 {
648 needRemoveWindowInputChannel_ = needRemoveWindowInputChannel;
649 }
650
IsLayoutFullScreen() const651 bool WindowImpl::IsLayoutFullScreen() const
652 {
653 return true;
654 }
655
IsFullScreen() const656 bool WindowImpl::IsFullScreen() const
657 {
658 return true;
659 }
660
SetRequestedOrientation(Orientation orientation)661 void WindowImpl::SetRequestedOrientation(Orientation orientation)
662 {
663 }
664
GetRequestedOrientation()665 Orientation WindowImpl::GetRequestedOrientation()
666 {
667 return Orientation::UNSPECIFIED;
668 }
669
SetTouchHotAreas(const std::vector<Rect> & rects)670 WMError WindowImpl::SetTouchHotAreas(const std::vector<Rect>& rects)
671 {
672 return WMError::WM_OK;
673 }
GetRequestedTouchHotAreas(std::vector<Rect> & rects) const674 void WindowImpl::GetRequestedTouchHotAreas(std::vector<Rect>& rects) const
675 {
676 }
677
SetAPPWindowLabel(const std::string & label)678 WMError WindowImpl::SetAPPWindowLabel(const std::string& label)
679 {
680 if (uiContent_ == nullptr) {
681 WLOGFE("uicontent is empty");
682 return WMError::WM_ERROR_NULLPTR;
683 }
684 uiContent_->SetAppWindowTitle(label);
685 return WMError::WM_OK;
686 }
687
SetAPPWindowIcon(const std::shared_ptr<Media::PixelMap> & icon)688 WMError WindowImpl::SetAPPWindowIcon(const std::shared_ptr<Media::PixelMap>& icon)
689 {
690 if (icon == nullptr) {
691 WLOGFE("window icon is empty");
692 return WMError::WM_ERROR_NULLPTR;
693 }
694 if (uiContent_ == nullptr) {
695 WLOGFE("uicontent is empty");
696 return WMError::WM_ERROR_NULLPTR;
697 }
698 uiContent_->SetAppWindowIcon(icon);
699 return WMError::WM_OK;
700 }
701
SetCornerRadius(float cornerRadius)702 WMError WindowImpl::SetCornerRadius(float cornerRadius)
703 {
704 return WMError::WM_OK;
705 }
706
SetShadowRadius(float radius)707 WMError WindowImpl::SetShadowRadius(float radius)
708 {
709 return WMError::WM_OK;
710 }
711
SetShadowColor(std::string color)712 WMError WindowImpl::SetShadowColor(std::string color)
713 {
714 return WMError::WM_OK;
715 }
716
SetShadowOffsetX(float offsetX)717 WMError WindowImpl::SetShadowOffsetX(float offsetX)
718 {
719 return WMError::WM_OK;
720 }
721
SetShadowOffsetY(float offsetY)722 WMError WindowImpl::SetShadowOffsetY(float offsetY)
723 {
724 return WMError::WM_OK;
725 }
726
SetBlur(float radius)727 WMError WindowImpl::SetBlur(float radius)
728 {
729 return WMError::WM_OK;
730 }
731
SetBackdropBlur(float radius)732 WMError WindowImpl::SetBackdropBlur(float radius)
733 {
734 return WMError::WM_OK;
735 }
736
SetBackdropBlurStyle(WindowBlurStyle blurStyle)737 WMError WindowImpl::SetBackdropBlurStyle(WindowBlurStyle blurStyle)
738 {
739 return WMError::WM_OK;
740 }
741
NotifyMemoryLevel(int32_t level)742 WMError WindowImpl::NotifyMemoryLevel(int32_t level)
743 {
744 return WMError::WM_OK;
745 }
746
IsAllowHaveSystemSubWindow()747 bool WindowImpl::IsAllowHaveSystemSubWindow()
748 {
749 return true;
750 }
751
RaiseToAppTop()752 WmErrorCode WindowImpl::RaiseToAppTop()
753 {
754 return WmErrorCode::WM_OK;
755 }
756
RaiseAboveTarget(int32_t subWindowId)757 WmErrorCode WindowImpl::RaiseAboveTarget(int32_t subWindowId)
758 {
759 return WmErrorCode::WM_ERROR_DEVICE_NOT_SUPPORT;
760 }
761
SetAspectRatio(float ratio)762 WMError WindowImpl::SetAspectRatio(float ratio)
763 {
764 return WMError::WM_OK;
765 }
766
ResetAspectRatio()767 WMError WindowImpl::ResetAspectRatio()
768 {
769 return WMError::WM_OK;
770 }
771
GetKeyboardAnimationConfig()772 KeyboardAnimationConfig WindowImpl::GetKeyboardAnimationConfig()
773 {
774 return keyboardAnimationConfig_;
775 }
776
SetNeedDefaultAnimation(bool needDefaultAnimation)777 void WindowImpl::SetNeedDefaultAnimation(bool needDefaultAnimation)
778 {
779 return;
780 }
781
SetViewportConfig(const Ace::ViewportConfig & config)782 void WindowImpl::SetViewportConfig(const Ace::ViewportConfig& config)
783 {
784 bool isUpdate = false;
785 if (width_ != config.Width()) {
786 width_ = config.Width();
787 isUpdate = true;
788 }
789 if (height_ != config.Height()) {
790 height_ = config.Height();
791 isUpdate = true;
792 }
793 if (abs(density_ - config.Density()) >= 0.000001) {
794 density_ = config.Density();
795 isUpdate = true;
796 }
797 if (orientation_ != config.Orientation()) {
798 orientation_ = config.Orientation();
799 isUpdate = true;
800 }
801 if (isUpdate) {
802 UpdateViewportConfig();
803 }
804 }
805
UpdateViewportConfig()806 void WindowImpl::UpdateViewportConfig()
807 {
808 Ace::ViewportConfig config;
809 config.SetSize(width_, height_);
810 config.SetPosition(0, 0);
811 config.SetDensity(density_);
812 config.SetOrientation(orientation_);
813 if (uiContent_ != nullptr) {
814 uiContent_->UpdateViewportConfig(config, WindowSizeChangeReason::UNDEFINED);
815 }
816
817 }
818
SetOrientation(Orientation orientation)819 void WindowImpl::SetOrientation(Orientation orientation)
820 {
821 WLOGFD("SetOrientation : orientation=%{public}d", static_cast<int32_t>(orientation));
822 if (orientation_ == static_cast<int32_t>(orientation)) {
823 return;
824 }
825 orientation_ = static_cast<int32_t>(orientation);
826 UpdateViewportConfig();
827 }
828
SetSize(int32_t width,int32_t height)829 void WindowImpl::SetSize(int32_t width, int32_t height)
830 {
831 WLOGFD("SetSize : width=%{public}d, height=%{public}d", width, height);
832 if (width_ == width && height_ == height) {
833 return;
834 }
835 width_ = width;
836 height_ = height;
837 UpdateViewportConfig();
838 }
839
SetDensity(float density)840 void WindowImpl::SetDensity(float density)
841 {
842 WLOGFD("SetDensity : density=%{public}f", density);
843 if (abs(density_ - density) <= 0.000001) { // 0.000001: near zero.
844 return;
845 }
846 density_ = density;
847 UpdateViewportConfig();
848 }
849
SetResizeByDragEnabled(bool dragEnabled)850 WMError WindowImpl::SetResizeByDragEnabled(bool dragEnabled)
851 {
852 return WMError::WM_OK;
853 }
854
SetRaiseByClickEnabled(bool raiseEnabled)855 WMError WindowImpl::SetRaiseByClickEnabled(bool raiseEnabled)
856 {
857 return WMError::WM_OK;
858 }
859 } // namespace Rosen
860 } // namespace OHOS
861