kodi
SeatInputProcessing.h
1 /*
2  * Copyright (C) 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 "InputProcessorKeyboard.h"
12 #include "InputProcessorPointer.h"
13 #include "InputProcessorTouch.h"
14 #include "Seat.h"
15 
16 #include <cstdint>
17 #include <map>
18 #include <memory>
19 
20 #include <wayland-client-protocol.hpp>
21 
22 namespace KODI
23 {
24 namespace WINDOWING
25 {
26 namespace WAYLAND
27 {
28 
29 enum class InputType
30 {
31  POINTER,
32  KEYBOARD,
33  TOUCH
34 };
35 
40 {
41 public:
47  virtual void OnEvent(InputType type, XBMC_Event& event) {}
52  virtual void OnEnter(InputType type) {}
57  virtual void OnLeave(InputType type) {}
71  virtual void OnSetCursor(std::uint32_t seatGlobalName, std::uint32_t serial) {}
72 
73  virtual ~IInputHandler() = default;
74 };
75 
83 {
84 public:
91  CSeatInputProcessing(wayland::surface_t const& inputSurface, IInputHandler& handler);
92  void AddSeat(CSeat* seat);
93  void RemoveSeat(CSeat* seat);
94 
105  void SetCoordinateScale(std::int32_t scale);
106 
107 private:
108  wayland::surface_t m_inputSurface;
109  IInputHandler& m_handler;
110 
111  void OnPointerEnter(std::uint32_t seatGlobalName, std::uint32_t serial) override;
112  void OnPointerLeave() override;
113  void OnPointerEvent(XBMC_Event& event) override;
114 
115  void OnKeyboardEnter() override;
116  void OnKeyboardLeave() override;
117  void OnKeyboardEvent(XBMC_Event& event) override;
118 
119  struct SeatState
120  {
121  CSeat* seat;
122  std::unique_ptr<CInputProcessorKeyboard> keyboardProcessor;
123  std::unique_ptr<CInputProcessorPointer> pointerProcessor;
124  std::unique_ptr<CInputProcessorTouch> touchProcessor;
125 
126  SeatState(CSeat* seat)
127  : seat{seat}
128  {}
129  };
130  std::map<std::uint32_t, SeatState> m_seats;
131 };
132 
133 }
134 }
135 }
virtual void OnLeave(InputType type)
Handle focus leave.
Definition: SeatInputProcessing.h:57
virtual void OnEvent(InputType type, XBMC_Event &event)
Handle input event.
Definition: SeatInputProcessing.h:47
Receive events from all registered wl_seats and process them into Kodi events.
Definition: SeatInputProcessing.h:82
Definition: InputProcessorKeyboard.h:28
virtual void OnSetCursor(std::uint32_t seatGlobalName, std::uint32_t serial)
Handle request for setting the cursor.
Definition: SeatInputProcessing.h:71
Definition: InputProcessorPointer.h:27
Definition: AudioDecoder.h:18
Handler interface for input events from CSeatInputProcessor.
Definition: SeatInputProcessing.h:39
Handle all events and requests related to one seat (including input and selection) ...
Definition: Seat.h:114
Definition: XBMC_events.h:117
virtual void OnEnter(InputType type)
Handle focus enter.
Definition: SeatInputProcessing.h:52