2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
12 #include "input/keyboard/XBMC_keysym.h"
13 #include "utils/Geometry.h"
14 #include "windowing/XBMC_events.h"
18 #include <wayland-client-protocol.hpp>
27 class IInputHandlerPointer
30 virtual void OnPointerEnter(std::uint32_t seatGlobalName
, std::uint32_t serial
) {}
31 virtual void OnPointerLeave() {}
32 virtual void OnPointerEvent(XBMC_Event
& event
) = 0;
34 ~IInputHandlerPointer() = default;
37 class CInputProcessorPointer final
: public IRawInputHandlerPointer
40 CInputProcessorPointer(wayland::surface_t
const& surface
, IInputHandlerPointer
& handler
);
41 void SetCoordinateScale(std::int32_t scale
) { m_coordinateScale
= scale
; }
43 void OnPointerEnter(CSeat
* seat
,
45 const wayland::surface_t
& surface
,
47 double surfaceY
) override
;
48 void OnPointerLeave(CSeat
* seat
,
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
;
56 CInputProcessorPointer(CInputProcessorPointer
const& other
) = delete;
57 CInputProcessorPointer
& operator=(CInputProcessorPointer
const& other
) = delete;
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
);
64 wayland::surface_t m_surface
;
65 IInputHandlerPointer
& m_handler
;
67 bool m_pointerOnSurface
{};
69 // Pointer position in *scaled* coordinates
70 CPointGen
<std::uint16_t> m_pointerPosition
;
71 std::int32_t m_coordinateScale
{1};