1 /*
2 * Copyright (c) 2021 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_agent.h"
17 #include "window_manager_hilog.h"
18 #include "wm_common.h"
19
20 namespace OHOS {
21 namespace Rosen {
22 namespace {
23 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAgent"};
24 }
25
WindowAgent(sptr<WindowImpl> & windowImpl)26 WindowAgent::WindowAgent(sptr<WindowImpl>& windowImpl)
27 {
28 window_ = windowImpl;
29 }
30
UpdateWindowRect(const struct Rect & rect,WindowSizeChangeReason reason)31 void WindowAgent::UpdateWindowRect(const struct Rect& rect, WindowSizeChangeReason reason)
32 {
33 if (window_ == nullptr) {
34 WLOGFE("window_ is nullptr");
35 return;
36 }
37 window_->UpdateRect(rect, reason);
38 }
39
UpdateWindowMode(WindowMode mode)40 void WindowAgent::UpdateWindowMode(WindowMode mode)
41 {
42 if (window_ == nullptr) {
43 WLOGFE("window_ is nullptr");
44 return;
45 }
46 window_->UpdateMode(mode);
47 }
48
UpdateFocusStatus(bool focused)49 void WindowAgent::UpdateFocusStatus(bool focused)
50 {
51 if (window_ == nullptr) {
52 WLOGFE("window_ is nullptr");
53 return;
54 }
55 window_->UpdateFocusStatus(focused);
56 }
57
UpdateAvoidArea(const std::vector<Rect> & avoidArea)58 void WindowAgent::UpdateAvoidArea(const std::vector<Rect>& avoidArea)
59 {
60 if (window_ == nullptr) {
61 WLOGFE("window_ is nullptr");
62 return;
63 }
64 window_->UpdateAvoidArea(avoidArea);
65 }
66
UpdateWindowState(WindowState state)67 void WindowAgent::UpdateWindowState(WindowState state)
68 {
69 if (window_ == nullptr) {
70 WLOGFE("window_ is nullptr");
71 return;
72 }
73 window_->UpdateWindowState(state);
74 }
75
UpdateWindowDragInfo(const PointInfo & point,DragEvent event)76 void WindowAgent::UpdateWindowDragInfo(const PointInfo& point, DragEvent event)
77 {
78 if (window_ == nullptr) {
79 WLOGFE("window is null");
80 return;
81 }
82 window_->UpdateDragEvent(point, event);
83 }
84
UpdateDisplayId(DisplayId from,DisplayId to)85 void WindowAgent::UpdateDisplayId(DisplayId from, DisplayId to)
86 {
87 if (window_ == nullptr) {
88 WLOGFE("window is null");
89 return;
90 }
91 window_->UpdateDisplayId(from, to);
92 }
93
UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo> & info)94 void WindowAgent::UpdateOccupiedAreaChangeInfo(const sptr<OccupiedAreaChangeInfo>& info)
95 {
96 if (window_ == nullptr) {
97 WLOGFE("window is null");
98 return;
99 }
100 window_->UpdateOccupiedAreaChangeInfo(info);
101 }
102
UpdateActiveStatus(bool isActive)103 void WindowAgent::UpdateActiveStatus(bool isActive)
104 {
105 if (window_ == nullptr) {
106 WLOGFE("window is null");
107 return;
108 }
109 window_->UpdateActiveStatus(isActive);
110 }
111 } // namespace Rosen
112 } // namespace OHOS
113