1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* Copyright (C) 2017-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include <cstdint>
#include <map>
#include <wayland-client-protocol.hpp>
#include "input/touch/ITouchInputHandler.h"
#include "Seat.h"
namespace KODI
{
namespace WINDOWING
{
namespace WAYLAND
{
/**
* Touch input processor
*
* Events go directly to \ref CGenericTouchInputHandler, so no callbacks here
*/
class CInputProcessorTouch final : public IRawInputHandlerTouch
{
public:
CInputProcessorTouch(wayland::surface_t const& surface);
~CInputProcessorTouch() noexcept;
void SetCoordinateScale(std::int32_t scale) { m_coordinateScale = scale; }
void OnTouchDown(CSeat* seat, std::uint32_t serial, std::uint32_t time, wayland::surface_t surface, std::int32_t id, double x, double y) override;
void OnTouchUp(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::int32_t id) override;
void OnTouchMotion(CSeat* seat, std::uint32_t time, std::int32_t id, double x, double y) override;
void OnTouchCancel(CSeat* seat) override;
void OnTouchShape(CSeat* seat, std::int32_t id, double major, double minor) override;
private:
CInputProcessorTouch(CInputProcessorTouch const& other) = delete;
CInputProcessorTouch& operator=(CInputProcessorTouch const& other) = delete;
struct TouchPoint
{
std::uint32_t lastEventTime;
/// Pointer number passed to \ref ITouchInputHandler
std::int32_t kodiPointerNumber;
/**
* Last coordinates - needed for TouchInputUp events where Wayland does not
* send new coordinates but Kodi needs them anyway
*/
float x, y, size;
TouchPoint(std::uint32_t initialEventTime, std::int32_t kodiPointerNumber, float x, float y, float size)
: lastEventTime{initialEventTime}, kodiPointerNumber{kodiPointerNumber}, x{x}, y{y}, size{size}
{}
};
void SendTouchPointEvent(TouchInput event, TouchPoint const& point);
void UpdateTouchPoint(TouchPoint const& point);
void AbortTouches();
wayland::surface_t m_surface;
std::int32_t m_coordinateScale{1};
/// Map of wl_touch point id to data
std::map<std::int32_t, TouchPoint> m_touchPoints;
};
}
}
}
|