Change a service name of the indicator and remove a unused indicator style
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / accessibility-manager-impl-wl.cpp
1 /*
2  * Copyright (c) 2014 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-manager-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 AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
44 {
45   bool ret = false;
46   Dali::AccessibilityManager handle( this );
47
48   /*
49    * In order to application decide reading action first,
50    * emit ActionNext signal in first, AccessibilityActionNext for handler in next
51    */
52   if( !mIndicatorFocused )
53   {
54     if( !mActionNextSignal.Empty() )
55     {
56       mActionNextSignal.Emit( handle );
57     }
58   }
59
60   if( mActionHandler )
61   {
62     ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
63   }
64
65   DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
66
67   return ret;
68 }
69
70 bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
71 {
72   bool ret = false;
73
74   Dali::AccessibilityManager handle( this );
75
76    /*
77    * In order to application decide reading action first,
78    * emit ActionPrevious signal in first, AccessibilityActionPrevious for handler in next
79    */
80  if ( !mIndicatorFocused )
81   {
82     if( !mActionPreviousSignal.Empty() )
83     {
84       mActionPreviousSignal.Emit( handle );
85     }
86   }
87
88   if( mActionHandler )
89   {
90     ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
91   }
92
93   DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
94
95   return ret;
96 }
97
98 bool AccessibilityManager::HandleActionActivateEvent()
99 {
100   bool ret = false;
101
102   Dali::AccessibilityManager handle( this );
103
104   /*
105    * In order to application decide reading action first,
106    * emit ActionActivate signal in first, AccessibilityActionActivate for handler in next
107    */
108   if ( !mIndicatorFocused )
109   {
110     if( !mActionActivateSignal.Empty() )
111     {
112       mActionActivateSignal.Emit( handle );
113     }
114   }
115
116   if( mActionHandler )
117   {
118     ret = mActionHandler->AccessibilityActionActivate();
119   }
120
121   DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
122
123   return ret;
124 }
125
126 bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
127 {
128   bool ret = false;
129
130   DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
131
132   mReadPosition.x = x;
133   mReadPosition.y = y;
134
135   Dali::AccessibilityManager handle( this );
136
137   bool indicatorFocused = false;
138
139   // Check whether the Indicator is focused
140   if( mIndicator && mIndicator->IsConnected() )
141   {
142     // Check the position and size of Indicator actor
143     Dali::Actor indicatorActor = mIndicator->GetActor();
144     Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
145     Vector3 size = indicatorActor.GetCurrentSize();
146
147     if(mReadPosition.x >= position.x &&
148        mReadPosition.x <= position.x + size.width &&
149        mReadPosition.y >= position.y &&
150        mReadPosition.y <= position.y + size.height)
151     {
152       indicatorFocused = true;
153       DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
154     }
155   }
156
157   if( mIndicator )
158   {
159     if( !mIndicatorFocused && indicatorFocused )
160     {
161       // If Indicator is focused, the focus should be cleared in Dali focus chain.
162       if( mActionHandler )
163       {
164         mActionHandler->ClearAccessibilityFocus();
165       }
166     }
167     else if( mIndicatorFocused && !indicatorFocused )
168     {
169     }
170
171     mIndicatorFocused = indicatorFocused;
172
173     // Send accessibility READ action information to Indicator
174     if( mIndicatorFocused )
175     {
176     }
177   }
178
179   if(allowReadAgain)
180   {
181     /*
182      * In order to application decide reading action first,
183      * emit ActionRead signal in first, AccessibilityActionRead for handler in next
184      */
185     if( !mIndicatorFocused )
186     {
187       if ( !mActionReadSignal.Empty() )
188       {
189         mActionReadSignal.Emit( handle );
190       }
191     }
192   }
193   else
194   {
195     /*
196      * In order to application decide reading action first,
197      * emit ActionRead signal in first, AccessibilityActionRead for handler in next
198      */
199     if( !mIndicatorFocused )
200     {
201       if ( !mActionOverSignal.Empty() )
202       {
203         mActionOverSignal.Emit( handle );
204       }
205     }
206   }
207
208   if( mActionHandler && !mIndicatorFocused)
209   {
210     // If Indicator is not focused, the accessibility actions should be handled by the registered
211     // accessibility action handler (e.g. focus manager)
212     ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
213     DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
214   }
215
216   return ret;
217 }
218
219 bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
220 {
221   bool ret = false;
222
223   Dali::AccessibilityManager handle( this );
224
225   /*
226    * In order to application decide reading action first,
227    * emit ActionReadNext signal in first, AccessibilityActionReadNext for handler in next
228    */
229   if ( !mIndicatorFocused )
230   {
231     if( !mActionReadNextSignal.Empty() )
232     {
233       mActionReadNextSignal.Emit( handle );
234     }
235   }
236
237   if( mActionHandler )
238   {
239     ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
240   }
241
242   DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
243
244   return ret;
245 }
246
247 bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
248 {
249   bool ret = false;
250
251   Dali::AccessibilityManager handle( this );
252
253   /*
254    * In order to application decide reading action first,
255    * emit ActionReadPrevious signal in first, AccessibilityActionReadPrevious for handler in next
256    */
257   if ( !mIndicatorFocused )
258   {
259     if( !mActionReadPreviousSignal.Empty() )
260     {
261       mActionReadPreviousSignal.Emit( handle );
262     }
263   }
264
265   if( mActionHandler )
266   {
267     ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
268   }
269
270   DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
271
272   return ret;
273 }
274
275 bool AccessibilityManager::HandleActionUpEvent()
276 {
277   bool ret = false;
278
279   Dali::AccessibilityManager handle( this );
280
281   /*
282    * In order to application decide reading action first,
283    * emit ActionUp signal in first, AccessibilityActionUp for handler in next
284    */
285   if ( !mIndicatorFocused )
286   {
287     if( !mActionUpSignal.Empty() )
288     {
289       mActionUpSignal.Emit( handle );
290     }
291   }
292
293   if( mActionHandler )
294   {
295     ret = mActionHandler->AccessibilityActionUp();
296   }
297
298   DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
299
300   return ret;
301 }
302
303 bool AccessibilityManager::HandleActionDownEvent()
304 {
305   bool ret = false;
306
307   Dali::AccessibilityManager handle( this );
308
309   /*
310    * In order to application decide reading action first,
311    * emit ActionDown signal in first, AccessibilityActionDown for handler in next
312    */
313   if ( !mIndicatorFocused )
314   {
315     if( !mActionDownSignal.Empty() )
316     {
317       mActionDownSignal.Emit( handle );
318     }
319   }
320
321   if( mActionHandler )
322   {
323     ret = mActionHandler->AccessibilityActionDown();
324   }
325
326   DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
327
328   return ret;
329 }
330
331 } // namespace Adaptor
332
333 } // namespace Internal
334
335 } // namespace Dali