1 /*
2  * Copyright (c) 2021-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 #ifndef OHOS_WINDOW_INPUT_CHANNEL_H
16 #define OHOS_WINDOW_INPUT_CHANNEL_H
17 
18 #include <i_input_event_consumer.h>
19 #include <key_event.h>
20 #include "refbase.h"
21 #include "vsync_station.h"
22 #include "window.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class WindowInputChannel final: public RefBase {
27 public:
28     explicit WindowInputChannel(const sptr<Window>& window);
29     virtual ~WindowInputChannel();
30     void HandlePointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
31     void HandleKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent);
32     void Destroy();
33     Rect GetWindowRect();
34 private:
35     bool IsKeyboardEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const;
36     void DispatchKeyEventCallback(std::shared_ptr<MMI::KeyEvent>& keyEvent, bool consumed);
37     std::mutex mtx_;
38     sptr<Window> window_;
39     bool isAvailable_;
40     static const int32_t MAX_INPUT_NUM = 100;
41 };
42 }
43 }
44 
45 
46 #endif // OHOS_WINDOW_INPUT_CHANNEL_H
47