Wayland DPI and Multi-threading Wayland support
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / input-manager.h
1 #ifndef __DALI_WAYLAND_INPUT_H__
2 #define __DALI_WAYLAND_INPUT_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23 #include <dali/public-api/events/key-event.h>
24
25 // INTERNAL INCLUDES
26 #include <base/interfaces/window-event-interface.h>
27 #include <wl-types.h>
28 #include <input/input-interface.h>
29 #include <input/seat.h>
30
31
32 namespace Dali
33 {
34 namespace Internal
35 {
36 namespace Adaptor
37 {
38
39 /**
40  * @brief Listens to Wayland input events.
41  * Translates the wayland events into DALi events and forwards them to a WindowEventInterface
42  */
43 class InputManager : public InputInterface
44 {
45
46 public:
47
48
49   /**
50    * @brief Constructor
51    */
52   InputManager();
53
54   /**
55    * @brief Destructor
56    */
57   virtual ~InputManager();
58
59   /**
60    * @brief Assign the window event interface
61    * @param[in]  eventInterface event interface
62    */
63   void AssignWindowEventInterface( WindowEventInterface* eventInterface);
64
65   /**
66    * @brief listen to events on this seat
67    * @param seatInterface[in] output interface
68    */
69   void AddSeatListener( Dali::WlSeat* seatInterface );
70
71
72 protected: //InputInterface, pointer events
73
74   /**
75    * @copydoc InputInterface::PointerEnter
76    */
77   virtual void PointerEnter( Seat* seat, unsigned int serial, WlSurface* surface, float x, float y );
78
79   /**
80    * @copydoc InputInterface::PointerLeave
81    */
82   virtual void PointerLeave( Seat* seat, unsigned int serial, WlSurface* surface );
83
84   /**
85    * @copydoc InputInterface::PointerMotion
86    */
87   virtual void PointerMotion( Seat* seat, unsigned int timestamp, float x, float y );
88
89   /**
90    * @copydoc InputInterface::PointerButton
91    */
92   virtual void PointerButton( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state );
93
94   /**
95    * @copydoc InputInterface::PointerAxis
96    */
97   virtual void PointerAxis( Seat* seat, unsigned int timestamp, unsigned int axis, float value );
98
99
100 protected: //InputInterface, keyboard events
101
102   /**
103    * @copydoc InputInterface::KeyboardKeymap
104    */
105   virtual void KeyboardKeymap( Seat* seat, unsigned int format, int fd, unsigned int size );
106
107   /**
108    * @copydoc InputInterface::KeyFocusEnter
109    */
110   virtual void KeyFocusEnter( Seat* seat, unsigned int serial, WlSurface* surface, WlArray* keys );
111
112   /**
113    * @copydoc InputInterface::KeyFocusLeave
114    */
115   virtual void KeyFocusLeave( Seat* seat, unsigned int serial, WlSurface* surface );
116
117   /**
118    * @copydoc InputInterface::KeyEvent
119    */
120   virtual void KeyEvent( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state );
121
122   /**
123    * @copydoc InputInterface::KeyModifiers
124    */
125   virtual void KeyModifiers( Seat* seat,
126                             unsigned int serial,
127                             unsigned int depressed,
128                             unsigned int latched,
129                             unsigned int locked,
130                             unsigned int group );
131
132   /**
133    * @copydoc InputInterface::KeyRepeatInfo
134    */
135   virtual void KeyRepeatInfo( Seat* seat, int32_t rate, int32_t delay);
136
137 protected: //InputInterface, touch events
138
139   /**
140    * @copydoc InputInterface::TouchDown
141    */
142   virtual void TouchDown( Seat* seat, unsigned int serial, unsigned int timestamp, WlSurface* surface, int touchId, float x, float y);
143
144   /**
145    * @copydoc InputInterface::TouchUp
146    */
147   virtual void TouchUp( Seat* seat, unsigned int serial, unsigned int timestamp, int touchId );
148
149   /**
150    * @copydoc InputInterface::TouchMotion
151    */
152   virtual void TouchMotion( Seat* seat, unsigned int timestamp, int touchId, float x, float y );
153
154   /**
155    * @copydoc InputInterface::TouchFrame
156    */
157   virtual void TouchFrame( Seat* seat );
158
159   /**
160    * @copydoc InputInterface::TouchCancel
161    */
162   virtual void TouchCancel( Seat* seat );
163
164
165 protected: //InputInterface  Helper functions
166
167   /**
168    * @copydoc InputInterface::GetSeat( const WlKeyboard* keyboard )
169    */
170   virtual Seat* GetSeat( const WlKeyboard* keyboard );
171
172   /**
173    * @copydoc InputInterface::GetSeat( const WlPointer* pointer )
174    */
175   virtual Seat* GetSeat( const WlPointer* pointer );
176
177   /**
178    * @copydoc InputInterface::GetSeat( const WlTouch* touch )
179    */
180   virtual Seat* GetSeat( const WlTouch* touch );
181
182   /**
183    * @copydoc InputInterface::GetSeat( const WlSeat* seat )
184    */
185   virtual Seat* GetSeat( const WlSeat* seat );
186
187 public:
188
189   /**
190    * @brief Add a new seat ( collection of input devices)
191    * @param[in] wlRegistry
192    * @param[in] seatName seat name / id
193    * @param[in] version interface version
194    */
195   void AddSeat( Seat* seat );
196
197
198 private:
199
200  Dali::Vector< Seat* > mSeats;
201  WindowEventInterface* mWindowEventInterface;
202
203 };
204
205 } // Internal
206 } // Adaptor
207 } // Dali
208
209 #endif  //__DALI_WAYLAND_INPUT_H__