2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "accessibility-manager-impl.h"
24 #include <Elementary.h>
26 #include <dali/public-api/dali-core.h>
27 #include <dali/integration-api/debug.h>
28 #include <dali/integration-api/events/gesture-requests.h>
31 #include "system-settings.h"
33 #define MSG_DOMAIN_CONTROL_ACCESS (int)ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL
45 #if defined(DEBUG_ENABLED)
46 Debug::Filter* gAccessibilityManagerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_MANAGER");
48 } // unnamed namespace
50 bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
53 Dali::AccessibilityManager handle( this );
56 * In order to application decide reading action first,
57 * emit ActionNext signal in first, AccessibilityActionNext for handler in next
59 if( !mIndicatorFocused )
61 if( !mActionNextSignal.Empty() )
63 mActionNextSignal.Emit( handle );
67 if( mIndicator && mIndicatorFocused )
69 Elm_Access_Action_Info actionInfo;
70 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
72 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
74 else if( mActionHandler )
76 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
79 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
84 bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
88 Dali::AccessibilityManager handle( this );
91 * In order to application decide reading action first,
92 * emit ActionPrevious signal in first, AccessibilityActionPrevious for handler in next
94 if ( !mIndicatorFocused )
96 if( !mActionPreviousSignal.Empty() )
98 mActionPreviousSignal.Emit( handle );
102 if( mIndicator && mIndicatorFocused )
104 Elm_Access_Action_Info actionInfo;
105 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
107 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
109 else if( mActionHandler )
111 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
114 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
119 bool AccessibilityManager::HandleActionActivateEvent()
123 Dali::AccessibilityManager handle( this );
126 * In order to application decide reading action first,
127 * emit ActionActivate signal in first, AccessibilityActionActivate for handler in next
129 if ( !mIndicatorFocused )
131 if( !mActionActivateSignal.Empty() )
133 mActionActivateSignal.Emit( handle );
137 if( mIndicator && mIndicatorFocused )
139 Elm_Access_Action_Info actionInfo;
140 actionInfo.action_type = ELM_ACCESS_ACTION_ACTIVATE;
142 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
144 else if( mActionHandler )
146 ret = mActionHandler->AccessibilityActionActivate();
149 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
154 bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
158 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
163 Dali::AccessibilityManager handle( this );
165 bool indicatorFocused = false;
167 // Check whether the Indicator is focused
168 if( mIndicator && mIndicator->IsConnected() )
170 // Check the position and size of Indicator actor
171 Dali::Actor indicatorActor = mIndicator->GetActor();
172 Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
173 Vector3 size = indicatorActor.GetCurrentSize();
175 if(mReadPosition.x >= position.x &&
176 mReadPosition.x <= position.x + size.width &&
177 mReadPosition.y >= position.y &&
178 mReadPosition.y <= position.y + size.height)
180 indicatorFocused = true;
181 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
187 if( !mIndicatorFocused && indicatorFocused )
189 // If Indicator is focused, the focus should be cleared in Dali focus chain.
192 mActionHandler->ClearAccessibilityFocus();
195 else if( mIndicatorFocused && !indicatorFocused )
197 Elm_Access_Action_Info actionInfo;
198 actionInfo.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
200 // Indicator should be unhighlighted
201 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
202 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send unhighlight message to indicator!!!!\n", __FUNCTION__, __LINE__);
205 mIndicatorFocused = indicatorFocused;
207 // Send accessibility READ action information to Indicator
208 if( mIndicatorFocused )
210 Elm_Access_Action_Info actionInfo;
211 actionInfo.x = mReadPosition.x;
212 actionInfo.y = mReadPosition.y;
216 actionInfo.action_type = ELM_ACCESS_ACTION_READ;
220 actionInfo.action_type = static_cast<Elm_Access_Action_Type>( GetElmAccessActionOver() );
223 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
225 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send READ message to indicator!!!!\n", __FUNCTION__, __LINE__);
232 * In order to application decide reading action first,
233 * emit ActionRead signal in first, AccessibilityActionRead for handler in next
235 if( !mIndicatorFocused )
237 if ( !mActionReadSignal.Empty() )
239 mActionReadSignal.Emit( handle );
246 * In order to application decide reading action first,
247 * emit ActionRead signal in first, AccessibilityActionRead for handler in next
249 if( !mIndicatorFocused )
251 if ( !mActionOverSignal.Empty() )
253 mActionOverSignal.Emit( handle );
258 if( mActionHandler && !mIndicatorFocused)
260 // If Indicator is not focused, the accessibility actions should be handled by the registered
261 // accessibility action handler (e.g. focus manager)
262 ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
263 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
269 bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
273 Dali::AccessibilityManager handle( this );
276 * In order to application decide reading action first,
277 * emit ActionReadNext signal in first, AccessibilityActionReadNext for handler in next
279 if ( !mIndicatorFocused )
281 if( !mActionReadNextSignal.Empty() )
283 mActionReadNextSignal.Emit( handle );
287 if( mIndicator && mIndicatorFocused )
289 Elm_Access_Action_Info actionInfo;
290 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
292 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
294 else if( mActionHandler )
296 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
299 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
304 bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
308 Dali::AccessibilityManager handle( this );
311 * In order to application decide reading action first,
312 * emit ActionReadPrevious signal in first, AccessibilityActionReadPrevious for handler in next
314 if ( !mIndicatorFocused )
316 if( !mActionReadPreviousSignal.Empty() )
318 mActionReadPreviousSignal.Emit( handle );
322 if( mIndicator && mIndicatorFocused )
324 Elm_Access_Action_Info actionInfo;
325 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
327 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
329 else if( mActionHandler )
331 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
334 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
339 bool AccessibilityManager::HandleActionUpEvent()
343 Dali::AccessibilityManager handle( this );
346 * In order to application decide reading action first,
347 * emit ActionUp signal in first, AccessibilityActionUp for handler in next
349 if ( !mIndicatorFocused )
351 if( !mActionUpSignal.Empty() )
353 mActionUpSignal.Emit( handle );
357 if( mIndicator && mIndicatorFocused )
359 Elm_Access_Action_Info actionInfo;
360 actionInfo.action_type = ELM_ACCESS_ACTION_UP;
362 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
364 else if( mActionHandler )
366 ret = mActionHandler->AccessibilityActionUp();
369 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
374 bool AccessibilityManager::HandleActionDownEvent()
378 Dali::AccessibilityManager handle( this );
381 * In order to application decide reading action first,
382 * emit ActionDown signal in first, AccessibilityActionDown for handler in next
384 if ( !mIndicatorFocused )
386 if( !mActionDownSignal.Empty() )
388 mActionDownSignal.Emit( handle );
392 if( mIndicator && mIndicatorFocused )
394 Elm_Access_Action_Info actionInfo;
395 actionInfo.action_type = ELM_ACCESS_ACTION_DOWN;
397 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
399 else if( mActionHandler )
401 ret = mActionHandler->AccessibilityActionDown();
404 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
409 } // namespace Adaptor
411 } // namespace Internal