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 #ifndef OHOS_SCREEN_CLIENT_WINDOW_H
17 #define OHOS_SCREEN_CLIENT_WINDOW_H
18 
19 #include <cstdint>
20 #include <string>
21 #include <map>
22 #include <memory>
23 #include <refbase.h>
24 
25 #include "axis_event.h"
26 #include "key_event.h"
27 #include "pointer_event.h"
28 #include "single_instance.h"
29 #include "surface.h"
30 #include "window.h"
31 #include "window_scene.h"
32 
33 #include "screen_client.h"
34 #include "screen_client_common.h"
35 
36 namespace OHOS {
37 namespace DistributedHardware {
38 class ScreenClientWindowAdapter {
39 DECLARE_SINGLE_INSTANCE_BASE(ScreenClientWindowAdapter);
40 public:
41     sptr<Surface> CreateWindow(std::shared_ptr<WindowProperty> &windowProperty, int32_t windowId);
42     int32_t ShowWindow(int32_t windowId);
43     int32_t HideWindow(int32_t windowId);
44     int32_t MoveWindow(int32_t windowId, int32_t startX, int32_t startY);
45     int32_t RemoveWindow(int32_t windowId);
46     int32_t DestroyAllWindow();
47 private:
48     ScreenClientWindowAdapter() = default;
49     ~ScreenClientWindowAdapter() = default;
50     std::map<int32_t, sptr<Rosen::Window>> windowIdMap_;
51     std::mutex windowIdMapMutex_;
52     sptr<Surface> surface_ = nullptr;
53 };
54 
55 class ScreenClientInputEventListener : public Rosen::IInputEventConsumer {
56 public:
57     ScreenClientInputEventListener() = default;
58     ~ScreenClientInputEventListener() override = default;
59     bool OnInputEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const override;
60     bool OnInputEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const override;
61     bool OnInputEvent(const std::shared_ptr<MMI::AxisEvent>& axisEvent) const override;
62 };
63 } // namespace DistributedHardware
64 } // namespace OHOS
65 #endif