1/*
2 * Copyright (c) 2022-2024 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.h"
17
18#include "window_impl.h"
19#include "window_manager_hilog.h"
20
21namespace OHOS {
22namespace Rosen {
23namespace {
24constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "Window"};
25}
26sptr<Window> Window::Create(const std::string& windowName, sptr<WindowOption>& option,
27    const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, WMError& errCode)
28{
29    if (option == nullptr) {
30        option = new(std::nothrow) WindowOption();
31        if (option == nullptr) {
32            WLOGFE("alloc WindowOption failed");
33            return nullptr;
34        }
35    }
36    sptr<WindowImpl> windowImpl = new(std::nothrow) WindowImpl(option);
37    if (windowImpl == nullptr) {
38        WLOGFE("alloc WindowImpl failed");
39        return nullptr;
40    }
41    WMError error = windowImpl->Create(option->GetParentId(), context);
42    if (error != WMError::WM_OK) {
43        WLOGFE("error unequal to WMError::WM_OK");
44        errCode = error;
45        return nullptr;
46    }
47    return windowImpl;
48}
49
50sptr<Window> Window::Find(const std::string& windowName)
51{
52    return nullptr;
53}
54
55std::vector<sptr<Window>> Window::GetSubWindow(uint32_t parentId)
56{
57    return std::vector<sptr<Window>>();
58}
59
60sptr<Window> Window::GetTopWindowWithId(uint32_t mainWinId)
61{
62    return WindowImpl::GetTopWindowWithId(mainWinId);
63}
64
65sptr<Window> Window::GetTopWindowWithContext(const std::shared_ptr<AbilityRuntime::Context>& context)
66{
67    return nullptr;
68}
69
70void Window::UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration)
71{
72    return WindowImpl::UpdateConfigurationForAll(configuration);
73}
74
75bool OccupiedAreaChangeInfo::Marshalling(Parcel& parcel) const
76{
77    return true;
78}
79
80OccupiedAreaChangeInfo* OccupiedAreaChangeInfo::Unmarshalling(Parcel& parcel)
81{
82    return nullptr;
83}
84} // namespace Rosen
85} // namespace OHOS
86