• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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_node.h"
17 #include "window_helper.h"
18 #include "window_manager_hilog.h"
19 
20 namespace OHOS {
21 namespace Rosen {
22 namespace {
23     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowNode"};
24 }
25 
~WindowNode()26 WindowNode::~WindowNode()
27 {
28     WLOGI("~WindowNode id:%{public}u", GetWindowId());
29 }
30 
SetDisplayId(DisplayId displayId)31 void WindowNode::SetDisplayId(DisplayId displayId)
32 {
33     property_->SetDisplayId(displayId);
34 }
35 
SetEntireWindowTouchHotArea(const Rect & rect)36 void WindowNode::SetEntireWindowTouchHotArea(const Rect& rect)
37 {
38     entireWindowTouchHotArea_ = rect;
39 }
40 
SetEntireWindowPointerHotArea(const Rect & rect)41 void WindowNode::SetEntireWindowPointerHotArea(const Rect& rect)
42 {
43     entireWindowPointerHotArea_ = rect;
44 }
45 
SetWindowRect(const Rect & rect)46 void WindowNode::SetWindowRect(const Rect& rect)
47 {
48     property_->SetWindowRect(rect);
49 }
50 
SetDecorEnable(bool decorEnable)51 void WindowNode::SetDecorEnable(bool decorEnable)
52 {
53     property_->SetDecorEnable(decorEnable);
54 }
55 
SetDecoStatus(bool decoStatus)56 void WindowNode::SetDecoStatus(bool decoStatus)
57 {
58     property_->SetDecoStatus(decoStatus);
59 }
60 
SetRequestRect(const Rect & rect)61 void WindowNode::SetRequestRect(const Rect& rect)
62 {
63     property_->SetRequestRect(rect);
64 }
65 
SetWindowProperty(const sptr<WindowProperty> & property)66 void WindowNode::SetWindowProperty(const sptr<WindowProperty>& property)
67 {
68     property_ = property;
69 }
70 
SetSystemBarProperty(WindowType type,const SystemBarProperty & property)71 void WindowNode::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
72 {
73     property_->SetSystemBarProperty(type, property);
74 }
75 
SetWindowMode(WindowMode mode)76 void WindowNode::SetWindowMode(WindowMode mode)
77 {
78     property_->SetWindowMode(mode);
79 }
80 
SetBrightness(float brightness)81 void WindowNode::SetBrightness(float brightness)
82 {
83     property_->SetBrightness(brightness);
84 }
85 
SetFocusable(bool focusable)86 void WindowNode::SetFocusable(bool focusable)
87 {
88     property_->SetFocusable(focusable);
89 }
90 
SetTouchable(bool touchable)91 void WindowNode::SetTouchable(bool touchable)
92 {
93     property_->SetTouchable(touchable);
94 }
95 
SetTurnScreenOn(bool turnScreenOn)96 void WindowNode::SetTurnScreenOn(bool turnScreenOn)
97 {
98     property_->SetTurnScreenOn(turnScreenOn);
99 }
100 
SetKeepScreenOn(bool keepScreenOn)101 void WindowNode::SetKeepScreenOn(bool keepScreenOn)
102 {
103     property_->SetKeepScreenOn(keepScreenOn);
104 }
105 
SetCallingWindow(uint32_t windowId)106 void WindowNode::SetCallingWindow(uint32_t windowId)
107 {
108     property_->SetCallingWindow(windowId);
109 }
110 
GetCallingWindow() const111 uint32_t WindowNode::GetCallingWindow() const
112 {
113     return property_->GetCallingWindow();
114 }
115 
SetWindowSizeChangeReason(WindowSizeChangeReason reason)116 void WindowNode::SetWindowSizeChangeReason(WindowSizeChangeReason reason)
117 {
118     windowSizeChangeReason_ = reason;
119 }
120 
SetRequestedOrientation(Orientation orientation)121 void WindowNode::SetRequestedOrientation(Orientation orientation)
122 {
123     property_->SetRequestedOrientation(orientation);
124 }
125 
SetShowingDisplays(const std::vector<DisplayId> & displayIdVec)126 void WindowNode::SetShowingDisplays(const std::vector<DisplayId>& displayIdVec)
127 {
128     showingDisplays_.clear();
129     showingDisplays_.assign(displayIdVec.begin(), displayIdVec.end());
130 }
131 
SetModeSupportInfo(uint32_t modeSupportInfo)132 void WindowNode::SetModeSupportInfo(uint32_t modeSupportInfo)
133 {
134     property_->SetModeSupportInfo(modeSupportInfo);
135 }
136 
ResetWindowSizeChangeReason()137 void WindowNode::ResetWindowSizeChangeReason()
138 {
139     windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
140 }
141 
GetWindowToken() const142 const sptr<IWindow>& WindowNode::GetWindowToken() const
143 {
144     return windowToken_;
145 }
146 
SetWindowToken(sptr<IWindow> window)147 void WindowNode::SetWindowToken(sptr<IWindow> window)
148 {
149     windowToken_ = window;
150 }
151 
SetInputEventCallingPid(int32_t pid)152 void WindowNode::SetInputEventCallingPid(int32_t pid)
153 {
154     inputCallingPid_ = pid;
155 }
156 
SetCallingPid(int32_t pid)157 void WindowNode::SetCallingPid(int32_t pid)
158 {
159     callingPid_ = pid;
160     SetInputEventCallingPid(pid);
161 }
162 
SetCallingUid(int32_t uid)163 void WindowNode::SetCallingUid(int32_t uid)
164 {
165     callingUid_ = uid;
166 }
167 
SetDragType(DragType dragType)168 void WindowNode::SetDragType(DragType dragType)
169 {
170     property_->SetDragType(dragType);
171 }
172 
SetOriginRect(const Rect & rect)173 void WindowNode::SetOriginRect(const Rect& rect)
174 {
175     property_->SetOriginRect(rect);
176 }
177 
SetTouchHotAreas(const std::vector<Rect> & rects)178 void WindowNode::SetTouchHotAreas(const std::vector<Rect>& rects)
179 {
180     touchHotAreas_ = rects;
181 }
182 
SetPointerHotAreas(const std::vector<Rect> & rects)183 void WindowNode::SetPointerHotAreas(const std::vector<Rect>& rects)
184 {
185     pointerHotAreas_ = rects;
186 }
187 
SetWindowSizeLimits(const WindowSizeLimits & sizeLimits)188 void WindowNode::SetWindowSizeLimits(const WindowSizeLimits& sizeLimits)
189 {
190     property_->SetSizeLimits(sizeLimits);
191 }
192 
SetWindowUpdatedSizeLimits(const WindowSizeLimits & sizeLimits)193 void WindowNode::SetWindowUpdatedSizeLimits(const WindowSizeLimits& sizeLimits)
194 {
195     property_->SetUpdatedSizeLimits(sizeLimits);
196 }
197 
ComputeTransform()198 void WindowNode::ComputeTransform()
199 {
200     property_->ComputeTransform();
201 }
202 
SetTransform(const Transform & trans)203 void WindowNode::SetTransform(const Transform& trans)
204 {
205     property_->SetTransform(trans);
206 }
207 
GetZoomTransform() const208 Transform WindowNode::GetZoomTransform() const
209 {
210     return property_->GetZoomTransform();
211 }
212 
UpdateZoomTransform(const Transform & trans,bool isDisplayZoomOn)213 void WindowNode::UpdateZoomTransform(const Transform& trans, bool isDisplayZoomOn)
214 {
215     property_->SetZoomTransform(trans);
216     property_->SetDisplayZoomState(isDisplayZoomOn);
217     if (windowToken_) {
218         windowToken_->UpdateZoomTransform(trans, isDisplayZoomOn);
219     }
220 }
221 
GetWindowSizeLimits() const222 WindowSizeLimits WindowNode::GetWindowSizeLimits() const
223 {
224     return property_->GetSizeLimits();
225 }
226 
GetWindowUpdatedSizeLimits() const227 WindowSizeLimits WindowNode::GetWindowUpdatedSizeLimits() const
228 {
229     return property_->GetUpdatedSizeLimits();
230 }
231 
GetDragType() const232 DragType WindowNode::GetDragType() const
233 {
234     return property_->GetDragType();
235 }
236 
GetStretchable() const237 bool WindowNode::GetStretchable() const
238 {
239     return property_->GetStretchable();
240 }
241 
GetOriginRect() const242 const Rect& WindowNode::GetOriginRect() const
243 {
244     return property_->GetOriginRect();
245 }
246 
GetDisplayId() const247 DisplayId WindowNode::GetDisplayId() const
248 {
249     return property_->GetDisplayId();
250 }
251 
GetWindowName() const252 const std::string& WindowNode::GetWindowName() const
253 {
254     return property_->GetWindowName();
255 }
256 
GetWindowId() const257 uint32_t WindowNode::GetWindowId() const
258 {
259     return property_->GetWindowId();
260 }
261 
GetParentId() const262 uint32_t WindowNode::GetParentId() const
263 {
264     return property_->GetParentId();
265 }
266 
GetEntireWindowTouchHotArea() const267 Rect WindowNode::GetEntireWindowTouchHotArea() const
268 {
269     return entireWindowTouchHotArea_;
270 }
271 
GetEntireWindowPointerHotArea() const272 Rect WindowNode::GetEntireWindowPointerHotArea() const
273 {
274     return entireWindowPointerHotArea_;
275 }
276 
GetWindowRect() const277 Rect WindowNode::GetWindowRect() const
278 {
279     return property_->GetWindowRect();
280 }
281 
GetDecoStatus() const282 bool WindowNode::GetDecoStatus() const
283 {
284     return property_->GetDecoStatus();
285 }
286 
GetRequestRect() const287 Rect WindowNode::GetRequestRect() const
288 {
289     return property_->GetRequestRect();
290 }
291 
GetWindowType() const292 WindowType WindowNode::GetWindowType() const
293 {
294     return property_->GetWindowType();
295 }
296 
GetWindowMode() const297 WindowMode WindowNode::GetWindowMode() const
298 {
299     return property_->GetWindowMode();
300 }
301 
EnableDefaultAnimation(bool animationPlayed)302 bool WindowNode::EnableDefaultAnimation(bool animationPlayed)
303 {
304     // system config enabled && not in remote animation && not custom animation && not crash
305     bool defaultAnimation = property_->GetAnimationFlag() == (static_cast<uint32_t>(WindowAnimation::DEFAULT));
306     return ((!animationPlayed) && (defaultAnimation) && (!isAppCrash_));
307 }
308 
GetBrightness() const309 float WindowNode::GetBrightness() const
310 {
311     return property_->GetBrightness();
312 }
313 
IsTurnScreenOn() const314 bool WindowNode::IsTurnScreenOn() const
315 {
316     return property_->IsTurnScreenOn();
317 }
318 
IsKeepScreenOn() const319 bool WindowNode::IsKeepScreenOn() const
320 {
321     return property_->IsKeepScreenOn();
322 }
323 
GetWindowFlags() const324 uint32_t WindowNode::GetWindowFlags() const
325 {
326     return property_->GetWindowFlags();
327 }
328 
GetWindowProperty() const329 const sptr<WindowProperty>& WindowNode::GetWindowProperty() const
330 {
331     return property_;
332 }
333 
GetInputEventCallingPid() const334 int32_t WindowNode::GetInputEventCallingPid() const
335 {
336     return inputCallingPid_;
337 }
338 
GetCallingPid() const339 int32_t WindowNode::GetCallingPid() const
340 {
341     return callingPid_;
342 }
343 
GetCallingUid() const344 int32_t WindowNode::GetCallingUid() const
345 {
346     return callingUid_;
347 }
348 
GetSystemBarProperty() const349 const std::unordered_map<WindowType, SystemBarProperty>& WindowNode::GetSystemBarProperty() const
350 {
351     return property_->GetSystemBarProperty();
352 }
353 
IsSplitMode() const354 bool WindowNode::IsSplitMode() const
355 {
356     return (property_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY ||
357         property_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
358 }
359 
GetWindowSizeChangeReason() const360 WindowSizeChangeReason WindowNode::GetWindowSizeChangeReason() const
361 {
362     return windowSizeChangeReason_;
363 }
364 
GetRequestedOrientation() const365 Orientation WindowNode::GetRequestedOrientation() const
366 {
367     return property_->GetRequestedOrientation();
368 }
369 
GetShowingDisplays() const370 std::vector<DisplayId> WindowNode::GetShowingDisplays() const
371 {
372     return showingDisplays_;
373 }
374 
GetModeSupportInfo() const375 uint32_t WindowNode::GetModeSupportInfo() const
376 {
377     return property_->GetModeSupportInfo();
378 }
379 
GetTouchHotAreas(std::vector<Rect> & rects) const380 void WindowNode::GetTouchHotAreas(std::vector<Rect>& rects) const
381 {
382     rects = touchHotAreas_;
383 }
384 
GetPointerHotAreas(std::vector<Rect> & rects) const385 void WindowNode::GetPointerHotAreas(std::vector<Rect>& rects) const
386 {
387     rects = pointerHotAreas_;
388 }
389 
GetAccessTokenId() const390 uint32_t WindowNode::GetAccessTokenId() const
391 {
392     return property_->GetAccessTokenId();
393 }
394 
SetSnapshot(std::shared_ptr<Media::PixelMap> pixelMap)395 void WindowNode::SetSnapshot(std::shared_ptr<Media::PixelMap> pixelMap)
396 {
397     snapshot_ = pixelMap;
398 }
399 
GetSnapshot()400 std::shared_ptr<Media::PixelMap> WindowNode::GetSnapshot()
401 {
402     return snapshot_;
403 }
404 
SetAspectRatio(float ratio)405 void WindowNode::SetAspectRatio(float ratio)
406 {
407     property_->SetAspectRatio(ratio);
408 }
409 
GetAspectRatio() const410 float WindowNode::GetAspectRatio() const
411 {
412     return property_->GetAspectRatio();
413 }
414 
SetWindowGravity(WindowGravity gravity,uint32_t percent)415 void WindowNode::SetWindowGravity(WindowGravity gravity, uint32_t percent)
416 {
417     property_->SetWindowGravity(gravity, percent);
418 }
419 
GetWindowGravity(WindowGravity & gravity,uint32_t & percent) const420 void WindowNode::GetWindowGravity(WindowGravity& gravity, uint32_t& percent) const
421 {
422     property_->GetWindowGravity(gravity, percent);
423 }
424 } // namespace Rosen
425 } // namespace OHOS
426