• 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 
SetWindowType(WindowType type)28 void WindowOption::SetWindowType(WindowType type)
29 {
30     type_ = type;
31 }
32 
SetWindowMode(WindowMode mode)33 void WindowOption::SetWindowMode(WindowMode mode)
34 {
35     if (!WindowHelper::IsValidWindowMode(mode)) {
36         return;
37     }
38     mode_ = mode;
39 }
40 
SetFocusable(bool isFocusable)41 void WindowOption::SetFocusable(bool isFocusable)
42 {
43     focusable_ = isFocusable;
44 }
45 
SetTouchable(bool isTouchable)46 void WindowOption::SetTouchable(bool isTouchable)
47 {
48     touchable_ = isTouchable;
49 }
50 
SetDisplayId(DisplayId displayId)51 void WindowOption::SetDisplayId(DisplayId displayId)
52 {
53     displayId_ = displayId;
54 }
55 
SetParentId(uint32_t parentId)56 void WindowOption::SetParentId(uint32_t parentId)
57 {
58     parentId_ = parentId;
59 }
60 
SetWindowName(const std::string & windowName)61 void WindowOption::SetWindowName(const std::string& windowName)
62 {
63     windowName_ = windowName;
64 }
65 
AddWindowFlag(WindowFlag flag)66 void WindowOption::AddWindowFlag(WindowFlag flag)
67 {
68     flags_ |= static_cast<uint32_t>(flag);
69 }
70 
RemoveWindowFlag(WindowFlag flag)71 void WindowOption::RemoveWindowFlag(WindowFlag flag)
72 {
73     flags_ &= ~(static_cast<uint32_t>(flag));
74 }
75 
SetWindowFlags(uint32_t flags)76 void WindowOption::SetWindowFlags(uint32_t flags)
77 {
78     flags_ = flags;
79 }
80 
SetSystemBarProperty(WindowType type,const SystemBarProperty & property)81 void WindowOption::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
82 {
83     if (type == WindowType::WINDOW_TYPE_STATUS_BAR || type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) {
84         sysBarPropMap_[type] = property;
85     }
86 }
87 
GetWindowRect() const88 Rect WindowOption::GetWindowRect() const
89 {
90     return windowRect_;
91 }
GetWindowType() const92 WindowType WindowOption::GetWindowType() const
93 {
94     return type_;
95 }
96 
GetWindowMode() const97 WindowMode WindowOption::GetWindowMode() const
98 {
99     return mode_;
100 }
101 
GetFocusable() const102 bool WindowOption::GetFocusable() const
103 {
104     return focusable_;
105 }
GetTouchable() const106 bool WindowOption::GetTouchable() const
107 {
108     return touchable_;
109 }
110 
GetDisplayId() const111 DisplayId WindowOption::GetDisplayId() const
112 {
113     return displayId_;
114 }
115 
GetParentId() const116 uint32_t WindowOption::GetParentId() const
117 {
118     return parentId_;
119 }
120 
GetWindowName() const121 const std::string& WindowOption::GetWindowName() const
122 {
123     return windowName_;
124 }
125 
GetWindowFlags() const126 uint32_t WindowOption::GetWindowFlags() const
127 {
128     return flags_;
129 }
130 
SetHitOffset(int32_t x,int32_t y)131 void WindowOption::SetHitOffset(int32_t x, int32_t y)
132 {
133     hitOffset_.x = x;
134     hitOffset_.y = y;
135 }
136 
SetWindowTag(WindowTag windowTag)137 void WindowOption::SetWindowTag(WindowTag windowTag)
138 {
139     windowTag_ = windowTag;
140 }
141 
GetWindowTag() const142 WindowTag WindowOption::GetWindowTag() const
143 {
144     return windowTag_;
145 }
146 
SetWindowSessionType(WindowSessionType sessionType)147 void WindowOption::SetWindowSessionType(WindowSessionType sessionType)
148 {
149     sessionType_ = sessionType;
150 }
151 
GetWindowSessionType() const152 WindowSessionType WindowOption::GetWindowSessionType() const
153 {
154     return sessionType_;
155 }
156 
SetMainHandlerAvailable(bool isMainHandlerAvailable)157 void WindowOption::SetMainHandlerAvailable(bool isMainHandlerAvailable)
158 {
159     isMainHandlerAvailable_ = isMainHandlerAvailable;
160 }
161 
GetMainHandlerAvailable() const162 bool WindowOption::GetMainHandlerAvailable() const
163 {
164     return isMainHandlerAvailable_;
165 }
166 
GetHitOffset() const167 const PointInfo& WindowOption::GetHitOffset() const
168 {
169     return hitOffset_;
170 }
171 
GetSystemBarProperty() const172 const std::unordered_map<WindowType, SystemBarProperty>& WindowOption::GetSystemBarProperty() const
173 {
174     return sysBarPropMap_;
175 }
176 
SetKeepScreenOn(bool keepScreenOn)177 void WindowOption::SetKeepScreenOn(bool keepScreenOn)
178 {
179     keepScreenOn_ = keepScreenOn;
180 }
181 
IsKeepScreenOn() const182 bool WindowOption::IsKeepScreenOn() const
183 {
184     return keepScreenOn_;
185 }
186 
SetTurnScreenOn(bool turnScreenOn)187 void WindowOption::SetTurnScreenOn(bool turnScreenOn)
188 {
189     turnScreenOn_ = turnScreenOn;
190 }
191 
IsTurnScreenOn() const192 bool WindowOption::IsTurnScreenOn() const
193 {
194     return turnScreenOn_;
195 }
196 
SetBrightness(float brightness)197 void WindowOption::SetBrightness(float brightness)
198 {
199     brightness_ = brightness;
200 }
201 
GetBrightness() const202 float WindowOption::GetBrightness() const
203 {
204     return brightness_;
205 }
206 
SetCallingWindow(uint32_t windowId)207 void WindowOption::SetCallingWindow(uint32_t windowId)
208 {
209     callingWindow_ = windowId;
210 }
211 
GetCallingWindow() const212 uint32_t WindowOption::GetCallingWindow() const
213 {
214     return callingWindow_;
215 }
216 
GetRequestedOrientation() const217 Orientation WindowOption::GetRequestedOrientation() const
218 {
219     return requestedOrientation_;
220 }
221 
SetRequestedOrientation(Orientation orientation)222 void WindowOption::SetRequestedOrientation(Orientation orientation)
223 {
224     requestedOrientation_ = orientation;
225 }
226 
SetSubWindowTitle(const std::string & subWindowTitle)227 void WindowOption::SetSubWindowTitle(const std::string& subWindowTitle)
228 {
229     subWindowTitle_ = subWindowTitle;
230 }
231 
GetSubWindowTitle() const232 std::string WindowOption::GetSubWindowTitle() const
233 {
234     return subWindowTitle_;
235 }
236 
SetSubWindowDecorEnable(bool subWindowDecorEnable)237 void WindowOption::SetSubWindowDecorEnable(bool subWindowDecorEnable)
238 {
239     subWindowDecorEnable_ = subWindowDecorEnable;
240 }
241 
GetSubWindowDecorEnable() const242 bool WindowOption::GetSubWindowDecorEnable() const
243 {
244     return subWindowDecorEnable_;
245 }
246 
SetOnlySupportSceneBoard(bool onlySupportSceneBoard)247 void WindowOption::SetOnlySupportSceneBoard(bool onlySupportSceneBoard)
248 {
249     onlySupportSceneBoard_ = onlySupportSceneBoard;
250 }
251 
GetOnlySupportSceneBoard() const252 bool WindowOption::GetOnlySupportSceneBoard() const
253 {
254     return onlySupportSceneBoard_;
255 }
256 } // namespace Rosen
257 } // namespace OHOS
258 
259