• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_ROSEN_WINDOW_SCENE_WINDOW_EVENT_CHANNEL_H
17 #define OHOS_ROSEN_WINDOW_SCENE_WINDOW_EVENT_CHANNEL_H
18 
19 #include <functional>
20 #include <list>
21 #include <map>
22 
23 #include "accessibility_element_info.h"
24 
25 #include "interfaces/include/ws_common.h"
26 #include "session/container/include/zidl/session_stage_interface.h"
27 #include "session/container/include/zidl/window_event_channel_stub.h"
28 
29 namespace OHOS::Rosen {
30 class WindowEventChannel : public WindowEventChannelStub {
31 public:
WindowEventChannel(sptr<ISessionStage> iSessionStage)32     explicit WindowEventChannel(sptr<ISessionStage> iSessionStage) : sessionStage_(iSessionStage)
33     {
34         dispatchCallback_ = std::bind(&WindowEventChannel::OnDispatchEventProcessed, std::placeholders::_1,
35             std::placeholders::_2);
36     }
37     ~WindowEventChannel() = default;
38 
39     WSError TransferBackpressedEventForConsumed(bool& isConsumed) override;
40     WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
41     WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
42     WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) override;
43     WSError TransferFocusActiveEvent(bool isFocusActive) override;
44     WSError TransferFocusState(bool focusState) override;
45     WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
46         std::list<Accessibility::AccessibilityElementInfo>& infos) override;
47     WSError TransferSearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent,
48         std::list<Accessibility::AccessibilityElementInfo>& infos) override;
49     WSError TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
50         Accessibility::AccessibilityElementInfo& info) override;
51     WSError TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
52         Accessibility::AccessibilityElementInfo& info) override;
53     WSError TransferExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments,
54         int32_t action, int64_t baseParent) override;
55 
56 private:
57     void PrintKeyEvent(const std::shared_ptr<MMI::KeyEvent>& event);
58     void PrintPointerEvent(const std::shared_ptr<MMI::PointerEvent>& event);
59     void PrintInfoPointerEvent(const std::shared_ptr<MMI::PointerEvent>& event);
60     static void OnDispatchEventProcessed(int32_t eventId, int64_t actionTime);
61 
62 private:
63     sptr<ISessionStage> sessionStage_ = nullptr;
64     std::function<void(int32_t, int64_t)> dispatchCallback_ { nullptr };
65 };
66 } // namespace OHOS::Rosen
67 #endif // OHOS_ROSEN_WINDOW_SCENE_WINDOW_EVENT_CHANNEL_H
68