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 #ifndef INTERFACES_INNERKITS_WINDOW_SCENE_H
17 #define INTERFACES_INNERKITS_WINDOW_SCENE_H
18 
19 #include <refbase.h>
20 #include <iremote_object.h>
21 
22 #include "window.h"
23 #include "window_option.h"
24 
25 namespace OHOS::AppExecFwk {
26 class Configuration;
27 }
28 
29 namespace OHOS {
30 namespace Rosen {
31 #ifdef CreateWindow
32 #undef CreateWindow
33 #endif
34 class WINDOW_EXPORT WindowScene : public RefBase {
35 public:
36     WindowScene() = default;
37     ~WindowScene();
38     WMError Init(DisplayId displayId, const std::shared_ptr<AbilityRuntime::Context>& context,
39         sptr<IWindowLifeCycle>& listener, sptr<WindowOption> option = nullptr);
40     sptr<Window> CreateWindow(const std::string& windowName, sptr<WindowOption>& option) const;
41     const sptr<Window>& GetMainWindow() const;
42     std::vector<sptr<Window>> GetSubWindow();
43     WMError GoDestroy();
44     void UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration);
45 
46 private:
47     std::string GenerateMainWindowName(const std::shared_ptr<AbilityRuntime::Context>& context) const;
48 
49     sptr<Window> mainWindow_ = nullptr;
50     static inline std::atomic<uint32_t> count { 0 };
51     static const std::string MAIN_WINDOW_ID;
52     static const DisplayId DEFAULT_DISPLAY_ID = 0;
53     DisplayId displayId_ = DEFAULT_DISPLAY_ID;
54 };
55 } // namespace Rosen
56 } // namespace OHOS
57 #endif // INTERFACES_INNERKITS_WINDOW_SCENE_H
58