1 /* 2 * Copyright (c) 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 #ifndef WINDOW_EXTENSION_CONNECTION_H 17 #define WINDOW_EXTENSION_CONNECTION_H 18 19 #include <string> 20 #include <element_name.h> 21 #include <i_input_event_consumer.h> 22 #include <input_manager.h> 23 #include <key_event.h> 24 #include <pointer_event.h> 25 #include <memory> 26 27 #include "wm_common.h" 28 29 namespace OHOS { 30 namespace Rosen { 31 namespace { 32 const std::string RECT_FORM_KEY_POS_X = "ext_pos_x"; 33 const std::string RECT_FORM_KEY_POS_Y = "ext_pos_y"; 34 const std::string RECT_FORM_KEY_HEIGHT = "ext_pos_heigh"; 35 const std::string RECT_FORM_KEY_WIDTH = "ext_pos_width"; 36 const std::string WINDOW_ID = "ext_window_id"; 37 } 38 39 class RSSurfaceNode; 40 class IWindowExtensionCallback : virtual public RefBase { 41 public: 42 virtual void OnWindowReady(const std::shared_ptr<RSSurfaceNode>& rsSurfaceNode) = 0; 43 virtual void OnExtensionDisconnected() = 0; 44 virtual void OnKeyEvent(const std::shared_ptr<MMI::KeyEvent>& event) = 0; 45 virtual void OnPointerEvent(const std::shared_ptr<MMI::PointerEvent>& event) = 0; 46 virtual void OnBackPress() = 0; 47 }; 48 49 class WindowExtensionConnection : public RefBase { 50 public: 51 WindowExtensionConnection(); 52 ~WindowExtensionConnection(); 53 int ConnectExtension(const AppExecFwk::ElementName& element, const Rect& rect, 54 uint32_t uid, uint32_t windowId, const sptr<IWindowExtensionCallback>& callback) const; 55 void DisconnectExtension() const; 56 void Show() const; 57 void Hide() const; 58 void RequestFocus() const; 59 void SetBounds(const Rect& rect) const; 60 private: 61 class Impl; 62 sptr<Impl> pImpl_; 63 }; 64 } // namespace Rosen 65 } // namespace OHOS 66 #endif // WINDOW_EXTENSION_CONNECTION_H