• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_option.h"
17 
18 #include "window_helper.h"
19 #include "wm_common.h"
20 
21 namespace OHOS {
22 namespace Rosen {
WindowOption()23 WindowOption::WindowOption(): windowTag_(WindowTag::SYSTEM_WINDOW)
24 {
25     AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
26 }
27 
SetWindowMode(WindowMode mode)28 void WindowOption::SetWindowMode(WindowMode mode)
29 {
30     if (!WindowHelper::IsValidWindowMode(mode)) {
31         return;
32     }
33     mode_ = mode;
34 }
35 
SetWindowRect(const Rect & rect)36 void WindowOption::SetWindowRect(const Rect& rect)
37 {
38     windowRect_ = rect;
39 }
40 
SetWindowType(WindowType type)41 void WindowOption::SetWindowType(WindowType type)
42 {
43     type_ = type;
44 }
45 
SetParentId(uint32_t parentId)46 void WindowOption::SetParentId(uint32_t parentId)
47 {
48     parentId_ = parentId;
49 }
50 
SetDisplayId(DisplayId displayId)51 void WindowOption::SetDisplayId(DisplayId displayId)
52 {
53     displayId_ = displayId;
54 }
55 
SetFocusable(bool isFocusable)56 void WindowOption::SetFocusable(bool isFocusable)
57 {
58     focusable_ = isFocusable;
59 }
60 
SetTouchable(bool isTouchable)61 void WindowOption::SetTouchable(bool isTouchable)
62 {
63     touchable_ = isTouchable;
64 }
65 
SetWindowName(const std::string & windowName)66 void WindowOption::SetWindowName(const std::string& windowName)
67 {
68     windowName_ = windowName;
69 }
70 
SetWindowFlags(uint32_t flags)71 void WindowOption::SetWindowFlags(uint32_t flags)
72 {
73     flags_ = flags;
74 }
75 
RemoveWindowFlag(WindowFlag flag)76 void WindowOption::RemoveWindowFlag(WindowFlag flag)
77 {
78     flags_ &= ~(static_cast<uint32_t>(flag));
79 }
80 
AddWindowFlag(WindowFlag flag)81 void WindowOption::AddWindowFlag(WindowFlag flag)
82 {
83     flags_ |= static_cast<uint32_t>(flag);
84 }
85 
SetWindowTag(WindowTag windowTag)86 void WindowOption::SetWindowTag(WindowTag windowTag)
87 {
88     windowTag_ = windowTag;
89 }
90 
SetSystemBarProperty(WindowType type,const SystemBarProperty & property)91 void WindowOption::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
92 {
93     if (type == WindowType::WINDOW_TYPE_STATUS_BAR || type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) {
94         sysBarPropMap_[type] = property;
95     }
96 }
97 
SetWindowSessionType(WindowSessionType sessionType)98 void WindowOption::SetWindowSessionType(WindowSessionType sessionType)
99 {
100     sessionType_ = sessionType;
101 }
102 
SetHitOffset(int32_t x,int32_t y)103 void WindowOption::SetHitOffset(int32_t x, int32_t y)
104 {
105     hitOffset_.x = x;
106     hitOffset_.y = y;
107 }
108 
IsTurnScreenOn() const109 bool WindowOption::IsTurnScreenOn() const
110 {
111     return turnScreenOn_;
112 }
113 
SetTurnScreenOn(bool turnScreenOn)114 void WindowOption::SetTurnScreenOn(bool turnScreenOn)
115 {
116     turnScreenOn_ = turnScreenOn;
117 }
118 
IsKeepScreenOn() const119 bool WindowOption::IsKeepScreenOn() const
120 {
121     return keepScreenOn_;
122 }
123 
SetKeepScreenOn(bool keepScreenOn)124 void WindowOption::SetKeepScreenOn(bool keepScreenOn)
125 {
126     keepScreenOn_ = keepScreenOn;
127 }
128 
SetCallingWindow(uint32_t windowId)129 void WindowOption::SetCallingWindow(uint32_t windowId)
130 {
131     callingWindow_ = windowId;
132 }
133 
SetRequestedOrientation(Orientation orientation)134 void WindowOption::SetRequestedOrientation(Orientation orientation)
135 {
136     requestedOrientation_ = orientation;
137 }
138 
SetBrightness(float brightness)139 void WindowOption::SetBrightness(float brightness)
140 {
141     brightness_ = brightness;
142 }
143 
SetMainHandlerAvailable(bool isMainHandlerAvailable)144 void WindowOption::SetMainHandlerAvailable(bool isMainHandlerAvailable)
145 {
146     isMainHandlerAvailable_ = isMainHandlerAvailable;
147 }
148 
SetSubWindowDecorEnable(bool subWindowDecorEnable)149 void WindowOption::SetSubWindowDecorEnable(bool subWindowDecorEnable)
150 {
151     subWindowDecorEnable_ = subWindowDecorEnable;
152 }
153 
SetSubWindowTitle(const std::string & subWindowTitle)154 void WindowOption::SetSubWindowTitle(const std::string& subWindowTitle)
155 {
156     subWindowTitle_ = subWindowTitle;
157 }
158 
SetSubWindowMaximizeSupported(bool maximizeSupported)159 void WindowOption::SetSubWindowMaximizeSupported(bool maximizeSupported)
160 {
161     subWindowMaximizeSupported_ = maximizeSupported;
162 }
163 
SetOnlySupportSceneBoard(bool onlySupportSceneBoard)164 void WindowOption::SetOnlySupportSceneBoard(bool onlySupportSceneBoard)
165 {
166     onlySupportSceneBoard_ = onlySupportSceneBoard;
167 }
168 
SetWindowTopmost(bool isTopmost)169 void WindowOption::SetWindowTopmost(bool isTopmost)
170 {
171     isTopmost_ = isTopmost;
172 }
173 
SetSubWindowZLevel(int32_t zLevel)174 void WindowOption::SetSubWindowZLevel(int32_t zLevel)
175 {
176     zLevel_ = zLevel;
177 }
178 
GetSubWindowZLevel() const179 int32_t WindowOption::GetSubWindowZLevel() const
180 {
181     return zLevel_;
182 }
183 
SetZIndex(int32_t zIndex)184 void WindowOption::SetZIndex(int32_t zIndex)
185 {
186     zIndex_ = zIndex;
187 }
188 
GetZIndex() const189 int32_t WindowOption::GetZIndex() const
190 {
191     return zIndex_;
192 }
193 
GetWindowMode() const194 WindowMode WindowOption::GetWindowMode() const
195 {
196     return mode_;
197 }
198 
GetWindowType() const199 WindowType WindowOption::GetWindowType() const
200 {
201     return type_;
202 }
203 
GetWindowRect() const204 Rect WindowOption::GetWindowRect() const
205 {
206     return windowRect_;
207 }
208 
GetWindowTag() const209 WindowTag WindowOption::GetWindowTag() const
210 {
211     return windowTag_;
212 }
213 
GetParentId() const214 uint32_t WindowOption::GetParentId() const
215 {
216     return parentId_;
217 }
218 
GetDisplayId() const219 DisplayId WindowOption::GetDisplayId() const
220 {
221     return displayId_;
222 }
223 
GetWindowFlags() const224 uint32_t WindowOption::GetWindowFlags() const
225 {
226     return flags_;
227 }
228 
GetTouchable() const229 bool WindowOption::GetTouchable() const
230 {
231     return touchable_;
232 }
233 
GetFocusable() const234 bool WindowOption::GetFocusable() const
235 {
236     return focusable_;
237 }
238 
GetHitOffset() const239 const PointInfo& WindowOption::GetHitOffset() const
240 {
241     return hitOffset_;
242 }
243 
GetWindowName() const244 const std::string& WindowOption::GetWindowName() const
245 {
246     return windowName_;
247 }
248 
GetWindowSessionType() const249 WindowSessionType WindowOption::GetWindowSessionType() const
250 {
251     return sessionType_;
252 }
253 
GetMainHandlerAvailable() const254 bool WindowOption::GetMainHandlerAvailable() const
255 {
256     return isMainHandlerAvailable_;
257 }
258 
GetSystemBarProperty() const259 const std::unordered_map<WindowType, SystemBarProperty>& WindowOption::GetSystemBarProperty() const
260 {
261     return sysBarPropMap_;
262 }
263 
GetOnlySupportSceneBoard() const264 bool WindowOption::GetOnlySupportSceneBoard() const
265 {
266     return onlySupportSceneBoard_;
267 }
268 
GetBrightness() const269 float WindowOption::GetBrightness() const
270 {
271     return brightness_;
272 }
273 
GetRequestedOrientation() const274 Orientation WindowOption::GetRequestedOrientation() const
275 {
276     return requestedOrientation_;
277 }
278 
GetCallingWindow() const279 uint32_t WindowOption::GetCallingWindow() const
280 {
281     return callingWindow_;
282 }
283 
GetSubWindowDecorEnable() const284 bool WindowOption::GetSubWindowDecorEnable() const
285 {
286     return subWindowDecorEnable_;
287 }
288 
GetSubWindowTitle() const289 std::string WindowOption::GetSubWindowTitle() const
290 {
291     return subWindowTitle_;
292 }
293 
GetWindowTopmost() const294 bool WindowOption::GetWindowTopmost() const
295 {
296     return isTopmost_;
297 }
298 
GetSubWindowMaximizeSupported() const299 bool WindowOption::GetSubWindowMaximizeSupported() const
300 {
301     return subWindowMaximizeSupported_;
302 }
303 
SetSubWindowOutlineEnabled(bool outlineEnabled)304 void WindowOption::SetSubWindowOutlineEnabled(bool outlineEnabled)
305 {
306     subWindowOutlineEnabled_ = outlineEnabled;
307 }
308 
IsSubWindowOutlineEnabled() const309 bool WindowOption::IsSubWindowOutlineEnabled() const
310 {
311     return subWindowOutlineEnabled_;
312 }
313 } // namespace Rosen
314 } // namespace OHOS
315 
316