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 "window_option.h" 17#include "window_helper.h" 18#include "wm_common.h" 19 20namespace OHOS { 21namespace Rosen { 22WindowOption::WindowOption(): windowTag_(WindowTag::SYSTEM_WINDOW) 23{ 24} 25 26void WindowOption::SetWindowRect(const struct Rect& rect) 27{ 28 windowRect_ = rect; 29} 30 31void WindowOption::SetWindowType(WindowType type) 32{ 33 type_ = type; 34} 35 36void WindowOption::SetWindowMode(WindowMode mode) 37{ 38 if (!WindowHelper::IsValidWindowMode(mode)) { 39 return; 40 } 41 mode_ = mode; 42} 43 44void WindowOption::SetFocusable(bool isFocusable) 45{ 46 focusable_ = isFocusable; 47} 48 49void WindowOption::SetTouchable(bool isTouchable) 50{ 51 touchable_ = isTouchable; 52} 53 54void WindowOption::SetDisplayId(DisplayId displayId) 55{ 56 displayId_ = displayId; 57} 58 59void WindowOption::SetParentId(uint32_t parentId) 60{ 61 parentId_ = parentId; 62} 63 64void WindowOption::SetWindowName(const std::string& windowName) 65{ 66 windowName_ = windowName; 67} 68 69void WindowOption::AddWindowFlag(WindowFlag flag) 70{ 71 flags_ |= static_cast<uint32_t>(flag); 72} 73 74void WindowOption::RemoveWindowFlag(WindowFlag flag) 75{ 76 flags_ &= ~(static_cast<uint32_t>(flag)); 77} 78 79void WindowOption::SetWindowFlags(uint32_t flags) 80{ 81 flags_ = flags; 82} 83 84void WindowOption::SetSystemBarProperty(WindowType type, const SystemBarProperty& property) 85{ 86 if (type == WindowType::WINDOW_TYPE_STATUS_BAR || type == WindowType::WINDOW_TYPE_NAVIGATION_BAR) { 87 sysBarPropMap_[type] = property; 88 } 89} 90 91Rect WindowOption::GetWindowRect() const 92{ 93 return windowRect_; 94} 95 96WindowType WindowOption::GetWindowType() const 97{ 98 return type_; 99} 100 101WindowMode WindowOption::GetWindowMode() const 102{ 103 return mode_; 104} 105 106bool WindowOption::GetFocusable() const 107{ 108 return focusable_; 109} 110 111bool WindowOption::GetTouchable() const 112{ 113 return touchable_; 114} 115 116DisplayId WindowOption::GetDisplayId() const 117{ 118 return displayId_; 119} 120 121uint32_t WindowOption::GetParentId() const 122{ 123 return parentId_; 124} 125 126const std::string& WindowOption::GetWindowName() const 127{ 128 return windowName_; 129} 130 131uint32_t WindowOption::GetWindowFlags() const 132{ 133 return flags_; 134} 135 136void WindowOption::SetHitOffset(int32_t x, int32_t y) 137{ 138 hitOffset_.x = x; 139 hitOffset_.y = y; 140} 141 142void WindowOption::SetWindowTag(WindowTag windowTag) 143{ 144 windowTag_ = windowTag; 145} 146 147WindowTag WindowOption::GetWindowTag() const 148{ 149 return windowTag_; 150} 151 152void WindowOption::SetWindowSessionType(WindowSessionType sessionType) 153{ 154 sessionType_ = sessionType; 155} 156 157WindowSessionType WindowOption::GetWindowSessionType() const 158{ 159 return sessionType_; 160} 161 162void WindowOption::SetMainHandlerAvailable(bool isMainHandlerAvailable) 163{ 164 isMainHandlerAvailable_ = isMainHandlerAvailable; 165} 166 167bool WindowOption::GetMainHandlerAvailable() const 168{ 169 return isMainHandlerAvailable_; 170} 171 172const PointInfo& WindowOption::GetHitOffset() const 173{ 174 return hitOffset_; 175} 176 177const std::unordered_map<WindowType, SystemBarProperty>& WindowOption::GetSystemBarProperty() const 178{ 179 return sysBarPropMap_; 180} 181 182void WindowOption::SetKeepScreenOn(bool keepScreenOn) 183{ 184 keepScreenOn_ = keepScreenOn; 185} 186 187bool WindowOption::IsKeepScreenOn() const 188{ 189 return keepScreenOn_; 190} 191 192void WindowOption::SetTurnScreenOn(bool turnScreenOn) 193{ 194 turnScreenOn_ = turnScreenOn; 195} 196 197bool WindowOption::IsTurnScreenOn() const 198{ 199 return turnScreenOn_; 200} 201 202void WindowOption::SetBrightness(float brightness) 203{ 204 brightness_ = brightness; 205} 206 207float WindowOption::GetBrightness() const 208{ 209 return brightness_; 210} 211 212void WindowOption::SetCallingWindow(uint32_t windowId) 213{ 214 callingWindow_ = windowId; 215} 216 217uint32_t WindowOption::GetCallingWindow() const 218{ 219 return callingWindow_; 220} 221 222Orientation WindowOption::GetRequestedOrientation() const 223{ 224 return requestedOrientation_; 225} 226 227void WindowOption::SetRequestedOrientation(Orientation orientation) 228{ 229 requestedOrientation_ = orientation; 230} 231 232void WindowOption::SetBundleName(const std::string bundleName) 233{ 234 bundleName_ = bundleName; 235} 236 237const std::string WindowOption::GetBundleName() const 238{ 239 return bundleName_; 240} 241 242void WindowOption::SetSubWindowTitle(const std::string& subWindowTitle) 243{ 244 subWindowTitle_ = subWindowTitle; 245} 246 247std::string WindowOption::GetSubWindowTitle() const 248{ 249 return subWindowTitle_; 250} 251 252void WindowOption::SetSubWindowDecorEnable(bool subWindowDecorEnable) 253{ 254 subWindowDecorEnable_ = subWindowDecorEnable; 255} 256 257bool WindowOption::GetSubWindowDecorEnable() const 258{ 259 return subWindowDecorEnable_; 260} 261 262void WindowOption::SetOnlySupportSceneBoard(bool onlySupportSceneBoard) 263{ 264 onlySupportSceneBoard_ = onlySupportSceneBoard; 265} 266 267bool WindowOption::GetOnlySupportSceneBoard() const 268{ 269 return onlySupportSceneBoard_; 270} 271 272void WindowOption::SetRealParentId(int32_t realParentId) 273{ 274 realParentId_ = realParentId; 275} 276 277int32_t WindowOption::GetRealParentId() const 278{ 279 return realParentId_; 280} 281 282void WindowOption::SetParentWindowType(WindowType parentWindowType) 283{ 284 parentWindowType_ = parentWindowType; 285} 286 287WindowType WindowOption::GetParentWindowType() const 288{ 289 return parentWindowType_; 290} 291 292void WindowOption::SetIsUIExtFirstSubWindow(bool isUIExtFirstSubWindow) 293{ 294 isUIExtFirstSubWindow_ = isUIExtFirstSubWindow; 295} 296 297bool WindowOption::GetIsUIExtFirstSubWindow() const 298{ 299 return isUIExtFirstSubWindow_; 300} 301 302void WindowOption::SetUIExtensionUsage(uint32_t uiExtensionUsage) 303{ 304 if (uiExtensionUsage < static_cast<uint32_t>(UIExtensionUsage::UIEXTENSION_USAGE_END)) { 305 uiExtensionUsage_ = uiExtensionUsage; 306 } else { 307 uiExtensionUsage_ = static_cast<uint32_t>(UIExtensionUsage::EMBEDDED); 308 } 309} 310 311uint32_t WindowOption::GetUIExtensionUsage() const 312{ 313 return uiExtensionUsage_; 314} 315 316void WindowOption::SetDialogDecorEnable(bool decorEnable) 317{ 318 dialogDecorEnable_ = decorEnable; 319} 320 321void WindowOption::SetIsUIExtAnySubWindow(bool isUIExtAnySubWindow) 322{ 323 isUIExtAnySubWindow_ = isUIExtAnySubWindow; 324} 325 326bool WindowOption::GetIsUIExtAnySubWindow() const 327{ 328 return isUIExtAnySubWindow_; 329} 330 331bool WindowOption::GetDialogDecorEnable() const 332{ 333 return dialogDecorEnable_; 334} 335 336void WindowOption::SetDialogTitle(const std::string& dialogTitle) 337{ 338 dialogTitle_ = dialogTitle; 339} 340 341std::string WindowOption::GetDialogTitle() const 342{ 343 return dialogTitle_; 344} 345 346void WindowOption::SetWindowTopmost(bool isTopmost) 347{ 348 isTopmost_ = isTopmost; 349} 350 351bool WindowOption::GetWindowTopmost() const 352{ 353 return isTopmost_; 354} 355 356} // namespace Rosen 357} // namespace OHOS 358 359