remove raw input listener

Change-Id: I056238aeeade0b1f507e59cb73e566cef879c08f
Signed-off-by: lizheng <lizheng2@huawei.com>
This commit is contained in:
lizheng 2021-12-16 15:02:09 +08:00
parent 62777c4070
commit 14162d0daa
29 changed files with 21 additions and 2290 deletions

100
README.md
View File

@ -193,106 +193,6 @@ The dependent APIs include the following:
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p220mcpsimp"><a name="p220mcpsimp"></a><a name="p220mcpsimp"></a>Rotates the current window.</p>
</td>
</tr>
<tr id="row221mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p223mcpsimp"><a name="p223mcpsimp"></a><a name="p223mcpsimp"></a>RegistPointerButtonCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p225mcpsimp"><a name="p225mcpsimp"></a><a name="p225mcpsimp"></a>Registers the callback for Button events of the mouse.</p>
</td>
</tr>
<tr id="row226mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p228mcpsimp"><a name="p228mcpsimp"></a><a name="p228mcpsimp"></a>RegistPointerEnterCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p230mcpsimp"><a name="p230mcpsimp"></a><a name="p230mcpsimp"></a>Registers the callback for Enter events of the mouse.</p>
</td>
</tr>
<tr id="row231mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p233mcpsimp"><a name="p233mcpsimp"></a><a name="p233mcpsimp"></a>RegistPointerLeaveCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p235mcpsimp"><a name="p235mcpsimp"></a><a name="p235mcpsimp"></a>Registers the callback for Leave events of the mouse.</p>
</td>
</tr>
<tr id="row236mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p238mcpsimp"><a name="p238mcpsimp"></a><a name="p238mcpsimp"></a>RegistPointerMotionCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p240mcpsimp"><a name="p240mcpsimp"></a><a name="p240mcpsimp"></a>Registers the callback for Motion events of the mouse.</p>
</td>
</tr>
<tr id="row241mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p243mcpsimp"><a name="p243mcpsimp"></a><a name="p243mcpsimp"></a>RegistPointerAxisDiscreteCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p245mcpsimp"><a name="p245mcpsimp"></a><a name="p245mcpsimp"></a>Registers the callback for AxisDiscrete events of the mouse.</p>
</td>
</tr>
<tr id="row246mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p248mcpsimp"><a name="p248mcpsimp"></a><a name="p248mcpsimp"></a>RegistPointerAxisSourceCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p250mcpsimp"><a name="p250mcpsimp"></a><a name="p250mcpsimp"></a>Registers the callback for AxisSource events of the mouse.</p>
</td>
</tr>
<tr id="row251mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p253mcpsimp"><a name="p253mcpsimp"></a><a name="p253mcpsimp"></a>RegistPointerAxisStopCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p255mcpsimp"><a name="p255mcpsimp"></a><a name="p255mcpsimp"></a>Registers the callback for AxisStop events of the mouse.</p>
</td>
</tr>
<tr id="row256mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p258mcpsimp"><a name="p258mcpsimp"></a><a name="p258mcpsimp"></a>RegistPointerAxisCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p260mcpsimp"><a name="p260mcpsimp"></a><a name="p260mcpsimp"></a>Registers the callback for Axis events of the mouse.</p>
</td>
</tr>
<tr id="row261mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p263mcpsimp"><a name="p263mcpsimp"></a><a name="p263mcpsimp"></a>RegistTouchUpCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p265mcpsimp"><a name="p265mcpsimp"></a><a name="p265mcpsimp"></a>Registers the callback for TouchUp events.</p>
</td>
</tr>
<tr id="row266mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p268mcpsimp"><a name="p268mcpsimp"></a><a name="p268mcpsimp"></a>RegistTouchDownCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p270mcpsimp"><a name="p270mcpsimp"></a><a name="p270mcpsimp"></a>Registers the callback for TouchDown events.</p>
</td>
</tr>
<tr id="row271mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p273mcpsimp"><a name="p273mcpsimp"></a><a name="p273mcpsimp"></a>RegistTouchEmotionCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p275mcpsimp"><a name="p275mcpsimp"></a><a name="p275mcpsimp"></a>Registers the callback for TouchEmotion events.</p>
</td>
</tr>
<tr id="row276mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p278mcpsimp"><a name="p278mcpsimp"></a><a name="p278mcpsimp"></a>RegistTouchFrameCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p280mcpsimp"><a name="p280mcpsimp"></a><a name="p280mcpsimp"></a>Registers the callback for TouchFrame events.</p>
</td>
</tr>
<tr id="row281mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p283mcpsimp"><a name="p283mcpsimp"></a><a name="p283mcpsimp"></a>RegistTouchCancelCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p285mcpsimp"><a name="p285mcpsimp"></a><a name="p285mcpsimp"></a>Registers the callback for TouchCancel events.</p>
</td>
</tr>
<tr id="row286mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p288mcpsimp"><a name="p288mcpsimp"></a><a name="p288mcpsimp"></a>RegistTouchShapeCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p290mcpsimp"><a name="p290mcpsimp"></a><a name="p290mcpsimp"></a>Registers the callback for TouchShape events.</p>
</td>
</tr>
<tr id="row291mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p293mcpsimp"><a name="p293mcpsimp"></a><a name="p293mcpsimp"></a>RegistTouchOrientationCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p295mcpsimp"><a name="p295mcpsimp"></a><a name="p295mcpsimp"></a>Registers the callback for TouchOrientation events.</p>
</td>
</tr>
<tr id="row296mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p298mcpsimp"><a name="p298mcpsimp"></a><a name="p298mcpsimp"></a>RegistKeyboardKeyCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p300mcpsimp"><a name="p300mcpsimp"></a><a name="p300mcpsimp"></a>Registers the callback for Key events of the keyboard.</p>
</td>
</tr>
<tr id="row301mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p303mcpsimp"><a name="p303mcpsimp"></a><a name="p303mcpsimp"></a>RegistKeyboardKeyMapCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p305mcpsimp"><a name="p305mcpsimp"></a><a name="p305mcpsimp"></a>Registers the callback for KeyMap events of the keyboard.</p>
</td>
</tr>
<tr id="row306mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p308mcpsimp"><a name="p308mcpsimp"></a><a name="p308mcpsimp"></a>RegistKeyboardLeaveCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p310mcpsimp"><a name="p310mcpsimp"></a><a name="p310mcpsimp"></a>Registers the callback for Leave events of the keyboard.</p>
</td>
</tr>
<tr id="row311mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p313mcpsimp"><a name="p313mcpsimp"></a><a name="p313mcpsimp"></a>RegistKeyboardEnterCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p315mcpsimp"><a name="p315mcpsimp"></a><a name="p315mcpsimp"></a>Registers the callback for Enter events of the keyboard.</p>
</td>
</tr>
<tr id="row316mcpsimp"><td class="cellrowborder" valign="top" width="48%" headers="mcps1.1.3.1.1 "><p id="p318mcpsimp"><a name="p318mcpsimp"></a><a name="p318mcpsimp"></a>RegistKeyboardRepeatInfoCb</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.1.3.1.2 "><p id="p320mcpsimp"><a name="p320mcpsimp"></a><a name="p320mcpsimp"></a>Registers the callback for RepeatInfo events of the keyboard.</p>
</td>
</tr>
</tbody>
</table>

View File

@ -102,26 +102,6 @@ foundation/graphic/standard/
| ChangeWindowType | 更改当前窗口类型 |
| ReSize | 调整当前窗口至指定大小 |
| Rotate | 旋转当前窗口 |
| RegistPointerButtonCb | 注册鼠标Button事件回调 |
| RegistPointerEnterCb | 注册鼠标Enter事件回调 |
| RegistPointerLeaveCb | 注册鼠标Leave事件回调 |
| RegistPointerMotionCb | 注册鼠标Motion事件回调 |
| RegistPointerAxisDiscreteCb | 注册鼠标AxisDiscrete事件回调 |
| RegistPointerAxisSourceCb | 注册鼠标AxisSource事件回调 |
| RegistPointerAxisStopCb | 注册鼠标AxisStop事件回调 |
| RegistPointerAxisCb | 注册鼠标Axis事件回调 |
| RegistTouchUpCb | 注册TouchUp事件回调 |
| RegistTouchDownCb | 注册TouchDown事件回调 |
| RegistTouchEmotionCb | 注册TouchEmotion事件回调 |
| RegistTouchFrameCb | 注册TouchFrame事件回调 |
| RegistTouchCancelCb | 注册TouchCancel事件回调 |
| RegistTouchShapeCb | 注册TouchShape事件回调 |
| RegistTouchOrientationCb | 注册TouchOrientation事件回调 |
| RegistKeyboardKeyCb | 注册键盘Key事件回调 |
| RegistKeyboardKeyMapCb | 注册键盘KeyMap事件回调 |
| RegistKeyboardLeaveCb | 注册键盘Leave事件回调 |
| RegistKeyboardEnterCb | 注册键盘Enter事件回调 |
| RegistKeyboardRepeatInfoCb | 注册键盘RepeatInfo事件回调 |
### SubWindow
| 接口名 | 职责 |

View File

@ -43,8 +43,6 @@ ohos_shared_library("wms_client") {
"src/client/video_window.cpp",
"src/client/window_manager.cpp",
"src/client/window_manager_controller_client.cpp",
"src/input_listener_manager.cpp",
"src/log_listener.cpp",
"src/singleton_container.cpp",
"src/tester.cpp",
"src/wayland_service.cpp",
@ -75,10 +73,6 @@ ohos_shared_library("wms_client") {
"//developtools/bytrace_standard/interfaces/innerkits/native:bytrace_core",
"//foundation/graphic/standard:libwmservice",
"//foundation/graphic/standard/frameworks/wmserver:wms_protocol",
"//third_party/wayland-ivi-extension:libilmClient",
"//third_party/wayland-ivi-extension:libilmCommon",
"//third_party/wayland-ivi-extension:libilmControl",
"//third_party/wayland-ivi-extension:libilmInput",
"//third_party/wayland-protocols_standard:linux_dmabuf_unstable_v1_protocol",
"//third_party/wayland-protocols_standard:linux_explicit_synchronization_unstable_v1_protocol",
"//third_party/wayland-protocols_standard:viewporter_protocol",
@ -139,8 +133,6 @@ config("libwmclient_public_config") {
ohos_shared_library("libwmclient") {
sources = [
"src/input_listener_manager.cpp",
"src/log_listener.cpp",
"src/singleton_container.cpp",
"src/static_call.cpp",
"src/subwindow_normal_impl.cpp",
@ -181,10 +173,6 @@ ohos_shared_library("libwmclient") {
"//developtools/bytrace_standard/interfaces/innerkits/native:bytrace_core",
"//foundation/graphic/standard:libwmservice",
"//foundation/graphic/standard/frameworks/wmserver:wms_protocol",
"//third_party/wayland-ivi-extension:libilmClient",
"//third_party/wayland-ivi-extension:libilmCommon",
"//third_party/wayland-ivi-extension:libilmControl",
"//third_party/wayland-ivi-extension:libilmInput",
"//third_party/wayland-protocols_standard:linux_dmabuf_unstable_v1_protocol",
"//third_party/wayland-protocols_standard:linux_explicit_synchronization_unstable_v1_protocol",
"//third_party/wayland-protocols_standard:viewporter_protocol",

View File

@ -24,8 +24,6 @@
#include <surface.h>
#include <window_manager_service_client.h>
#include "input_listener_manager.h"
#include "log_listener.h"
#include "wayland_service.h"
#include "window_manager_server.h"
#include "wl_buffer_cache.h"
@ -56,7 +54,6 @@ struct InnerWindowInfo {
int32_t pos_y;
funcWindowInfoChange windowInfoChangeCb;
void (* onWindowCreateCb)(uint32_t pid);
sptr<InputListener> logListener;
bool operator ==(const InnerWindowInfo &other) const
{

View File

@ -1,115 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_WM_INCLUDE_INPUT_LISTENER_MANAGER_H
#define FRAMEWORKS_WM_INCLUDE_INPUT_LISTENER_MANAGER_H
#include <map>
#include <vector>
#include <refbase.h>
#include <wayland-client-protocol.h>
#include <window_manager_input_type.h>
#include "singleton_delegator.h"
#include "wayland_service.h"
namespace OHOS {
class InputListenerManager;
class InputListener : public RefBase {
friend class InputListenerManager;
public:
PointerEnterFunc pointerEnter = nullptr;
PointerLeaveFunc pointerLeave = nullptr;
PointerMotionFunc pointerMotion = nullptr;
PointerButtonFunc pointerButton = nullptr;
PointerFrameFunc pointerFrame = nullptr;
PointerAxisFunc pointerAxis = nullptr;
PointerAxisSourceFunc pointerAxisSource = nullptr;
PointerAxisStopFunc pointerAxisStop = nullptr;
PointerAxisDiscreteFunc pointerAxisDiscrete = nullptr;
KeyboardKeymapFunc keyboardKeymap = nullptr;
KeyboardEnterFunc keyboardEnter = nullptr;
KeyboardLeaveFunc keyboardLeave = nullptr;
KeyboardKeyFunc keyboardKey = nullptr;
KeyboardModifiersFunc keyboardModifiers = nullptr;
KeyboardRepeatInfoFunc keyboardRepeatInfo = nullptr;
TouchDownFunc touchDown = nullptr;
TouchUpFunc touchUp = nullptr;
TouchMotionFunc touchMotion = nullptr;
TouchFrameFunc touchFrame = nullptr;
TouchCancelFunc touchCancel = nullptr;
TouchShapeFunc touchShape = nullptr;
TouchOrientationFunc touchOrientation = nullptr;
void *GetWindow() const
{
return window;
}
private:
InputListener(void *w);
~InputListener() = default;
void *window;
};
struct Seat {
struct wl_seat *seat;
struct wl_pointer *pointer;
struct wl_keyboard *keyboard;
struct wl_touch *touch;
};
using InputListeners = std::vector<sptr<InputListener>>;
class InputListenerManager : public RefBase {
public:
static sptr<InputListenerManager> GetInstance();
MOCKABLE void Init();
MOCKABLE void Deinit();
MOCKABLE sptr<InputListener> AddListener(void *window);
MOCKABLE void RemoveListener(sptr<InputListener> &listener);
protected:
InputListeners GetFocus();
InputListeners GetInputCallback(void *window);
void SetFocus(void *window);
std::map<void *, InputListeners> inputListenersMap;
void *focus = nullptr;
private:
InputListenerManager() = default;
MOCKABLE ~InputListenerManager() override;
static inline sptr<InputListenerManager> instance = nullptr;
static inline SingletonDelegator<InputListenerManager> delegator;
static void OnAppear(const GetServiceFunc get, const std::string &iname, uint32_t ver);
static inline std::vector<Seat> seats;
static uint32_t FindSeatNum(struct wl_seat *seat);
static inline void SeatHandleCapabilities(void *, struct wl_seat *, uint32_t caps);
static inline void RegisterPointerListener(uint32_t caps, struct wl_seat *seat);
static inline void RegisterKeyboardListener(uint32_t caps, struct wl_seat *seat);
static inline void RegisterTouchListener(uint32_t caps, struct wl_seat *seat);
};
} // namespace OHOS
#endif // FRAMEWORKS_WM_INCLUDE_INPUT_LISTENER_MANAGER_H

View File

@ -1,65 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_WM_INCLUDE_LOG_LISTENER_H
#define FRAMEWORKS_WM_INCLUDE_LOG_LISTENER_H
#include "input_listener_manager.h"
#include "singleton_delegator.h"
namespace OHOS {
class LogListener : public RefBase {
public:
static sptr<LogListener> GetInstance();
MOCKABLE sptr<InputListener> AddListener(void *window);
MOCKABLE void RemoveListener(sptr<InputListener> &listener);
private:
LogListener() = default;
MOCKABLE ~LogListener() = default;
static inline sptr<LogListener> instance = nullptr;
static inline SingletonDelegator<LogListener> delegator;
void PointerHandleEnter(void *data, uint32_t serial, double x, double y);
void PointerHandleLeave(void *data, uint32_t serial);
void PointerHandleMotion(void *data, uint32_t time, double x, double y);
void PointerHandleButton(void *data,
uint32_t serial, uint32_t time, uint32_t button, PointerButtonState state);
void PointerHandleFrame(void *data);
void PointerHandleAxis(void *data, uint32_t time, PointerAxis axis, double value);
void PointerHandleAxisSource(void *data, PointerAxisSource axisSource);
void PointerHandleAxisStop(void *data, uint32_t time, PointerAxis axis);
void PointerHandleAxisDiscrete(void *data, PointerAxis axis, int32_t discrete);
void KeyboardHandleKeyMap(void *data, KeyboardKeymapFormat format, int32_t fd, uint32_t size);
void KeyboardHandleEnter(void *data, uint32_t serial, const std::vector<uint32_t> &keys);
void KeyboardHandleLeave(void *data, uint32_t serial);
void KeyboardHandleKey(void *data,
uint32_t serial, uint32_t time, uint32_t key, KeyboardKeyState state);
void KeyboardHandleModifiers(void *data,
uint32_t serial, uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
void KeyboardHandleRepeatInfo(void *data, int32_t rate, int32_t delay);
void TouchHandleDown(void *data, uint32_t serial, uint32_t time, int32_t id, double x, double y);
void TouchHandleUp(void *data, uint32_t serial, uint32_t time, int32_t id);
void TouchHandleMotion(void *data, uint32_t time, int32_t id, double x, double y);
void TouchHandleFrame(void *data);
void TouchHandleCancel(void *data);
void TouchHandleShape(void *data, int32_t id, double major, double minor);
void TouchHandleOrientation(void *data, int32_t id, double orientation);
};
} // namespace OHOS
#endif // FRAMEWORKS_WM_INCLUDE_LOG_LISTENER_H

View File

@ -22,7 +22,6 @@
#include <window_manager_service_client.h>
#include "log_listener.h"
#include "wl_surface.h"
#include "window_attribute.h"
#include "window_option_impl.h"
@ -72,34 +71,6 @@ public:
virtual GSError OnTouch(OnTouchFunc cb) override;
virtual GSError OnKey(OnKeyFunc cb) override;
// pointer listener
virtual GSError OnPointerEnter(PointerEnterFunc func) override;
virtual GSError OnPointerLeave(PointerLeaveFunc func) override;
virtual GSError OnPointerMotion(PointerMotionFunc func) override;
virtual GSError OnPointerButton(PointerButtonFunc func) override;
virtual GSError OnPointerFrame(PointerFrameFunc func) override;
virtual GSError OnPointerAxis(PointerAxisFunc func) override;
virtual GSError OnPointerAxisSource(PointerAxisSourceFunc func) override;
virtual GSError OnPointerAxisStop(PointerAxisStopFunc func) override;
virtual GSError OnPointerAxisDiscrete(PointerAxisDiscreteFunc func) override;
// keyboard listener
virtual GSError OnKeyboardKeymap(KeyboardKeymapFunc func) override;
virtual GSError OnKeyboardEnter(KeyboardEnterFunc func) override;
virtual GSError OnKeyboardLeave(KeyboardLeaveFunc func) override;
virtual GSError OnKeyboardKey(KeyboardKeyFunc func) override;
virtual GSError OnKeyboardModifiers(KeyboardModifiersFunc func) override;
virtual GSError OnKeyboardRepeatInfo(KeyboardRepeatInfoFunc func) override;
// touch listener
virtual GSError OnTouchDown(TouchDownFunc func) override;
virtual GSError OnTouchUp(TouchUpFunc func) override;
virtual GSError OnTouchMotion(TouchMotionFunc func) override;
virtual GSError OnTouchFrame(TouchFrameFunc func) override;
virtual GSError OnTouchCancel(TouchCancelFunc func) override;
virtual GSError OnTouchShape(TouchShapeFunc func) override;
virtual GSError OnTouchOrientation(TouchOrientationFunc func) override;
private:
WindowImpl() = default;
virtual ~WindowImpl() override;
@ -127,8 +98,6 @@ private:
sptr<Surface> csurface = nullptr;
sptr<Surface> psurface = nullptr;
sptr<InputListener> logListener = nullptr;
sptr<InputListener> exportListener = nullptr;
BeforeFrameSubmitFunc onBeforeFrameSubmitFunc = nullptr;
};
} // namespace OHOS

View File

@ -23,7 +23,6 @@
#include <window_manager_service_client.h>
#include "input_listener_manager.h"
#include "singleton_delegator.h"
#include "wayland_service.h"
#include "window_manager_server.h"
@ -76,7 +75,6 @@ private:
std::vector<WptrWindow> windowCache;
sptr<WlDisplay> display = nullptr;
sptr<InputListenerManager> inputListenerManager = nullptr;
sptr<WlBufferCache> wlBufferCache = nullptr;
sptr<WlDMABufferFactory> wlDMABufferFactory = nullptr;
sptr<WlSHMBufferFactory> wlSHMBufferFactory = nullptr;

View File

@ -64,7 +64,6 @@ bool LayerControllerClient::init(sptr<IWindowManagerService> &service)
}
wms = service;
InputListenerManager::GetInstance()->Init();
WlDMABufferFactory::GetInstance()->Init();
WlSHMBufferFactory::GetInstance()->Init();
WlSurfaceFactory::GetInstance()->Init();

View File

@ -1,560 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "input_listener_manager.h"
#include <mutex>
#include <wayland-client-protocol.h>
namespace OHOS {
namespace {
std::function<InputListeners()> g_getFocus = []() { return InputListeners(); };
std::function<InputListeners(void *)> g_getInputCallback = [](void *) { return InputListeners(); };
std::function<void(void *)> g_setFocus = [](void *) {};
}
InputListener::InputListener(void *w)
{
window = w;
}
void InputListenerManager::Init()
{
delegator.Dep<WaylandService>()->OnAppear(&InputListenerManager::OnAppear);
auto instance = SingletonContainer::Get<InputListenerManager>();
g_getFocus = std::bind(&InputListenerManager::GetFocus, instance);
g_getInputCallback = std::bind(&InputListenerManager::GetInputCallback, instance, std::placeholders::_1);
g_setFocus = std::bind(&InputListenerManager::SetFocus, instance, std::placeholders::_1);
}
void InputListenerManager::Deinit()
{
while (!seats.empty()) {
if (seats.back().seat != nullptr) {
wl_seat_destroy(seats.back().seat);
seats.back().seat = nullptr;
}
if (seats.back().pointer != nullptr) {
wl_pointer_destroy(seats.back().pointer);
seats.back().pointer = nullptr;
}
if (seats.back().keyboard != nullptr) {
wl_keyboard_destroy(seats.back().keyboard);
seats.back().keyboard = nullptr;
}
if (seats.back().touch != nullptr) {
wl_touch_destroy(seats.back().touch);
seats.back().touch = nullptr;
}
seats.pop_back();
}
g_getFocus = []() { return InputListeners(); };
g_getInputCallback = [](void *) { return InputListeners(); };
g_setFocus = [](void *) {};
}
InputListenerManager::~InputListenerManager()
{
Deinit();
}
sptr<InputListenerManager> InputListenerManager::GetInstance()
{
if (instance == nullptr) {
static std::mutex mutex;
std::lock_guard<std::mutex> lock(mutex);
if (instance == nullptr) {
instance = new InputListenerManager();
}
}
return instance;
}
sptr<InputListener> InputListenerManager::AddListener(void *window)
{
sptr<InputListener> listener = new InputListener(window);
if (listener == nullptr) {
return nullptr;
}
if (inputListenersMap.find(window) == inputListenersMap.end()) {
inputListenersMap[window] = std::vector<sptr<InputListener>>();
}
inputListenersMap[window].push_back(listener);
return listener;
}
void InputListenerManager::RemoveListener(sptr<InputListener> &listener)
{
if (listener == nullptr) {
return;
}
auto &v = inputListenersMap[listener->GetWindow()];
auto match = [&listener](const auto &l) {
return listener == l;
};
auto it = std::find_if(v.begin(), v.end(), match);
if (it != v.end()) {
v.erase(it);
}
if (v.empty()) {
inputListenersMap.erase(listener->GetWindow());
}
}
InputListeners InputListenerManager::GetFocus()
{
return GetInputCallback(focus);
}
void InputListenerManager::SetFocus(void *window)
{
focus = window;
}
InputListeners InputListenerManager::GetInputCallback(void *window)
{
static InputListeners nullInputCallback;
if (inputListenersMap.find(window) == inputListenersMap.end()) {
return nullInputCallback;
}
return inputListenersMap[window];
}
void InputListenerManager::OnAppear(const GetServiceFunc get, const std::string &iname, uint32_t ver)
{
if (iname == "wl_seat") {
constexpr uint32_t wlSeatVersion = 1;
struct wl_seat *s = static_cast<struct wl_seat *>(get(&wl_seat_interface, wlSeatVersion));
if (s == nullptr) {
return;
}
Seat seat = {
.seat = s,
};
seats.push_back(seat);
static struct wl_seat_listener listener = { SeatHandleCapabilities };
wl_seat_add_listener(s, &listener, nullptr);
}
}
void InputListenerManager::SeatHandleCapabilities(void *, struct wl_seat * seat, uint32_t caps)
{
InputListenerManager::RegisterPointerListener(caps, seat);
InputListenerManager::RegisterKeyboardListener(caps, seat);
InputListenerManager::RegisterTouchListener(caps, seat);
}
namespace {
void OnPointerEnter(void *, struct wl_pointer *,
uint32_t serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy)
{
double x = wl_fixed_to_double(sx);
double y = wl_fixed_to_double(sy);
auto window = static_cast<void *>(wl_surface_get_user_data(surface));
g_setFocus(window);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->pointerEnter) {
listener->pointerEnter(window, serial, x, y);
}
}
}
void OnPointerLeave(void *, struct wl_pointer *,
uint32_t serial, struct wl_surface *surface)
{
auto window = static_cast<void *>(wl_surface_get_user_data(surface));
const auto &inputListeners = g_getInputCallback(window);
for (const auto &listener : inputListeners) {
if (listener->pointerLeave) {
listener->pointerLeave(window, serial);
}
}
}
void OnPointerMotion(void *, struct wl_pointer *,
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
{
double x = wl_fixed_to_double(sx);
double y = wl_fixed_to_double(sy);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->pointerMotion) {
listener->pointerMotion(listener->GetWindow(), time, x, y);
}
}
}
void OnPointerButton(void *, struct wl_pointer *,
uint32_t serial, uint32_t time, uint32_t button, uint32_t s)
{
auto state = static_cast<PointerButtonState>(s);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->pointerButton) {
listener->pointerButton(listener->GetWindow(), serial, time, button, state);
}
}
}
void OnPointerAxis(void *, struct wl_pointer *,
uint32_t time, uint32_t a, wl_fixed_t v)
{
auto value = wl_fixed_to_double(v);
auto axis = static_cast<PointerAxis>(a);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->pointerAxis) {
listener->pointerAxis(listener->GetWindow(), time, axis, value);
}
}
}
void OnPointerFrame(void *, struct wl_pointer *)
{
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->pointerFrame) {
listener->pointerFrame(listener->GetWindow());
}
}
}
void OnPointerAxisSource(void *, struct wl_pointer *,
uint32_t as)
{
auto axisSource = static_cast<PointerAxisSource>(as);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->pointerAxisSource) {
listener->pointerAxisSource(listener->GetWindow(), axisSource);
}
}
}
void OnPointerAxisStop(void *, struct wl_pointer *,
uint32_t time, uint32_t a)
{
auto axis = static_cast<PointerAxis>(a);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->pointerAxisStop) {
listener->pointerAxisStop(listener->GetWindow(), time, axis);
}
}
}
void OnPointerAxisDiscrete(void *, struct wl_pointer *,
uint32_t a, int32_t discrete)
{
auto axis = static_cast<PointerAxis>(a);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->pointerAxisDiscrete) {
listener->pointerAxisDiscrete(listener->GetWindow(), axis, discrete);
}
}
}
void OnKeyboardKeymap(void *, struct wl_keyboard *,
uint32_t f, int32_t fd, uint32_t size)
{
auto format = static_cast<KeyboardKeymapFormat>(f);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->keyboardKeymap) {
listener->keyboardKeymap(listener->GetWindow(), format, fd, size);
}
}
}
void OnKeyboardEnter(void *, struct wl_keyboard *,
uint32_t serial, struct wl_surface *surface, struct wl_array *ks)
{
std::vector<uint32_t> keys;
auto k = static_cast<uint32_t *>(ks->data);
while (reinterpret_cast<const char *>(k) < reinterpret_cast<const char *>(ks->data) + ks->size) {
keys.push_back(*k++);
}
auto window = static_cast<void *>(wl_surface_get_user_data(surface));
g_setFocus(window);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->keyboardEnter) {
listener->keyboardEnter(listener->GetWindow(), serial, keys);
}
}
}
void OnKeyboardLeave(void *, struct wl_keyboard *,
uint32_t serial, struct wl_surface *surface)
{
auto window = static_cast<void *>(wl_surface_get_user_data(surface));
const auto &inputListeners = g_getInputCallback(window);
for (const auto &listener : inputListeners) {
if (listener->keyboardLeave) {
listener->keyboardLeave(window, serial);
}
}
}
void OnKeyboardKey(void *, struct wl_keyboard *,
uint32_t serial, uint32_t time, uint32_t key, uint32_t s)
{
auto state = static_cast<KeyboardKeyState>(s);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->keyboardKey) {
listener->keyboardKey(listener->GetWindow(), serial, time, key, state);
}
}
}
void OnKeyboardModifiers(void *, struct wl_keyboard *,
uint32_t serial, uint32_t modsDepressed,
uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
{
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->keyboardModifiers) {
listener->keyboardModifiers(listener->GetWindow(), serial, modsDepressed, modsLatched, modsLocked, group);
}
}
}
void OnKeyboardRepeatInfo(void *, struct wl_keyboard *,
int32_t rate, int32_t delay)
{
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->keyboardRepeatInfo) {
listener->keyboardRepeatInfo(listener->GetWindow(), rate, delay);
}
}
}
void OnTouchDown(void *, struct wl_touch *,
uint32_t serial, uint32_t time,
struct wl_surface *surface,
int32_t id, wl_fixed_t tx, wl_fixed_t ty)
{
double x = wl_fixed_to_double(tx);
double y = wl_fixed_to_double(ty);
auto window = static_cast<void *>(wl_surface_get_user_data(surface));
g_setFocus(window);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->touchDown) {
listener->touchDown(listener->GetWindow(), serial, time, id, x, y);
}
}
}
void OnTouchUp(void *, struct wl_touch *,
uint32_t serial, uint32_t time, int32_t id)
{
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->touchUp) {
listener->touchUp(listener->GetWindow(), serial, time, id);
}
}
}
void OnTouchMotion(void *, struct wl_touch *,
uint32_t time, int32_t id, wl_fixed_t tx, wl_fixed_t ty)
{
double x = wl_fixed_to_double(tx);
double y = wl_fixed_to_double(ty);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->touchMotion) {
listener->touchMotion(listener->GetWindow(), time, id, x, y);
}
}
}
void OnTouchFrame(void *, struct wl_touch *)
{
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->touchFrame) {
listener->touchFrame(listener->GetWindow());
}
}
}
void OnTouchCancel(void *, struct wl_touch *)
{
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->touchCancel) {
listener->touchCancel(listener->GetWindow());
}
}
}
void OnTouchShape(void *, struct wl_touch *,
int32_t id, wl_fixed_t ma, wl_fixed_t mi)
{
double major = wl_fixed_to_double(ma);
double minor = wl_fixed_to_double(mi);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->touchShape) {
listener->touchShape(listener->GetWindow(), id, major, minor);
}
}
}
void OnTouchOrientation(void *, struct wl_touch *,
int32_t id, wl_fixed_t o)
{
double orientation = wl_fixed_to_double(o);
const auto &inputListeners = g_getFocus();
for (const auto &listener : inputListeners) {
if (listener->touchOrientation) {
listener->touchOrientation(listener->GetWindow(), id, orientation);
}
}
}
} // namespace
uint32_t InputListenerManager::FindSeatNum(struct wl_seat *seat)
{
uint32_t num = 1;
for (uint32_t i = 0; i < seats.size(); i++) {
if (seat == seats[i].seat) {
num = i;
break;
}
}
return num;
}
void InputListenerManager::RegisterPointerListener(uint32_t caps, struct wl_seat *seat)
{
struct wl_pointer *pointer = nullptr;
uint32_t num = FindSeatNum(seat);
pointer = seats[num].pointer;
bool havePointerCapability = !!(caps & WL_SEAT_CAPABILITY_POINTER);
if (havePointerCapability == true && pointer == nullptr) {
static struct wl_pointer_listener listener = {
OnPointerEnter,
OnPointerLeave,
OnPointerMotion,
OnPointerButton,
OnPointerAxis,
OnPointerFrame,
OnPointerAxisSource,
OnPointerAxisStop,
OnPointerAxisDiscrete,
};
pointer = wl_seat_get_pointer(seat);
if (pointer) {
wl_pointer_add_listener(pointer, &listener, nullptr);
}
}
if (havePointerCapability == false && pointer != nullptr) {
wl_pointer_destroy(pointer);
pointer = nullptr;
}
seats[num].pointer = pointer;
}
void InputListenerManager::RegisterKeyboardListener(uint32_t caps, struct wl_seat *seat)
{
struct wl_keyboard *keyboard = nullptr;
uint32_t num = FindSeatNum(seat);
keyboard = seats[num].keyboard;
bool haveKeyboardCapability = !!(caps & WL_SEAT_CAPABILITY_KEYBOARD);
if (haveKeyboardCapability == true && keyboard == nullptr) {
static struct wl_keyboard_listener listener = {
OnKeyboardKeymap,
OnKeyboardEnter,
OnKeyboardLeave,
OnKeyboardKey,
OnKeyboardModifiers,
OnKeyboardRepeatInfo,
};
keyboard = wl_seat_get_keyboard(seat);
if (keyboard) {
wl_keyboard_add_listener(keyboard, &listener, nullptr);
}
}
if (haveKeyboardCapability == false && keyboard != nullptr) {
wl_keyboard_destroy(keyboard);
keyboard = nullptr;
}
seats[num].keyboard = keyboard;
}
void InputListenerManager::RegisterTouchListener(uint32_t caps, struct wl_seat *seat)
{
struct wl_touch *touch = nullptr;
uint32_t num = FindSeatNum(seat);
touch = seats[num].touch;
bool haveTouchCapability = !!(caps & WL_SEAT_CAPABILITY_TOUCH);
if (haveTouchCapability == true && touch == nullptr) {
static const struct wl_touch_listener listener = {
OnTouchDown,
OnTouchUp,
OnTouchMotion,
OnTouchFrame,
OnTouchCancel,
OnTouchShape,
OnTouchOrientation,
};
touch = wl_seat_get_touch(seat);
if (touch) {
wl_touch_add_listener(touch, &listener, nullptr);
}
}
if (haveTouchCapability == false && touch != nullptr) {
wl_touch_destroy(touch);
touch = nullptr;
}
seats[num].touch = touch;
}
} // namespace OHOS

View File

@ -1,187 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "log_listener.h"
#include <bytrace.h>
#include <mutex>
#include "window_manager_hilog.h"
namespace OHOS {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "WMLogListener" };
} // namespace
sptr<LogListener> LogListener::GetInstance()
{
if (instance == nullptr) {
static std::mutex mutex;
std::lock_guard<std::mutex> lock(mutex);
if (instance == nullptr) {
instance = new LogListener();
}
}
return instance;
}
sptr<InputListener> LogListener::AddListener(void *window)
{
auto l = delegator.Dep<InputListenerManager>()->AddListener(window);
l->pointerEnter = std::bind(&LogListener::PointerHandleEnter, this, POINTER_ENTER_ARG);
l->pointerLeave = std::bind(&LogListener::PointerHandleLeave, this, POINTER_LEAVE_ARG);
l->pointerMotion = std::bind(&LogListener::PointerHandleMotion, this, POINTER_MOTION_ARG);
l->pointerButton = std::bind(&LogListener::PointerHandleButton, this, POINTER_BUTTON_ARG);
l->pointerFrame = std::bind(&LogListener::PointerHandleFrame, this, POINTER_FRAME_ARG);
l->pointerAxis = std::bind(&LogListener::PointerHandleAxis, this, POINTER_AXIS_ARG);
l->pointerAxisSource = std::bind(&LogListener::PointerHandleAxisSource, this, POINTER_AXIS_SOURCE_ARG);
l->pointerAxisStop = std::bind(&LogListener::PointerHandleAxisStop, this, POINTER_AXIS_STOP_ARG);
l->pointerAxisDiscrete = std::bind(&LogListener::PointerHandleAxisDiscrete, this, POINTER_AXIS_DISCRETE_ARG);
l->keyboardKeymap = std::bind(&LogListener::KeyboardHandleKeyMap, this, KEYBOARD_KEYMAP_ARG);
l->keyboardEnter = std::bind(&LogListener::KeyboardHandleEnter, this, KEYBOARD_ENTER_ARG);
l->keyboardLeave = std::bind(&LogListener::KeyboardHandleLeave, this, KEYBOARD_LEAVE_ARG);
l->keyboardKey = std::bind(&LogListener::KeyboardHandleKey, this, KEYBOARD_KEY_ARG);
l->keyboardModifiers = std::bind(&LogListener::KeyboardHandleModifiers, this, KEYBOARD_MODIFIERS_ARG);
l->keyboardRepeatInfo = std::bind(&LogListener::KeyboardHandleRepeatInfo, this, KEYBOARD_REPEAT_INFO_ARG);
l->touchDown = std::bind(&LogListener::TouchHandleDown, this, TOUCH_DOWN_ARG);
l->touchUp = std::bind(&LogListener::TouchHandleUp, this, TOUCH_UP_ARG);
l->touchMotion = std::bind(&LogListener::TouchHandleMotion, this, TOUCH_MOTION_ARG);
l->touchFrame = std::bind(&LogListener::TouchHandleFrame, this, TOUCH_FRAME_ARG);
l->touchCancel = std::bind(&LogListener::TouchHandleCancel, this, TOUCH_CANCEL_ARG);
l->touchShape = std::bind(&LogListener::TouchHandleShape, this, TOUCH_SHAPE_ARG);
l->touchOrientation = std::bind(&LogListener::TouchHandleOrientation, this, TOUCH_ORIENTATION_ARG);
return l;
}
void LogListener::RemoveListener(sptr<InputListener> &listener)
{
delegator.Dep<InputListenerManager>()->RemoveListener(listener);
}
void LogListener::PointerHandleEnter(void *data, uint32_t sss, double x, double y)
{
WMLOGFD("");
}
void LogListener::PointerHandleLeave(void *data, uint32_t sss)
{
WMLOGFD("");
}
void LogListener::PointerHandleMotion(void *data, uint32_t time, double x, double y)
{
WMLOGFD("");
}
void LogListener::PointerHandleButton(void *data, uint32_t sss,
uint32_t time, uint32_t button, PointerButtonState state)
{
WMLOGFD("");
}
void LogListener::PointerHandleFrame(void *data)
{
WMLOGFD("");
}
void LogListener::PointerHandleAxis(void *data, uint32_t time, PointerAxis axis, double value)
{
WMLOGFD("");
}
void LogListener::PointerHandleAxisSource(void *data, PointerAxisSource axisSource)
{
WMLOGFD("");
}
void LogListener::PointerHandleAxisStop(void *data, uint32_t time, PointerAxis axis)
{
WMLOGFD("");
}
void LogListener::PointerHandleAxisDiscrete(void *data, PointerAxis axis, int32_t discrete)
{
WMLOGFD("");
}
void LogListener::KeyboardHandleKeyMap(void *data,
KeyboardKeymapFormat format, int32_t fd, uint32_t size)
{
WMLOGFD("");
}
void LogListener::KeyboardHandleEnter(void *data, uint32_t sss, const std::vector<uint32_t> &keys)
{
WMLOGFD("");
}
void LogListener::KeyboardHandleLeave(void *data, uint32_t sss)
{
WMLOGFD("");
}
void LogListener::KeyboardHandleKey(void *data,
uint32_t sss, uint32_t time, uint32_t key, KeyboardKeyState state)
{
WMLOGFD("");
}
void LogListener::KeyboardHandleModifiers(void *data, uint32_t sss,
uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
{
WMLOGFD("");
}
void LogListener::KeyboardHandleRepeatInfo(void *data, int32_t rate, int32_t delay)
{
WMLOGFD("");
}
void LogListener::TouchHandleDown(void *data,
uint32_t sss, uint32_t time, int32_t id, double x, double y)
{
WMLOGFD("");
}
void LogListener::TouchHandleUp(void *data, uint32_t sss, uint32_t time, int32_t id)
{
WMLOGFD("");
}
void LogListener::TouchHandleMotion(void *data, uint32_t time, int32_t id, double x, double y)
{
WMLOGFD("");
}
void LogListener::TouchHandleFrame(void *data)
{
WMLOGFD("");
}
void LogListener::TouchHandleCancel(void *data)
{
WMLOGFD("");
}
void LogListener::TouchHandleShape(void *data, int32_t id, double major, double minor)
{
WMLOGFD("");
}
void LogListener::TouchHandleOrientation(void *data, int32_t id, double orientation)
{
WMLOGFD("");
}
}

View File

@ -18,7 +18,6 @@
#include <mutex>
#include <wayland-client-protocol.h>
#include <window_manager_input_type.h>
#include "window_manager_hilog.h"
#include "wl_display.h"
@ -108,8 +107,8 @@ GSError WaylandService::Start()
return GSERROR_API_FAILED;
}
g_appear = std::bind(&WaylandService::Appear, this, __BIND3_ARGS);
g_remove = std::bind(&WaylandService::Remove, this, __BIND1_ARGS);
g_appear = std::bind(&WaylandService::Appear, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
g_remove = std::bind(&WaylandService::Remove, this, std::placeholders::_1);
return GSERROR_OK;
}

View File

@ -170,9 +170,6 @@ GSError WindowImpl::Create(sptr<Window> &window,
return wret;
}
wi->logListener = SingletonContainer::Get<LogListener>()->AddListener(wi.GetRefPtr());
wi->exportListener = SingletonContainer::Get<InputListenerManager>()->AddListener(wi.GetRefPtr());
window = wi;
WMLOGFI("Create Window Success");
return GSERROR_OK;
@ -424,160 +421,6 @@ GSError WindowImpl::OnKey(OnKeyFunc cb)
return GSERROR_OK;
}
GSError WindowImpl::OnPointerEnter(PointerEnterFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerEnter = func;
return GSERROR_OK;
}
GSError WindowImpl::OnPointerLeave(PointerLeaveFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerLeave = func;
return GSERROR_OK;
}
GSError WindowImpl::OnPointerMotion(PointerMotionFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerMotion = func;
return GSERROR_OK;
}
GSError WindowImpl::OnPointerButton(PointerButtonFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerButton = func;
return GSERROR_OK;
}
GSError WindowImpl::OnPointerFrame(PointerFrameFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerFrame = func;
return GSERROR_OK;
}
GSError WindowImpl::OnPointerAxis(PointerAxisFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerAxis = func;
return GSERROR_OK;
}
GSError WindowImpl::OnPointerAxisSource(PointerAxisSourceFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerAxisSource = func;
return GSERROR_OK;
}
GSError WindowImpl::OnPointerAxisStop(PointerAxisStopFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerAxisStop = func;
return GSERROR_OK;
}
GSError WindowImpl::OnPointerAxisDiscrete(PointerAxisDiscreteFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->pointerAxisDiscrete = func;
return GSERROR_OK;
}
GSError WindowImpl::OnKeyboardKeymap(KeyboardKeymapFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->keyboardKeymap = func;
return GSERROR_OK;
}
GSError WindowImpl::OnKeyboardEnter(KeyboardEnterFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->keyboardEnter = func;
return GSERROR_OK;
}
GSError WindowImpl::OnKeyboardLeave(KeyboardLeaveFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->keyboardLeave = func;
return GSERROR_OK;
}
GSError WindowImpl::OnKeyboardKey(KeyboardKeyFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->keyboardKey = func;
return GSERROR_OK;
}
GSError WindowImpl::OnKeyboardModifiers(KeyboardModifiersFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->keyboardModifiers = func;
return GSERROR_OK;
}
GSError WindowImpl::OnKeyboardRepeatInfo(KeyboardRepeatInfoFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->keyboardRepeatInfo = func;
return GSERROR_OK;
}
GSError WindowImpl::OnTouchDown(TouchDownFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->touchDown = func;
return GSERROR_OK;
}
GSError WindowImpl::OnTouchUp(TouchUpFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->touchUp = func;
return GSERROR_OK;
}
GSError WindowImpl::OnTouchMotion(TouchMotionFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->touchMotion = func;
return GSERROR_OK;
}
GSError WindowImpl::OnTouchFrame(TouchFrameFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->touchFrame = func;
return GSERROR_OK;
}
GSError WindowImpl::OnTouchCancel(TouchCancelFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->touchCancel = func;
return GSERROR_OK;
}
GSError WindowImpl::OnTouchShape(TouchShapeFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->touchShape = func;
return GSERROR_OK;
}
GSError WindowImpl::OnTouchOrientation(TouchOrientationFunc func)
{
CHECK_DESTROY(GSERROR_DESTROYED_OBJECT);
exportListener->touchOrientation = func;
return GSERROR_OK;
}
namespace {
void BufferRelease(struct wl_buffer *wbuffer, int32_t fence)
{
@ -642,14 +485,6 @@ void WindowImpl::OnBufferAvailable()
WindowImpl::~WindowImpl()
{
if (logListener != nullptr) {
SingletonContainer::Get<LogListener>()->RemoveListener(logListener);
}
if (exportListener != nullptr) {
SingletonContainer::Get<InputListenerManager>()->RemoveListener(exportListener);
}
if (csurface != nullptr) {
csurface->UnregisterConsumerListener();
}

View File

@ -61,7 +61,6 @@ void WindowManagerImpl::InitSingleton()
{
if (initSingleton == false) {
initSingleton = true;
inputListenerManager = SingletonContainer::Get<InputListenerManager>();
windowManagerServer = SingletonContainer::Get<WindowManagerServer>();
wlBufferCache = SingletonContainer::Get<WlBufferCache>();
wlDMABufferFactory = SingletonContainer::Get<WlDMABufferFactory>();
@ -69,7 +68,6 @@ void WindowManagerImpl::InitSingleton()
wlSubsurfaceFactory = SingletonContainer::Get<WlSubsurfaceFactory>();
wlSurfaceFactory = SingletonContainer::Get<WlSurfaceFactory>();
inputListenerManager->Init();
windowManagerServer->Init();
wlBufferCache->Init();
wlDMABufferFactory->Init();
@ -136,7 +134,6 @@ void WindowManagerImpl::DeinitSingleton()
wlDMABufferFactory->Deinit();
wlBufferCache->Deinit();
windowManagerServer->Deinit();
inputListenerManager->Deinit();
waylandService = nullptr;
wlSurfaceFactory = nullptr;
@ -145,7 +142,6 @@ void WindowManagerImpl::DeinitSingleton()
wlDMABufferFactory = nullptr;
wlBufferCache = nullptr;
windowManagerServer = nullptr;
inputListenerManager = nullptr;
display->Roundtrip();
}

View File

@ -19,8 +19,6 @@ group("unittest") {
testonly = true
deps = [
":input_listener_manager_test",
":log_listener_test",
":subwindow_normal_impl_test",
":subwindow_option_impl_test",
":wayland_service_test",
@ -38,28 +36,6 @@ group("unittest") {
]
}
## UnitTest input_listener_manager_test {{{
ohos_unittest("input_listener_manager_test") {
module_out_path = module_out_path
sources = [ "input_listener_manager_test.cpp" ]
deps = [ ":wm_test_common" ]
}
## UnitTest input_listener_manager_test }}}
## UnitTest log_listener_test {{{
ohos_unittest("log_listener_test") {
module_out_path = module_out_path
sources = [ "log_listener_test.cpp" ]
deps = [ ":wm_test_common" ]
}
## UnitTest log_listener_test }}}
## UnitTest subwindow_normal_impl_test {{{
ohos_unittest("subwindow_normal_impl_test") {
module_out_path = module_out_path

View File

@ -1,202 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "input_listener_manager_test.h"
namespace OHOS {
void InputListenerManagerTest::SetUp()
{
}
void InputListenerManagerTest::TearDown()
{
}
void InputListenerManagerTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << getpid() << std::endl;
initRet = WindowManager::GetInstance()->Init();
}
void InputListenerManagerTest::TearDownTestCase()
{
}
namespace {
/*
* Feature: InputListenerManager AddListener
* Function: InputListenerManager
* SubFunction: AddListener
* FunctionPoints: InputListenerManager AddListener
* EnvConditions: WindowManager init success.
* CaseDescription: 1. add listener[0] by an address A
* 2. check listener[0]
* a. check listener[0] isn't nullptr
* b. check listener[0].GetWindow() is address A
* c. check map size is 1
* d. check vector size of address A is 1
* 3. add listener[1] by nullptr
* 4. check listener[1]
* a. check listener[1] isn't nullptr
* b. check listener[1].GetWindow() is nullptr
* c. check map size is 2
* d. check vector size of nullptr is 1
* 5. add listener[2] by the address A
* 6. check listener[2]
* a. check listener[2] isn't nullptr
* b. check listener[2].GetWindow() is address A
* c. check map size is 2
* d. check vector size of address A is 2
* 7. add listener[3] by nullptr
* 8. check listener[3]
* a. check listener[3] isn't nullptr
* b. check listener[3].GetWindow() is nullptr
* c. check map size is 2
* d. check vector size of nullptr is 2
*/
HWTEST_F(InputListenerManagerTest, AddListener, testing::ext::TestSize.Level0)
{
// WindowManager init success.
ASSERT_EQ(initRet, GSERROR_OK) << "EnvConditions: WindowManager init success. (initRet == GSERROR_OK)";
auto manager = InputListenerManager::GetInstance();
// 1. add listener[0] by an address A
listener[0] = manager->AddListener(&addressA);
// 2. check listener[0]
{
// a. check listener[0] isn't nullptr
ASSERT_NE(listener[0], nullptr) << "CaseDescription:"
<< " 2.a check listener[0] isn't nullptr (listener[0] != nullptr)";
// b. check listener[0].GetWindow() is address A
ASSERT_EQ(listener[0]->GetWindow(), &addressA) << "CaseDescription:"
<< " 2.b. check listener[0].GetWindow() is address A (listener[0].GetWindow() == address A)";
// c. check map size is 1
ASSERT_EQ(manager->inputListenersMap.size(), 1u) << "CaseDescription:"
<< " 2.c check map size is 1 (map.size() == 1)";
// d. check vector size of address A is 1
ASSERT_EQ(manager->inputListenersMap[&addressA].size(), 1u) << "CaseDescription:"
<< " 2.d check vector size of address A is 1 (vector.size() == 1)";
}
// 3. add listener[1] by nullptr
listener[1] = manager->AddListener(nullptr);
// 4. check listener[1]
{
// a. check listener[1] isn't nullptr
ASSERT_NE(listener[1], nullptr) << "CaseDescription:"
<< " 4.a check listener[1] isn't nullptr (listener[1] != nullptr)";
// b. check listener[1].GetWindow() is address A
ASSERT_EQ(listener[1]->GetWindow(), nullptr) << "CaseDescription:"
<< " 4.b. check listener[1].GetWindow() is address A (listener[1].GetWindow() == nullptr)";
// c. check map size is 2
ASSERT_EQ(manager->inputListenersMap.size(), 2u) << "CaseDescription:"
<< " 4.c check map size is 2 (map.size() == 2)";
// d. check vector size of nullptr is 1
ASSERT_EQ(manager->inputListenersMap[nullptr].size(), 1u) << "CaseDescription:"
<< " 4.d check vector size of nullptr is 1 (vector.size() == 1)";
}
// 5. add listener[2] by the address A
listener[2] = manager->AddListener(&addressA);
// 6. check listener[2]
{
// a. check listener[2] isn't nullptr
ASSERT_NE(listener[2], nullptr) << "CaseDescription:"
<< " 6.a check listener[2] isn't nullptr (listener[2] != nullptr)";
// b. check listener[2].GetWindow() is address A
ASSERT_EQ(listener[2]->GetWindow(), &addressA) << "CaseDescription:"
<< " 6.b. check listener[2].GetWindow() is address A (listener[2].GetWindow() == address A)";
// c. check map size is 2
ASSERT_EQ(manager->inputListenersMap.size(), 2u) << "CaseDescription:"
<< " 6.c check map size is 2 (map.size() == 2)";
// d. check vector size of address A is 2
ASSERT_EQ(manager->inputListenersMap[&addressA].size(), 2u) << "CaseDescription:"
<< " 6.d check vector size of address A is 2 (vector.size() == 2)";
}
// 7. add listener[3] by nullptr
listener[3] = manager->AddListener(nullptr);
// 8. check listener[3]
{
// a. check listener[3] isn't nullptr
ASSERT_NE(listener[3], nullptr) << "CaseDescription:"
<< " 8.a check listener[3] isn't nullptr (listener[3] != nullptr)";
// b. check listener[3].GetWindow() is address A
ASSERT_EQ(listener[3]->GetWindow(), nullptr) << "CaseDescription:"
<< " 8.b. check listener[3].GetWindow() is address A (listener[3].GetWindow() == nullptr)";
// c. check map size is 2
ASSERT_EQ(manager->inputListenersMap.size(), 2u) << "CaseDescription:"
<< " 8.c check map size is 2 (map.size() == 2)";
// d. check vector size of nullptr is 2
ASSERT_EQ(manager->inputListenersMap[nullptr].size(), 2u) << "CaseDescription:"
<< " 8.d check vector size of nullptr is 2 (vector.size() == 2)";
}
}
/*
* Feature: InputListenerManager RemoveListener
* Function: InputListenerManager
* SubFunction: RemoveListener
* FunctionPoints: InputListenerManager RemoveListener
* EnvConditions: WindowManager init success.
* CaseDescription: 1. remove listener[0]
* 2. check map size is 2, check vector size of address A is 1
* 3. remove listener[2]
* 4. check map size is 1
* 5. remove listener[1], listener[3]
* 6. check map size is 0
*/
HWTEST_F(InputListenerManagerTest, RemoveListener, testing::ext::TestSize.Level0)
{
// WindowManager init success.
ASSERT_EQ(initRet, GSERROR_OK) << "EnvConditions: WindowManager init success. (initRet == GSERROR_OK)";
auto manager = InputListenerManager::GetInstance();
// 1. remove listener[0]
ASSERT_NE(listener[0], nullptr) << "CaseDescription: 1. remove listener[0] (listener[0] != nullptr)";
manager->RemoveListener(listener[0]);
// 2. check map size is 2, check vector size of address A is 1
ASSERT_EQ(manager->inputListenersMap.size(), 2u) << "CaseDescription:"
<< " 2. check map size is 2 (map.size() == 2)";
ASSERT_EQ(manager->inputListenersMap[&addressA].size(), 1u) << "CaseDescription:"
<< " 2. check vector size of address A is 1 (vector.size() == 1)";
// 3. remove listener[2]
ASSERT_NE(listener[2], nullptr) << "CaseDescription: 3. remove listener[2] (listener[2] != nullptr)";
manager->RemoveListener(listener[2]);
// 4. check map size is 1
ASSERT_EQ(manager->inputListenersMap.size(), 1u) << "CaseDescription:"
<< " 4. check map size is 1 (map.size() == 1)";
// 5. remove listener[1], listener[3]
ASSERT_NE(listener[1], nullptr) << "CaseDescription: 5. remove listener[1] (listener[1] != nullptr)";
ASSERT_NE(listener[3], nullptr) << "CaseDescription: 5. remove listener[3] (listener[3] != nullptr)";
manager->RemoveListener(listener[1]);
manager->RemoveListener(listener[3]);
// 6. check map size is 0
ASSERT_EQ(manager->inputListenersMap.size(), 0u) << "CaseDescription:"
<< " 6. check map size is 0 (map.size() == 0)";
}
} // namespace
} // namespace OHOS

View File

@ -1,40 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_WM_TEST_UNITTEST_INPUT_LISTENER_MANAGER_TEST_H
#define FRAMEWORKS_WM_TEST_UNITTEST_INPUT_LISTENER_MANAGER_TEST_H
#include <gtest/gtest.h>
#include <refbase.h>
#include <window_manager.h>
#include "input_listener_manager.h"
namespace OHOS {
class InputListenerManagerTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
virtual void SetUp() override;
virtual void TearDown() override;
private:
static inline GSError initRet = GSERROR_NOT_INIT;
static inline sptr<InputListener> listener[4] = {};
static inline int32_t addressA = 0;
};
}
#endif // FRAMEWORKS_WM_TEST_UNITTEST_INPUT_LISTENER_MANAGER_TEST_H

View File

@ -1,204 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "log_listener_test.h"
namespace OHOS {
void LogListenerTest::SetUp()
{
}
void LogListenerTest::TearDown()
{
}
void LogListenerTest::SetUpTestCase()
{
GTEST_LOG_(INFO) << getpid() << std::endl;
initRet = WindowManager::GetInstance()->Init();
}
void LogListenerTest::TearDownTestCase()
{
}
namespace {
/*
* Feature: LogListener AddListener
* Function: LogListener
* SubFunction: AddListener
* FunctionPoints: LogListener AddListener
* EnvConditions: WindowManager init success.
* CaseDescription: 1. add listener[0] by an address A
* 2. check listener[0]
* a. check listener[0] isn't nullptr
* b. check listener[0].GetWindow() is address A
* c. check map size is 1
* d. check vector size of address A is 1
* 3. add listener[1] by nullptr
* 4. check listener[1]
* a. check listener[1] isn't nullptr
* b. check listener[1].GetWindow() is nullptr
* c. check map size is 2
* d. check vector size of nullptr is 1
* 5. add listener[2] by the address A
* 6. check listener[2]
* a. check listener[2] isn't nullptr
* b. check listener[2].GetWindow() is address A
* c. check map size is 2
* d. check vector size of address A is 2
* 7. add listener[3] by nullptr
* 8. check listener[3]
* a. check listener[3] isn't nullptr
* b. check listener[3].GetWindow() is nullptr
* c. check map size is 2
* d. check vector size of nullptr is 2
*/
HWTEST_F(LogListenerTest, AddListener, testing::ext::TestSize.Level0)
{
// WindowManager init success.
ASSERT_EQ(initRet, GSERROR_OK) << "EnvConditions: WindowManager init success. (initRet == GSERROR_OK)";
auto ll = LogListener::GetInstance();
auto manager = InputListenerManager::GetInstance();
// 1. add listener[0] by an address A
listener[0] = ll->AddListener(&addressA);
// 2. check listener[0]
{
// a. check listener[0] isn't nullptr
ASSERT_NE(listener[0], nullptr) << "CaseDescription:"
<< " 2.a check listener[0] isn't nullptr (listener[0] != nullptr)";
// b. check listener[0].GetWindow() is address A
ASSERT_EQ(listener[0]->GetWindow(), &addressA) << "CaseDescription:"
<< " 2.b. check listener[0].GetWindow() is address A (listener[0].GetWindow() == address A)";
// c. check map size is 1
ASSERT_EQ(manager->inputListenersMap.size(), 1u) << "CaseDescription:"
<< " 2.c check map size is 1 (map.size() == 1)";
// d. check vector size of address A is 1
ASSERT_EQ(manager->inputListenersMap[&addressA].size(), 1u) << "CaseDescription:"
<< " 2.d check vector size of address A is 1 (vector.size() == 1)";
}
// 3. add listener[1] by nullptr
listener[1] = ll->AddListener(nullptr);
// 4. check listener[1]
{
// a. check listener[1] isn't nullptr
ASSERT_NE(listener[1], nullptr) << "CaseDescription:"
<< " 4.a check listener[1] isn't nullptr (listener[1] != nullptr)";
// b. check listener[1].GetWindow() is address A
ASSERT_EQ(listener[1]->GetWindow(), nullptr) << "CaseDescription:"
<< " 4.b. check listener[1].GetWindow() is address A (listener[1].GetWindow() == nullptr)";
// c. check map size is 2
ASSERT_EQ(manager->inputListenersMap.size(), 2u) << "CaseDescription:"
<< " 4.c check map size is 2 (map.size() == 2)";
// d. check vector size of nullptr is 1
ASSERT_EQ(manager->inputListenersMap[nullptr].size(), 1u) << "CaseDescription:"
<< " 4.d check vector size of nullptr is 1 (vector.size() == 1)";
}
// 5. add listener[2] by the address A
listener[2] = ll->AddListener(&addressA);
// 6. check listener[2]
{
// a. check listener[2] isn't nullptr
ASSERT_NE(listener[2], nullptr) << "CaseDescription:"
<< " 6.a check listener[2] isn't nullptr (listener[2] != nullptr)";
// b. check listener[2].GetWindow() is address A
ASSERT_EQ(listener[2]->GetWindow(), &addressA) << "CaseDescription:"
<< " 6.b. check listener[2].GetWindow() is address A (listener[2].GetWindow() == address A)";
// c. check map size is 2
ASSERT_EQ(manager->inputListenersMap.size(), 2u) << "CaseDescription:"
<< " 6.c check map size is 2 (map.size() == 2)";
// d. check vector size of address A is 2
ASSERT_EQ(manager->inputListenersMap[&addressA].size(), 2u) << "CaseDescription:"
<< " 6.d check vector size of address A is 2 (vector.size() == 2)";
}
// 7. add listener[3] by nullptr
listener[3] = ll->AddListener(nullptr);
// 8. check listener[3]
{
// a. check listener[3] isn't nullptr
ASSERT_NE(listener[3], nullptr) << "CaseDescription:"
<< " 8.a check listener[3] isn't nullptr (listener[3] != nullptr)";
// b. check listener[3].GetWindow() is address A
ASSERT_EQ(listener[3]->GetWindow(), nullptr) << "CaseDescription:"
<< " 8.b. check listener[3].GetWindow() is address A (listener[3].GetWindow() == nullptr)";
// c. check map size is 2
ASSERT_EQ(manager->inputListenersMap.size(), 2u) << "CaseDescription:"
<< " 8.c check map size is 2 (map.size() == 2)";
// d. check vector size of nullptr is 2
ASSERT_EQ(manager->inputListenersMap[nullptr].size(), 2u) << "CaseDescription:"
<< " 8.d check vector size of nullptr is 2 (vector.size() == 2)";
}
}
/*
* Feature: LogListener RemoveListener
* Function: LogListener
* SubFunction: RemoveListener
* FunctionPoints: LogListener RemoveListener
* EnvConditions: WindowManager init success.
* CaseDescription: 1. remove listener[0]
* 2. check map size is 2, check vector size of address A is 1
* 3. remove listener[2]
* 4. check map size is 1
* 5. remove listener[1], listener[3]
* 6. check map size is 0
*/
HWTEST_F(LogListenerTest, RemoveListener, testing::ext::TestSize.Level0)
{
// WindowManager init success.
ASSERT_EQ(initRet, GSERROR_OK) << "EnvConditions: WindowManager init success. (initRet == GSERROR_OK)";
auto ll = LogListener::GetInstance();
auto manager = InputListenerManager::GetInstance();
// 1. remove listener[0]
ASSERT_NE(listener[0], nullptr) << "CaseDescription: 1. remove listener[0] (listener[0] != nullptr)";
ll->RemoveListener(listener[0]);
// 2. check map size is 2, check vector size of address A is 1
ASSERT_EQ(manager->inputListenersMap.size(), 2u) << "CaseDescription:"
<< " 2. check map size is 2 (map.size() == 2)";
ASSERT_EQ(manager->inputListenersMap[&addressA].size(), 1u) << "CaseDescription:"
<< " 2. check vector size of address A is 1 (vector.size() == 1)";
// 3. remove listener[2]
ASSERT_NE(listener[2], nullptr) << "CaseDescription: 3. remove listener[2] (listener[2] != nullptr)";
ll->RemoveListener(listener[2]);
// 4. check map size is 1
ASSERT_EQ(manager->inputListenersMap.size(), 1u) << "CaseDescription:"
<< " 4. check map size is 1 (map.size() == 1)";
// 5. remove listener[1], listener[3]
ASSERT_NE(listener[1], nullptr) << "CaseDescription: 5. remove listener[1] (listener[1] != nullptr)";
ASSERT_NE(listener[3], nullptr) << "CaseDescription: 5. remove listener[3] (listener[3] != nullptr)";
ll->RemoveListener(listener[1]);
ll->RemoveListener(listener[3]);
// 6. check map size is 0
ASSERT_EQ(manager->inputListenersMap.size(), 0u) << "CaseDescription:"
<< " 6. check map size is 0 (map.size() == 0)";
}
} // namespace
} // namespace OHOS

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_WM_TEST_UNITTEST_LOG_LISTENER_TEST_H
#define FRAMEWORKS_WM_TEST_UNITTEST_LOG_LISTENER_TEST_H
#include <gtest/gtest.h>
#include <refbase.h>
#include <window_manager.h>
#include "input_listener_manager.h"
#include "log_listener.h"
namespace OHOS {
class LogListenerTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
virtual void SetUp() override;
virtual void TearDown() override;
private:
static inline GSError initRet = GSERROR_NOT_INIT;
static inline sptr<InputListener> listener[4] = {};
static inline int32_t addressA = 0;
};
}
#endif // FRAMEWORKS_WM_TEST_UNITTEST_LOG_LISTENER_TEST_H

View File

@ -51,30 +51,8 @@ public:
MOCK_METHOD1(OnTypeChange, void(WindowTypeChangeFunc func));
MOCK_METHOD1(OnModeChange, void(WindowModeChangeFunc func));
MOCK_METHOD1(OnSplitStatusChange, void(SplitStatusChangeFunc func));
MOCK_METHOD1(OnTouch, GSError(OnTouchFunc cb));
MOCK_METHOD1(OnKey, GSError(OnKeyFunc cb));
MOCK_METHOD1(OnPointerEnter, GSError(PointerEnterFunc func));
MOCK_METHOD1(OnPointerLeave, GSError(PointerLeaveFunc func));
MOCK_METHOD1(OnPointerMotion, GSError(PointerMotionFunc func));
MOCK_METHOD1(OnPointerButton, GSError(PointerButtonFunc func));
MOCK_METHOD1(OnPointerFrame, GSError(PointerFrameFunc func));
MOCK_METHOD1(OnPointerAxis, GSError(PointerAxisFunc func));
MOCK_METHOD1(OnPointerAxisSource, GSError(PointerAxisSourceFunc func));
MOCK_METHOD1(OnPointerAxisStop, GSError(PointerAxisStopFunc func));
MOCK_METHOD1(OnPointerAxisDiscrete, GSError(PointerAxisDiscreteFunc func));
MOCK_METHOD1(OnKeyboardKeymap, GSError(KeyboardKeymapFunc func));
MOCK_METHOD1(OnKeyboardEnter, GSError(KeyboardEnterFunc func));
MOCK_METHOD1(OnKeyboardLeave, GSError(KeyboardLeaveFunc func));
MOCK_METHOD1(OnKeyboardKey, GSError(KeyboardKeyFunc func));
MOCK_METHOD1(OnKeyboardModifiers, GSError(KeyboardModifiersFunc func));
MOCK_METHOD1(OnKeyboardRepeatInfo, GSError(KeyboardRepeatInfoFunc func));
MOCK_METHOD1(OnTouchDown, GSError(TouchDownFunc func));
MOCK_METHOD1(OnTouchUp, GSError(TouchUpFunc func));
MOCK_METHOD1(OnTouchMotion, GSError(TouchMotionFunc func));
MOCK_METHOD1(OnTouchFrame, GSError(TouchFrameFunc func));
MOCK_METHOD1(OnTouchCancel, GSError(TouchCancelFunc func));
MOCK_METHOD1(OnTouchShape, GSError(TouchShapeFunc func));
MOCK_METHOD1(OnTouchOrientation, GSError(TouchOrientationFunc func));
MOCK_METHOD1(OnTouch, GSError(OnTouchFunc cb));
};
} // namespace OHOS

View File

@ -54,7 +54,8 @@ namespace {
HWTEST_F(WaylandServiceTest, Start, testing::ext::TestSize.Level0)
{
// once before all
const auto appear = std::bind(&WaylandServiceTest::OnAppear, this, __BIND3_ARGS);
const auto appear = std::bind(&WaylandServiceTest::OnAppear,
this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
WaylandService::GetInstance()->OnAppear(appear);
const auto &display = WlDisplay::GetInstance();

View File

@ -1296,147 +1296,5 @@ HWTEST_F(WindowImplTest, OnTypeChange01, Function | SmallTest | Level2)
}
}
}
/*
* Function: OnTouch
* Type: Function
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call NormalWindow OnTouch, check GSERROR_OK
*/
HWTEST_F(WindowImplTest, OnTouch01, Function | SmallTest | Level2)
{
PART("CaseDescription") {
STEP("1. call NormalWindow OnTouch, check GSERROR_OK") {
auto wret = normalWindow->OnTouch(nullptr);
STEP_ASSERT_EQ(wret, GSERROR_OK);
}
}
}
/*
* Function: OnTouch
* Type: Reliability
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call DestroyedWindow OnTouch, check GSERROR_DESTROYED_OBJECT
*/
HWTEST_F(WindowImplTest, OnTouch02, Reliability | SmallTest | Level2)
{
PART("CaseDescription") {
STEP("1. call DestroyedWindow OnTouch, check GSERROR_DESTROYED_OBJECT") {
auto wret = destroyedWindow->OnTouch(nullptr);
STEP_ASSERT_EQ(wret, GSERROR_DESTROYED_OBJECT);
}
}
}
/*
* Function: OnKey
* Type: Function
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call NormalWindow OnKey, check GSERROR_OK
*/
HWTEST_F(WindowImplTest, OnKey01, Function | SmallTest | Level2)
{
PART("CaseDescription") {
STEP("1. call NormalWindow OnKey, check GSERROR_OK") {
auto wret = normalWindow->OnKey(nullptr);
STEP_ASSERT_EQ(wret, GSERROR_OK);
}
}
}
/*
* Function: OnKey
* Type: Reliability
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call DestroyedWindow OnKey, check GSERROR_DESTROYED_OBJECT
*/
HWTEST_F(WindowImplTest, OnKey02, Reliability | SmallTest | Level2)
{
PART("CaseDescription") {
STEP("1. call DestroyedWindow OnKey, check GSERROR_DESTROYED_OBJECT") {
auto wret = destroyedWindow->OnKey(nullptr);
STEP_ASSERT_EQ(wret, GSERROR_DESTROYED_OBJECT);
}
}
}
/*
* Function: RawEvent
* Type: Reliability
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call NormalWindow listen raw event, check GSERROR_OK
*/
HWTEST_F(WindowImplTest, RawEvent01, Reliability | SmallTest | Level2)
{
PART("CaseDescription") {
STEP("1. call NormalWindow listen raw event, check GSERROR_OK") {
STEP_ASSERT_EQ(normalWindow->OnPointerEnter(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnPointerLeave(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnPointerMotion(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnPointerButton(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnPointerFrame(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnPointerAxis(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnPointerAxisSource(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnPointerAxisStop(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnPointerAxisDiscrete(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnKeyboardKeymap(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnKeyboardEnter(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnKeyboardLeave(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnKeyboardKey(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnKeyboardModifiers(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnKeyboardRepeatInfo(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnTouchDown(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnTouchUp(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnTouchMotion(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnTouchFrame(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnTouchCancel(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnTouchShape(nullptr), GSERROR_OK);
STEP_ASSERT_EQ(normalWindow->OnTouchOrientation(nullptr), GSERROR_OK);
}
}
}
/*
* Function: RawEvent
* Type: Reliability
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call DestroyedWindow listen raw event, check GSERROR_DESTROYED_OBJECT
*/
HWTEST_F(WindowImplTest, RawEvent02, Reliability | SmallTest | Level2)
{
PART("CaseDescription") {
STEP("1. call DestroyedWindow listen raw event, check GSERROR_DESTROYED_OBJECT") {
STEP_ASSERT_EQ(destroyedWindow->OnPointerEnter(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnPointerLeave(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnPointerMotion(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnPointerButton(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnPointerFrame(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnPointerAxis(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnPointerAxisSource(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnPointerAxisStop(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnPointerAxisDiscrete(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnKeyboardKeymap(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnKeyboardEnter(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnKeyboardLeave(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnKeyboardKey(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnKeyboardModifiers(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnKeyboardRepeatInfo(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnTouchDown(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnTouchUp(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnTouchMotion(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnTouchFrame(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnTouchCancel(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnTouchShape(nullptr), GSERROR_DESTROYED_OBJECT);
STEP_ASSERT_EQ(destroyedWindow->OnTouchOrientation(nullptr), GSERROR_DESTROYED_OBJECT);
}
}
}
} // namespace
} // namespace OHOS

View File

@ -52,7 +52,6 @@ ohos_executable("wmtest") {
"test/wmclient_native_test_13.cpp",
"test/wmclient_native_test_14.cpp",
"test/wmclient_native_test_15.cpp",
"test/wmclient_native_test_16.cpp",
"test/wmclient_native_test_17.cpp",
"test/wmclient_native_test_18.cpp",
"test/wmclient_native_test_19.cpp",

View File

@ -1,125 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "wmclient_native_test_16.h"
#include <cstdio>
#include <securec.h>
#include <display_type.h>
#include <window_manager.h>
#include "inative_test.h"
#include "native_test_class.h"
#include "util.h"
using namespace OHOS;
namespace {
class WMClientNativeTest16 : public INativeTest {
public:
std::string GetDescription() const override
{
constexpr const char *desc = "listener touch down and SwitchTop";
return desc;
}
std::string GetDomain() const override
{
constexpr const char *domain = "wmclient";
return domain;
}
int32_t GetID() const override
{
constexpr int32_t id = 16;
return id;
}
uint32_t GetLastTime() const override
{
constexpr uint32_t lastTime = LAST_TIME_FOREVER;
return lastTime;
}
void Run(int32_t argc, const char **argv) override
{
auto initRet = WindowManager::GetInstance()->Init();
if (initRet) {
printf("init failed with %s\n", GSErrorStr(initRet).c_str());
ExitTest();
return;
}
csurface1 = Surface::CreateSurfaceAsConsumer();
window1 = NativeTestFactory::CreateWindow(WINDOW_TYPE_NORMAL, csurface1);
if (window1 == nullptr) {
printf("NativeTestFactory::CreateWindow return nullptr\n");
return;
}
window1->SwitchTop();
auto surface1 = window1->GetSurface();
windowSync1 = NativeTestSync::CreateSync(NativeTestDraw::ColorDraw, surface1);
csurface2 = Surface::CreateSurfaceAsConsumer();
window2 = NativeTestFactory::CreateWindow(WINDOW_TYPE_NORMAL, csurface2);
if (window2 == nullptr) {
printf("NativeTestFactory::CreateWindow return nullptr\n");
return;
}
window2->SwitchTop();
auto surface2 = window2->GetSurface();
windowSync2 = NativeTestSync::CreateSync(NativeTestDraw::ColorDraw, surface2);
auto down1 = [this](void *, uint32_t, uint32_t, int32_t, double, double) { window2->SwitchTop(); };
auto down2 = [this](void *, uint32_t, uint32_t, int32_t, double, double) { window1->SwitchTop(); };
window1->OnTouchDown(down1);
window2->OnTouchDown(down2);
std::vector<struct WMDisplayInfo> displays;
WindowManager::GetInstance()->GetDisplays(displays);
if (displays.size() <= 0) {
printf("GetDisplays return no screen\n");
ExitTest();
return;
}
auto maxWidth = displays[0].width;
auto maxHeight = displays[0].height;
constexpr double percent = 0.75;
uint32_t width = percent * maxWidth;
uint32_t height = percent * maxHeight;
window1->Move(0, 0);
csurface1->SetDefaultWidthAndHeight(width, height);
window1->Resize(width, height);
window2->Move(maxWidth - width, maxHeight - height);
csurface2->SetDefaultWidthAndHeight(width, height);
window2->Resize(width, height);
}
private:
sptr<Surface> csurface1 = nullptr;
sptr<Window> window1 = nullptr;
sptr<NativeTestSync> windowSync1 = nullptr;
sptr<Surface> csurface2 = nullptr;
sptr<Window> window2 = nullptr;
sptr<NativeTestSync> windowSync2 = nullptr;
} g_autoload;
} // namespace

View File

@ -1,19 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_WMTEST_TEST_WMCLIENT_WMCLIENT_NATIVE_TEST_16_H
#define FRAMEWORKS_WMTEST_TEST_WMCLIENT_WMCLIENT_NATIVE_TEST_16_H
#endif // FRAMEWORKS_WMTEST_TEST_WMCLIENT_WMCLIENT_NATIVE_TEST_16_H

View File

@ -92,24 +92,30 @@ public:
config.usage = surface->GetDefaultUsage();
freeWindowSync = NativeTestSync::CreateSync(NativeTestDraw::RainbowDraw, surface, &config);
freeWindow->OnTouchDown(std::bind(&WMClientNativeTest27::OnTouchDown, this, TOUCH_DOWN_ARG));
freeWindow->OnTouchMotion(std::bind(&WMClientNativeTest27::OnTouchMotion, this, TOUCH_MOTION_ARG));
freeWindow->OnSizeChange(onSizeChange);
constexpr int32_t width = 300;
constexpr int32_t height = 300;
freeWindow->Resize(width, height);
ListenWindowTouchEvent(freeWindow->GetID());
}
void OnTouchDown(void *, uint32_t serial, uint32_t time, int32_t id, double x, double y)
bool OnTouch(const TouchEvent &event) override
{
downX = x;
downY = y;
}
int32_t x = event.GetPointerPosition(event.GetIndex()).GetX();
int32_t y = event.GetPointerPosition(event.GetIndex()).GetY();
if (event.GetAction() == TouchEnum::PRIMARY_POINT_DOWN) {
downX = x;
downY = y;
return false;
}
void OnTouchMotion(void *, uint32_t time, int32_t id, double x, double y)
{
freeWindow->Move(freeWindow->GetX() + x - downX, freeWindow->GetY() + y - downY)
->Then(std::bind(&WMClientNativeTest27::OnMoveReturn, this, std::placeholders::_1));
if (event.GetAction() == TouchEnum::POINT_MOVE) {
freeWindow->Move(freeWindow->GetX() + x - downX, freeWindow->GetY() + y - downY)
->Then(std::bind(&WMClientNativeTest27::OnMoveReturn, this, std::placeholders::_1));
return false;
}
return true;
}
void OnMoveReturn(const GSError &err)

View File

@ -20,7 +20,6 @@
#include <surface.h>
#include <promise.h>
#include "window_manager_input_type.h"
#include "window_manager_type.h"
namespace OHOS {
@ -61,34 +60,6 @@ public:
// listener
virtual GSError OnTouch(OnTouchFunc cb) = 0;
virtual GSError OnKey(OnKeyFunc cb) = 0;
// pointer listener
virtual GSError OnPointerEnter(PointerEnterFunc func) = 0;
virtual GSError OnPointerLeave(PointerLeaveFunc func) = 0;
virtual GSError OnPointerMotion(PointerMotionFunc func) = 0;
virtual GSError OnPointerButton(PointerButtonFunc func) = 0;
virtual GSError OnPointerFrame(PointerFrameFunc func) = 0;
virtual GSError OnPointerAxis(PointerAxisFunc func) = 0;
virtual GSError OnPointerAxisSource(PointerAxisSourceFunc func) = 0;
virtual GSError OnPointerAxisStop(PointerAxisStopFunc func) = 0;
virtual GSError OnPointerAxisDiscrete(PointerAxisDiscreteFunc func) = 0;
// keyboard listener
virtual GSError OnKeyboardKeymap(KeyboardKeymapFunc func) = 0;
virtual GSError OnKeyboardEnter(KeyboardEnterFunc func) = 0;
virtual GSError OnKeyboardLeave(KeyboardLeaveFunc func) = 0;
virtual GSError OnKeyboardKey(KeyboardKeyFunc func) = 0;
virtual GSError OnKeyboardModifiers(KeyboardModifiersFunc func) = 0;
virtual GSError OnKeyboardRepeatInfo(KeyboardRepeatInfoFunc func) = 0;
// touch listener
virtual GSError OnTouchDown(TouchDownFunc func) = 0;
virtual GSError OnTouchUp(TouchUpFunc func) = 0;
virtual GSError OnTouchMotion(TouchMotionFunc func) = 0;
virtual GSError OnTouchFrame(TouchFrameFunc func) = 0;
virtual GSError OnTouchCancel(TouchCancelFunc func) = 0;
virtual GSError OnTouchShape(TouchShapeFunc func) = 0;
virtual GSError OnTouchOrientation(TouchOrientationFunc func) = 0;
};
} // namespace OHOS

View File

@ -1,155 +0,0 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INTERFACES_INNERKITS_WMCLIENT_WINDOW_MANAGER_INPUT_TYPE_H
#define INTERFACES_INNERKITS_WMCLIENT_WINDOW_MANAGER_INPUT_TYPE_H
#include <functional>
namespace OHOS {
enum PointerButtonState {
POINTER_BUTTON_STATE_RELEASED,
POINTER_BUTTON_STATE_PRESSED,
};
enum PointerAxis {
POINTER_AXIS_VERTICAL_SCROLL,
POINTER_AXIS_HORIZONTAL_SCROLL,
};
enum PointerAxisSource {
POINTER_AXIS_SOURCE_WHEEL,
POINTER_AXIS_SOURCE_FINGER,
POINTER_AXIS_SOURCE_CONTINUOUS,
POINTER_AXIS_SOURCE_WHEEL_TILT,
};
enum KeyboardKeymapFormat {
KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP,
KEYBOARD_KEYMAP_FORMAT_XKB_V1,
};
enum KeyboardKeyState {
KEYBOARD_KEY_STATE_RELEASED,
KEYBOARD_KEY_STATE_PRESSED,
};
#define __BIND1_ARGS ::std::placeholders::_1
#define __BIND2_ARGS __BIND1_ARGS, ::std::placeholders::_2
#define __BIND3_ARGS __BIND2_ARGS, ::std::placeholders::_3
#define __BIND4_ARGS __BIND3_ARGS, ::std::placeholders::_4
#define __BIND5_ARGS __BIND4_ARGS, ::std::placeholders::_5
#define __BIND6_ARGS __BIND5_ARGS, ::std::placeholders::_6
#define __BIND7_ARGS __BIND6_ARGS, ::std::placeholders::_7
#define __BIND8_ARGS __BIND7_ARGS, ::std::placeholders::_8
#define POINTER_ENTER_ARG __BIND4_ARGS
using PointerEnterFunc = std::function<void(void *, uint32_t serial,
double x, double y)>;
#define POINTER_LEAVE_ARG __BIND2_ARGS
using PointerLeaveFunc = std::function<void(void *, uint32_t serial)>;
#define POINTER_MOTION_ARG __BIND4_ARGS
using PointerMotionFunc = std::function<void(void *, uint32_t time,
double x, double y)>;
#define POINTER_BUTTON_ARG __BIND5_ARGS
using PointerButtonFunc = std::function<void(void *, uint32_t serial,
uint32_t time,
uint32_t button,
PointerButtonState state)>;
#define POINTER_FRAME_ARG __BIND1_ARGS
using PointerFrameFunc = std::function<void(void *)>;
#define POINTER_AXIS_ARG __BIND4_ARGS
using PointerAxisFunc = std::function<void(void *, uint32_t time,
PointerAxis axis,
double value)>;
#define POINTER_AXIS_SOURCE_ARG __BIND2_ARGS
using PointerAxisSourceFunc = std::function<void(void *, PointerAxisSource axisSource)>;
#define POINTER_AXIS_STOP_ARG __BIND3_ARGS
using PointerAxisStopFunc = std::function<void(void *, uint32_t time,
PointerAxis axis)>;
#define POINTER_AXIS_DISCRETE_ARG __BIND3_ARGS
using PointerAxisDiscreteFunc = std::function<void(void *, PointerAxis axis,
int32_t discrete)>;
#define KEYBOARD_KEYMAP_ARG __BIND4_ARGS
using KeyboardKeymapFunc = std::function<void(void *, KeyboardKeymapFormat format,
int32_t fd,
uint32_t size)>;
#define KEYBOARD_ENTER_ARG __BIND3_ARGS
using KeyboardEnterFunc = std::function<void(void *, uint32_t serial,
const std::vector<uint32_t> &keys)>;
#define KEYBOARD_LEAVE_ARG __BIND2_ARGS
using KeyboardLeaveFunc = std::function<void(void *, uint32_t serial)>;
#define KEYBOARD_KEY_ARG __BIND5_ARGS
using KeyboardKeyFunc = std::function<void(void *, uint32_t serial,
uint32_t time,
uint32_t key,
KeyboardKeyState state)>;
#define KEYBOARD_MODIFIERS_ARG __BIND6_ARGS
using KeyboardModifiersFunc = std::function<void(void *, uint32_t serial,
uint32_t modsDepressed,
uint32_t modsLatched,
uint32_t modsLocked,
uint32_t group)>;
#define KEYBOARD_REPEAT_INFO_ARG __BIND3_ARGS
using KeyboardRepeatInfoFunc = std::function<void(void *, int32_t rate,
int32_t delay)>;
#define TOUCH_DOWN_ARG __BIND6_ARGS
using TouchDownFunc = std::function<void(void *, uint32_t serial,
uint32_t time,
int32_t id,
double x, double y)>;
#define TOUCH_UP_ARG __BIND4_ARGS
using TouchUpFunc = std::function<void(void *, uint32_t serial,
uint32_t time,
int32_t id)>;
#define TOUCH_MOTION_ARG __BIND5_ARGS
using TouchMotionFunc = std::function<void(void *, uint32_t time,
int32_t id,
double x, double y)>;
#define TOUCH_FRAME_ARG __BIND1_ARGS
using TouchFrameFunc = std::function<void(void *)>;
#define TOUCH_CANCEL_ARG __BIND1_ARGS
using TouchCancelFunc = std::function<void(void *)>;
#define TOUCH_SHAPE_ARG __BIND4_ARGS
using TouchShapeFunc = std::function<void(void *, int32_t id,
double major,
double minor)>;
#define TOUCH_ORIENTATION_ARG __BIND3_ARGS
using TouchOrientationFunc = std::function<void(void *, int32_t id,
double orientation)>;
} // namespace OHOS
#endif // INTERFACES_INNERKITS_WMCLIENT_WINDOW_MANAGER_INPUT_TYPE_H

View File

@ -129,14 +129,8 @@ class TouchEvent;
class KeyEvent;
using funcWindowInfoChange = std::function<void(WindowInfo &info)>;
using funcOnKey = std::function<bool(KeyEvent)>;
using funcOnTouch = std::function<bool(TouchEvent)>;
using WindowInfoChangeFunc = std::function<void(WindowInfo &info)>;
using OnKeyFunc = std::function<bool(KeyEvent)>;
using OnTouchFunc = std::function<bool(TouchEvent)>;
using WindowPositionChangeFunc = std::function<void(int32_t x, int32_t y)>;
using WindowSizeChangeFunc = std::function<void(uint32_t width, uint32_t height)>;
using WindowVisibilityChangeFunc = std::function<void(bool visibility)>;