Merge "PixmapSurface changes to double buffered pixmap." into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / accessibility-adaptor-impl-wl.cpp
1 /*
2  * Copyright (c) 2015 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
18 // CLASS HEADER
19 #include "accessibility-adaptor-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <vconf.h>
23 #include <Ecore.h>
24 #include <Ecore_Wayland.h>
25 #include <Elementary.h>
26
27 #include <dali/public-api/object/type-registry.h>
28 #include <dali/integration-api/debug.h>
29 #include <dali/integration-api/events/gesture-requests.h>
30
31 // INTERNAL INCLUDES
32 #include "system-settings.h"
33
34 namespace Dali
35 {
36
37 namespace Internal
38 {
39
40 namespace Adaptor
41 {
42
43 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
44 {
45   bool ret = false;
46
47   if( mActionHandler )
48   {
49     ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
50   }
51
52   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
53
54   return ret;
55 }
56
57 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
58 {
59   bool ret = false;
60
61   if( mActionHandler )
62   {
63     ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
64   }
65
66   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
67
68   return ret;
69 }
70
71 bool AccessibilityAdaptor::HandleActionActivateEvent()
72 {
73   bool ret = false;
74
75   if( mActionHandler )
76   {
77     ret = mActionHandler->AccessibilityActionActivate();
78   }
79
80   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
81
82   return ret;
83 }
84
85 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
86 {
87   bool ret = false;
88
89   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
90
91   mReadPosition.x = x;
92   mReadPosition.y = y;
93
94   Dali::AccessibilityAdaptor handle( this );
95
96   bool indicatorFocused = false;
97
98   // Check whether the Indicator is focused
99   if( mIndicator && mIndicator->IsConnected() )
100   {
101     // Check the position and size of Indicator actor
102     Dali::Actor indicatorActor = mIndicator->GetActor();
103     Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
104     Vector3 size = indicatorActor.GetCurrentSize();
105
106     if(mReadPosition.x >= position.x &&
107        mReadPosition.x <= position.x + size.width &&
108        mReadPosition.y >= position.y &&
109        mReadPosition.y <= position.y + size.height)
110     {
111       indicatorFocused = true;
112       DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
113     }
114   }
115
116   if( mIndicator )
117   {
118     if( !mIndicatorFocused && indicatorFocused )
119     {
120       // If Indicator is focused, the focus should be cleared in Dali focus chain.
121       if( mActionHandler )
122       {
123         mActionHandler->ClearAccessibilityFocus();
124       }
125     }
126     else if( mIndicatorFocused && !indicatorFocused )
127     {
128     }
129
130     mIndicatorFocused = indicatorFocused;
131
132     // Send accessibility READ action information to Indicator
133     if( mIndicatorFocused )
134     {
135     }
136   }
137
138   if( mActionHandler && !mIndicatorFocused)
139   {
140     // If Indicator is not focused, the accessibility actions should be handled by the registered
141     // accessibility action handler (e.g. focus manager)
142     ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
143     DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
144   }
145
146   return ret;
147 }
148
149 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
150 {
151   bool ret = false;
152
153   Dali::AccessibilityAdaptor handle( this );
154
155   if( mActionHandler )
156   {
157     ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
158   }
159
160   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
161
162   return ret;
163 }
164
165 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
166 {
167   bool ret = false;
168
169   if( mActionHandler )
170   {
171     ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
172   }
173
174   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
175
176   return ret;
177 }
178
179 bool AccessibilityAdaptor::HandleActionUpEvent()
180 {
181   bool ret = false;
182
183   if( mActionHandler )
184   {
185     ret = mActionHandler->AccessibilityActionUp();
186   }
187
188   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
189
190   return ret;
191 }
192
193 bool AccessibilityAdaptor::HandleActionDownEvent()
194 {
195   bool ret = false;
196
197   Dali::AccessibilityAdaptor handle( this );
198
199   if( mActionHandler )
200   {
201     ret = mActionHandler->AccessibilityActionDown();
202   }
203
204   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
205
206   return ret;
207 }
208
209 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
210 {
211   bool ret = false;
212
213   if( mActionHandler )
214   {
215     ret = mActionHandler->AccessibilityActionScrollUp();
216   }
217
218   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
219
220   return ret;
221 }
222
223
224 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
225 {
226   bool ret = false;
227
228   if( mActionHandler )
229   {
230     ret = mActionHandler->AccessibilityActionScrollDown();
231   }
232
233   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
234
235   return ret;
236 }
237
238 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
239 {
240   bool ret = false;
241
242   if( mActionHandler )
243   {
244     ret = mActionHandler->AccessibilityActionPageLeft();
245   }
246
247   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
248
249   return ret;
250 }
251
252 bool AccessibilityAdaptor::HandleActionPageRightEvent()
253 {
254   bool ret = false;
255
256   if( mActionHandler )
257   {
258     ret = mActionHandler->AccessibilityActionPageRight();
259   }
260
261   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
262
263   return ret;
264 }
265
266 bool AccessibilityAdaptor::HandleActionPageUpEvent()
267 {
268   bool ret = false;
269
270   if( mActionHandler )
271   {
272     ret = mActionHandler->AccessibilityActionPageUp();
273   }
274
275   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
276
277   return ret;
278 }
279
280 bool AccessibilityAdaptor::HandleActionPageDownEvent()
281 {
282   bool ret = false;
283
284   if( mActionHandler )
285   {
286     ret = mActionHandler->AccessibilityActionPageDown();
287   }
288
289   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
290
291   return ret;
292 }
293
294 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
295 {
296   bool ret = false;
297
298   if( mActionHandler )
299   {
300     ret = mActionHandler->AccessibilityActionMoveToFirst();
301   }
302
303   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
304
305   return ret;
306 }
307
308 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
309 {
310   bool ret = false;
311
312   if( mActionHandler )
313   {
314     ret = mActionHandler->AccessibilityActionMoveToLast();
315   }
316
317   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
318
319   return ret;
320 }
321
322 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
323 {
324   bool ret = false;
325
326   if( mActionHandler )
327   {
328     ret = mActionHandler->AccessibilityActionReadFromTop();
329   }
330
331   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
332
333   return ret;
334 }
335
336 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
337 {
338   bool ret = false;
339
340   if( mActionHandler )
341   {
342     ret = mActionHandler->AccessibilityActionReadFromNext();
343   }
344
345   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
346
347   return ret;
348 }
349
350 bool AccessibilityAdaptor::HandleActionZoomEvent()
351 {
352   bool ret = false;
353
354   if( mActionHandler )
355   {
356     ret = mActionHandler->AccessibilityActionZoom();
357   }
358
359   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
360
361   return ret;
362 }
363
364 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
365 {
366   bool ret = false;
367
368   if( mActionHandler )
369   {
370     ret = mActionHandler->AccessibilityActionReadIndicatorInformation();
371   }
372
373   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
374
375   return ret;
376 }
377
378 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
379 {
380   bool ret = false;
381
382   if( mActionHandler )
383   {
384     ret = mActionHandler->AccessibilityActionReadPauseResume();
385   }
386
387   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
388
389   return ret;
390 }
391
392 bool AccessibilityAdaptor::HandleActionStartStopEvent()
393 {
394   bool ret = false;
395
396   if( mActionHandler )
397   {
398     ret = mActionHandler->AccessibilityActionStartStop();
399   }
400
401   DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
402
403   return ret;
404 }
405
406 } // namespace Adaptor
407
408 } // namespace Internal
409
410 } // namespace Dali