| 1 |
/* |
| 2 |
* Copyright (C) 2017-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "Seat.h" |
| 12 |
#include "input/keyboard/XBMC_keysym.h" |
| 13 |
#include "utils/Geometry.h" |
| 14 |
#include "windowing/XBMC_events.h" |
| 15 |
|
| 16 |
#include <cstdint> |
| 17 |
|
| 18 |
#include <wayland-client-protocol.hpp> |
| 19 |
|
| 20 |
namespace KODI |
| 21 |
{ |
| 22 |
namespace WINDOWING |
| 23 |
{ |
| 24 |
namespace WAYLAND |
| 25 |
{ |
| 26 |
|
| 27 |
class IInputHandlerPointer |
| 28 |
{ |
| 29 |
public: |
| 30 |
virtual void OnPointerEnter(std::uint32_t seatGlobalName, std::uint32_t serial) {} |
| 31 |
virtual void OnPointerLeave() {} |
| 32 |
virtual void OnPointerEvent(XBMC_Event& event) = 0; |
| 33 |
protected: |
| 34 |
~IInputHandlerPointer() = default; |
| 35 |
}; |
| 36 |
|
| 37 |
class CInputProcessorPointer final : public IRawInputHandlerPointer |
| 38 |
{ |
| 39 |
public: |
| 40 |
CInputProcessorPointer(wayland::surface_t const& surface, IInputHandlerPointer& handler); |
| 41 |
void SetCoordinateScale(std::int32_t scale) { m_coordinateScale = scale; } |
| 42 |
|
| 43 |
void OnPointerEnter(CSeat* seat, |
| 44 |
std::uint32_t serial, |
| 45 |
const wayland::surface_t& surface, |
| 46 |
double surfaceX, |
| 47 |
double surfaceY) override; |
| 48 |
void OnPointerLeave(CSeat* seat, |
| 49 |
std::uint32_t serial, |
| 50 |
const wayland::surface_t& surface) override; |
| 51 |
void OnPointerMotion(CSeat* seat, std::uint32_t time, double surfaceX, double surfaceY) override; |
| 52 |
void OnPointerButton(CSeat* seat, std::uint32_t serial, std::uint32_t time, std::uint32_t button, wayland::pointer_button_state state) override; |
| 53 |
void OnPointerAxis(CSeat* seat, std::uint32_t time, wayland::pointer_axis axis, double value) override; |
| 54 |
|
| 55 |
private: |
| 56 |
CInputProcessorPointer(CInputProcessorPointer const& other) = delete; |
| 57 |
CInputProcessorPointer& operator=(CInputProcessorPointer const& other) = delete; |
| 58 |
|
| 59 |
std::uint16_t ConvertMouseCoordinate(double coord) const; |
| 60 |
void SetMousePosFromSurface(CPointGen<double> position); |
| 61 |
void SendMouseMotion(); |
| 62 |
void SendMouseButton(unsigned char button, bool pressed); |
| 63 |
|
| 64 |
wayland::surface_t m_surface; |
| 65 |
IInputHandlerPointer& m_handler; |
| 66 |
|
| 67 |
bool m_pointerOnSurface{}; |
| 68 |
|
| 69 |
// Pointer position in *scaled* coordinates |
| 70 |
CPointGen<std::uint16_t> m_pointerPosition; |
| 71 |
std::int32_t m_coordinateScale{1}; |
| 72 |
}; |
| 73 |
|
| 74 |
} |
| 75 |
} |
| 76 |
} |