1 /* 2 * Copyright (c) 2022-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 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 32 #include "screen_client.h" 33 #include "screen_client_common.h" 34 35 namespace OHOS { 36 namespace DistributedHardware { 37 class ScreenClientWindowAdapter { 38 DECLARE_SINGLE_INSTANCE_BASE(ScreenClientWindowAdapter); 39 public: 40 sptr<Surface> CreateWindow(std::shared_ptr<WindowProperty> &windowProperty, int32_t windowId); 41 int32_t ShowWindow(int32_t windowId); 42 int32_t HideWindow(int32_t windowId); 43 int32_t MoveWindow(int32_t windowId, int32_t startX, int32_t startY); 44 int32_t RemoveWindow(int32_t windowId); 45 int32_t DestroyAllWindow(); 46 private: 47 ScreenClientWindowAdapter() = default; 48 ~ScreenClientWindowAdapter() = default; 49 std::map<int32_t, sptr<Rosen::Window>> windowIdMap_; 50 std::mutex windowIdMapMutex_; 51 sptr<Surface> surface_ = nullptr; 52 }; 53 54 class ScreenClientInputEventListener : public Rosen::IInputEventConsumer { 55 public: 56 ScreenClientInputEventListener() = default; 57 ~ScreenClientInputEventListener() override = default; 58 bool OnInputEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const override; 59 bool OnInputEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const override; 60 bool OnInputEvent(const std::shared_ptr<MMI::AxisEvent>& axisEvent) const override; 61 }; 62 } // namespace DistributedHardware 63 } // namespace OHOS 64 #endif