[4.0] Add Finalize api for imf-manager
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / input / text / text-input-listeners.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 // CLASS HEADER
18 #include "text-input-listeners.h"
19
20 // INTERNAL INCLUDES
21 #include <input/text/text-input-interface.h>
22 #include <input/seat.h>
23
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 namespace Adaptor
32 {
33
34 namespace
35 {
36
37 void Enter( void* data, WlTextInput* textInput, WlSurface* surface )
38 {
39   TextInputInterface* input = static_cast< TextInputInterface* >( data );
40   Seat* seat = input->GetSeat( textInput );
41
42   input->Enter( seat, surface );
43 }
44
45 void Leave( void* data, WlTextInput* textInput )
46 {
47   TextInputInterface* input = static_cast< TextInputInterface* >( data );
48   Seat* seat = input->GetSeat( textInput );
49
50   input->Leave( seat );
51 }
52
53 void ModifiersMap( void* data, WlTextInput* textInput, struct wl_array* map )
54 {
55   TextInputInterface* input = static_cast< TextInputInterface* >( data );
56   Seat* seat = input->GetSeat( textInput );
57
58   input->ModifiersMap( seat, map );
59 }
60
61 void InputPanelState( void* data, WlTextInput* textInput, uint32_t state )
62 {
63   TextInputInterface* input = static_cast< TextInputInterface* >( data );
64   Seat* seat = input->GetSeat( textInput );
65
66   input->InputPanelState( seat, state );
67 }
68
69 void PreeditString( void* data, WlTextInput* textInput, uint32_t serial, const char* text, const char* commit )
70 {
71   TextInputInterface* input = static_cast< TextInputInterface* >( data );
72   Seat* seat = input->GetSeat( textInput );
73
74   input->PreeditString( seat, serial, text, commit );
75 }
76
77 void PreeditStyling( void* data, WlTextInput* textInput, uint32_t index, uint32_t length, uint32_t style)
78 {
79   TextInputInterface* input = static_cast< TextInputInterface* >( data );
80   Seat* seat = input->GetSeat( textInput );
81
82   input->PreeditStyling( seat, index, length, style );
83 }
84
85 void PreeditCursor(void* data,
86            WlTextInput* textInput,
87            int32_t index)
88 {
89
90   TextInputInterface* input = static_cast< TextInputInterface* >( data );
91   Seat* seat = input->GetSeat( textInput );
92
93   input->PreeditCursor( seat, index );
94 }
95
96 void CommitString(void* data,
97           WlTextInput* textInput,
98           uint32_t serial,
99           const char* text)
100 {
101   TextInputInterface* input = static_cast< TextInputInterface* >( data );
102   Seat* seat = input->GetSeat( textInput );
103
104   input->CommitString( seat, serial, text );
105 }
106
107 void CursorPosition(void* data,
108       WlTextInput* textInput,
109       int32_t index,
110       int32_t anchor)
111 {
112   TextInputInterface* input = static_cast< TextInputInterface* >( data );
113   Seat* seat = input->GetSeat( textInput );
114
115   input->CursorPosition( seat, index, anchor );
116 }
117
118 void DeleteSurroundingText(void* data,
119           WlTextInput* textInput,
120           int32_t index,
121           uint32_t length)
122 {
123   TextInputInterface* input = static_cast< TextInputInterface* >( data );
124   Seat* seat = input->GetSeat( textInput );
125
126   input->DeleteSurroundingText( seat, index, length );
127 }
128
129 void Keysym(void* data,
130          WlTextInput* textInput,
131          uint32_t serial,
132          uint32_t time,
133          uint32_t sym,
134          uint32_t state,
135          uint32_t modifiers)
136 {
137   TextInputInterface* input = static_cast< TextInputInterface* >( data );
138   Seat* seat = input->GetSeat( textInput );
139
140   input->Keysym( seat, serial, time, sym, state, modifiers );
141 }
142
143 void Language(void* data,
144      WlTextInput* textInput,
145      uint32_t serial,
146      const char* language)
147 {
148   TextInputInterface* input = static_cast< TextInputInterface* >( data );
149   Seat* seat = input->GetSeat( textInput );
150
151   input->Language( seat, serial, language );
152 }
153
154 void TextDirection(void* data,
155            WlTextInput* textInput,
156            uint32_t serial,
157            uint32_t direction)
158 {
159   TextInputInterface* input = static_cast< TextInputInterface* >( data );
160   Seat* seat = input->GetSeat( textInput );
161
162   input->TextDirection( seat, serial, direction );
163 }
164
165 void SelectionRegion(void* data,
166        WlTextInput* textInput,
167        uint32_t serial,
168        int32_t start,
169        int32_t end)
170 {
171   TextInputInterface* input = static_cast< TextInputInterface* >( data );
172   Seat* seat = input->GetSeat( textInput );
173
174   input->SelectionRegion( seat, serial, start, end );
175 }
176
177 void PrivateCommand(void* data,
178       WlTextInput* textInput,
179       uint32_t serial,
180       const char* command)
181 {
182   TextInputInterface* input = static_cast< TextInputInterface* >( data );
183   Seat* seat = input->GetSeat( textInput );
184
185   input->PrivateCommand( seat, serial, command );
186 }
187
188 void InputPanelGeometry(void* data,
189            WlTextInput* textInput,
190            uint32_t x,
191            uint32_t y,
192            uint32_t width,
193            uint32_t height)
194 {
195   TextInputInterface* input = static_cast< TextInputInterface* >( data );
196   Seat* seat = input->GetSeat( textInput );
197
198   input->InputPanelGeometry( seat, x, y, width, height );
199 }
200
201 void InputPanelData( void* data,
202           WlTextInput* textInput,
203           uint32_t serial,
204           const char* input_panel_data,
205           uint32_t input_panel_data_length)
206 {
207   TextInputInterface* input = static_cast< TextInputInterface* >( data );
208   Seat* seat = input->GetSeat( textInput );
209
210   input->InputPanelData( seat, serial, input_panel_data, input_panel_data_length);
211 }
212
213
214 /**
215  * If when running DALi on target a message like
216  * listener function for opcode 16 of wl_text_input is NULL,
217  * then it means the interface has been updated, and they've added an extra function
218  * to the listener
219  */
220 const WlTextInputListener TextInputListener =
221 {
222   Enter,
223   Leave,
224   ModifiersMap,
225   InputPanelState,
226   PreeditString,
227   PreeditStyling,
228   PreeditCursor,
229   CommitString,
230   CursorPosition,
231   DeleteSurroundingText,
232   Keysym,
233   Language,
234   TextDirection,
235   SelectionRegion,
236   PrivateCommand,
237   InputPanelGeometry,
238   InputPanelData
239 };
240
241 } // unnamed namespace
242
243
244 namespace Wayland
245 {
246
247 const WlTextInputListener* GetTextInputListener()
248 {
249   return &TextInputListener;
250 }
251
252 } // Wayland
253 } // Adaptor
254 } // Internal
255 } // Dali