• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "screen_group.h"
17 
18 #include <new>
19 
20 #include "class_var_definition.h"
21 #include "display_manager_adapter.h"
22 #include "screen_group_info.h"
23 #include "screen_info.h"
24 #include "singleton_container.h"
25 #include "window_manager_hilog.h"
26 
27 namespace OHOS::Rosen {
28 class ScreenGroup::Impl : public RefBase {
29 public:
Impl(sptr<ScreenGroupInfo> info)30     explicit Impl(sptr<ScreenGroupInfo> info)
31     {
32         screenGroupInfo_ = info;
33     }
34     ~Impl() = default;
35 
36     DEFINE_VAR_FUNC_GET_SET_WITH_LOCK(sptr<ScreenGroupInfo>, ScreenGroupInfo, screenGroupInfo);
37 };
38 
ScreenGroup(sptr<ScreenGroupInfo> info)39 ScreenGroup::ScreenGroup(sptr<ScreenGroupInfo> info)
40     : Screen(info), pImpl_(new Impl(info))
41 {
42 }
43 
UpdateScreenGroupInfo(sptr<ScreenGroupInfo> info) const44 void ScreenGroup::UpdateScreenGroupInfo(sptr<ScreenGroupInfo> info) const
45 {
46     if (info == nullptr) {
47         TLOGE(WmsLogTag::DMS, "ScreenGroupInfo is nullptr.");
48         return;
49     }
50     Screen::UpdateScreenInfo(info);
51     pImpl_->SetScreenGroupInfo(info);
52 }
53 
UpdateScreenGroupInfo() const54 void ScreenGroup::UpdateScreenGroupInfo() const
55 {
56     auto screenInfo = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenGroupInfoById(GetId());
57     UpdateScreenGroupInfo(screenInfo);
58 }
59 
~ScreenGroup()60 ScreenGroup::~ScreenGroup()
61 {
62 }
63 
GetCombination() const64 ScreenCombination ScreenGroup::GetCombination() const
65 {
66     UpdateScreenGroupInfo();
67     return pImpl_->GetScreenGroupInfo()->GetCombination();
68 }
69 
GetChildIds() const70 std::vector<ScreenId> ScreenGroup::GetChildIds() const
71 {
72     UpdateScreenGroupInfo();
73     return pImpl_->GetScreenGroupInfo()->GetChildren();
74 }
75 
GetChildPositions() const76 std::vector<Point> ScreenGroup::GetChildPositions() const
77 {
78     UpdateScreenGroupInfo();
79     return pImpl_->GetScreenGroupInfo()->GetPosition();
80 }
81 } // namespace OHOS::Rosen