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>
29 #include "system-settings.h"
31 #define MSG_DOMAIN_CONTROL_ACCESS (int)ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL
43 #if defined(DEBUG_ENABLED)
44 Debug::Filter* gAccessibilityManagerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_MANAGER");
46 } // unnamed namespace
48 bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
51 Dali::AccessibilityManager handle( this );
54 * In order to application decide reading action first,
55 * emit ActionNext signal in first, AccessibilityActionNext for handler in next
57 if( !mIndicatorFocused )
59 if( !mActionNextSignal.Empty() )
61 mActionNextSignal.Emit( handle );
65 if( mIndicator && mIndicatorFocused )
67 Elm_Access_Action_Info actionInfo;
68 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
70 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
72 else if( mActionHandler )
74 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
77 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
82 bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
86 Dali::AccessibilityManager handle( this );
89 * In order to application decide reading action first,
90 * emit ActionPrevious signal in first, AccessibilityActionPrevious for handler in next
92 if ( !mIndicatorFocused )
94 if( !mActionPreviousSignal.Empty() )
96 mActionPreviousSignal.Emit( handle );
100 if( mIndicator && mIndicatorFocused )
102 Elm_Access_Action_Info actionInfo;
103 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
105 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
107 else if( mActionHandler )
109 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
112 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
117 bool AccessibilityManager::HandleActionActivateEvent()
121 Dali::AccessibilityManager handle( this );
124 * In order to application decide reading action first,
125 * emit ActionActivate signal in first, AccessibilityActionActivate for handler in next
127 if ( !mIndicatorFocused )
129 if( !mActionActivateSignal.Empty() )
131 mActionActivateSignal.Emit( handle );
135 if( mIndicator && mIndicatorFocused )
137 Elm_Access_Action_Info actionInfo;
138 actionInfo.action_type = ELM_ACCESS_ACTION_ACTIVATE;
140 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
142 else if( mActionHandler )
144 ret = mActionHandler->AccessibilityActionActivate();
147 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
152 bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
156 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
161 Dali::AccessibilityManager handle( this );
163 bool indicatorFocused = false;
165 // Check whether the Indicator is focused
166 if( mIndicator && mIndicator->IsConnected() )
168 // Check the position and size of Indicator actor
169 Dali::Actor indicatorActor = mIndicator->GetActor();
170 Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
171 Vector3 size = indicatorActor.GetCurrentSize();
173 if(mReadPosition.x >= position.x &&
174 mReadPosition.x <= position.x + size.width &&
175 mReadPosition.y >= position.y &&
176 mReadPosition.y <= position.y + size.height)
178 indicatorFocused = true;
179 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
185 if( !mIndicatorFocused && indicatorFocused )
187 // If Indicator is focused, the focus should be cleared in Dali focus chain.
190 mActionHandler->ClearAccessibilityFocus();
193 else if( mIndicatorFocused && !indicatorFocused )
195 Elm_Access_Action_Info actionInfo;
196 actionInfo.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
198 // Indicator should be unhighlighted
199 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
200 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send unhighlight message to indicator!!!!\n", __FUNCTION__, __LINE__);
203 mIndicatorFocused = indicatorFocused;
205 // Send accessibility READ action information to Indicator
206 if( mIndicatorFocused )
208 Elm_Access_Action_Info actionInfo;
209 actionInfo.x = mReadPosition.x;
210 actionInfo.y = mReadPosition.y;
214 actionInfo.action_type = ELM_ACCESS_ACTION_READ;
218 actionInfo.action_type = static_cast<Elm_Access_Action_Type>( GetElmAccessActionOver() );
221 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
223 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send READ message to indicator!!!!\n", __FUNCTION__, __LINE__);
230 * In order to application decide reading action first,
231 * emit ActionRead signal in first, AccessibilityActionRead for handler in next
233 if( !mIndicatorFocused )
235 if ( !mActionReadSignal.Empty() )
237 mActionReadSignal.Emit( handle );
244 * In order to application decide reading action first,
245 * emit ActionRead signal in first, AccessibilityActionRead for handler in next
247 if( !mIndicatorFocused )
249 if ( !mActionOverSignal.Empty() )
251 mActionOverSignal.Emit( handle );
256 if( mActionHandler && !mIndicatorFocused)
258 // If Indicator is not focused, the accessibility actions should be handled by the registered
259 // accessibility action handler (e.g. focus manager)
260 ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
261 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
267 bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
271 Dali::AccessibilityManager handle( this );
274 * In order to application decide reading action first,
275 * emit ActionReadNext signal in first, AccessibilityActionReadNext for handler in next
277 if ( !mIndicatorFocused )
279 if( !mActionReadNextSignal.Empty() )
281 mActionReadNextSignal.Emit( handle );
285 if( mIndicator && mIndicatorFocused )
287 Elm_Access_Action_Info actionInfo;
288 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
290 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
292 else if( mActionHandler )
294 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
297 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
302 bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
306 Dali::AccessibilityManager handle( this );
309 * In order to application decide reading action first,
310 * emit ActionReadPrevious signal in first, AccessibilityActionReadPrevious for handler in next
312 if ( !mIndicatorFocused )
314 if( !mActionReadPreviousSignal.Empty() )
316 mActionReadPreviousSignal.Emit( handle );
320 if( mIndicator && mIndicatorFocused )
322 Elm_Access_Action_Info actionInfo;
323 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
325 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
327 else if( mActionHandler )
329 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
332 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
337 bool AccessibilityManager::HandleActionUpEvent()
341 Dali::AccessibilityManager handle( this );
344 * In order to application decide reading action first,
345 * emit ActionUp signal in first, AccessibilityActionUp for handler in next
347 if ( !mIndicatorFocused )
349 if( !mActionUpSignal.Empty() )
351 mActionUpSignal.Emit( handle );
355 if( mIndicator && mIndicatorFocused )
357 Elm_Access_Action_Info actionInfo;
358 actionInfo.action_type = ELM_ACCESS_ACTION_UP;
360 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
362 else if( mActionHandler )
364 ret = mActionHandler->AccessibilityActionUp();
367 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
372 bool AccessibilityManager::HandleActionDownEvent()
376 Dali::AccessibilityManager handle( this );
379 * In order to application decide reading action first,
380 * emit ActionDown signal in first, AccessibilityActionDown for handler in next
382 if ( !mIndicatorFocused )
384 if( !mActionDownSignal.Empty() )
386 mActionDownSignal.Emit( handle );
390 if( mIndicator && mIndicatorFocused )
392 Elm_Access_Action_Info actionInfo;
393 actionInfo.action_type = ELM_ACCESS_ACTION_DOWN;
395 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
397 else if( mActionHandler )
399 ret = mActionHandler->AccessibilityActionDown();
402 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
407 } // namespace Adaptor
409 } // namespace Internal