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/integration-api/debug.h>
27 #include <dali/integration-api/events/gesture-requests.h>
30 #include "system-settings.h"
32 #define MSG_DOMAIN_CONTROL_ACCESS (int)ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL
44 #if defined(DEBUG_ENABLED)
45 Debug::Filter* gAccessibilityManagerLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_MANAGER");
47 } // unnamed namespace
49 bool AccessibilityManager::HandleActionNextEvent(bool allowEndFeedback)
52 Dali::AccessibilityManager handle( this );
55 * In order to application decide reading action first,
56 * emit ActionNext signal in first, AccessibilityActionNext for handler in next
58 if( !mIndicatorFocused )
60 if( !mActionNextSignal.Empty() )
62 mActionNextSignal.Emit( handle );
66 if( mIndicator && mIndicatorFocused )
68 Elm_Access_Action_Info actionInfo;
69 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
71 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
73 else if( mActionHandler )
75 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
78 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
83 bool AccessibilityManager::HandleActionPreviousEvent(bool allowEndFeedback)
87 Dali::AccessibilityManager handle( this );
90 * In order to application decide reading action first,
91 * emit ActionPrevious signal in first, AccessibilityActionPrevious for handler in next
93 if ( !mIndicatorFocused )
95 if( !mActionPreviousSignal.Empty() )
97 mActionPreviousSignal.Emit( handle );
101 if( mIndicator && mIndicatorFocused )
103 Elm_Access_Action_Info actionInfo;
104 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
106 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
108 else if( mActionHandler )
110 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
113 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
118 bool AccessibilityManager::HandleActionActivateEvent()
122 Dali::AccessibilityManager handle( this );
125 * In order to application decide reading action first,
126 * emit ActionActivate signal in first, AccessibilityActionActivate for handler in next
128 if ( !mIndicatorFocused )
130 if( !mActionActivateSignal.Empty() )
132 mActionActivateSignal.Emit( handle );
136 if( mIndicator && mIndicatorFocused )
138 Elm_Access_Action_Info actionInfo;
139 actionInfo.action_type = ELM_ACCESS_ACTION_ACTIVATE;
141 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
143 else if( mActionHandler )
145 ret = mActionHandler->AccessibilityActionActivate();
148 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
153 bool AccessibilityManager::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
157 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
162 Dali::AccessibilityManager handle( this );
164 bool indicatorFocused = false;
166 // Check whether the Indicator is focused
167 if( mIndicator && mIndicator->IsConnected() )
169 // Check the position and size of Indicator actor
170 Dali::Actor indicatorActor = mIndicator->GetActor();
171 Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
172 Vector3 size = indicatorActor.GetCurrentSize();
174 if(mReadPosition.x >= position.x &&
175 mReadPosition.x <= position.x + size.width &&
176 mReadPosition.y >= position.y &&
177 mReadPosition.y <= position.y + size.height)
179 indicatorFocused = true;
180 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
186 if( !mIndicatorFocused && indicatorFocused )
188 // If Indicator is focused, the focus should be cleared in Dali focus chain.
191 mActionHandler->ClearAccessibilityFocus();
194 else if( mIndicatorFocused && !indicatorFocused )
196 Elm_Access_Action_Info actionInfo;
197 actionInfo.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
199 // Indicator should be unhighlighted
200 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
201 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send unhighlight message to indicator!!!!\n", __FUNCTION__, __LINE__);
204 mIndicatorFocused = indicatorFocused;
206 // Send accessibility READ action information to Indicator
207 if( mIndicatorFocused )
209 Elm_Access_Action_Info actionInfo;
210 actionInfo.x = mReadPosition.x;
211 actionInfo.y = mReadPosition.y;
215 actionInfo.action_type = ELM_ACCESS_ACTION_READ;
219 actionInfo.action_type = static_cast<Elm_Access_Action_Type>( GetElmAccessActionOver() );
222 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
224 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] Send READ message to indicator!!!!\n", __FUNCTION__, __LINE__);
231 * In order to application decide reading action first,
232 * emit ActionRead signal in first, AccessibilityActionRead for handler in next
234 if( !mIndicatorFocused )
236 if ( !mActionReadSignal.Empty() )
238 mActionReadSignal.Emit( handle );
245 * In order to application decide reading action first,
246 * emit ActionRead signal in first, AccessibilityActionRead for handler in next
248 if( !mIndicatorFocused )
250 if ( !mActionOverSignal.Empty() )
252 mActionOverSignal.Emit( handle );
257 if( mActionHandler && !mIndicatorFocused)
259 // If Indicator is not focused, the accessibility actions should be handled by the registered
260 // accessibility action handler (e.g. focus manager)
261 ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
262 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
268 bool AccessibilityManager::HandleActionReadNextEvent(bool allowEndFeedback)
272 Dali::AccessibilityManager handle( this );
275 * In order to application decide reading action first,
276 * emit ActionReadNext signal in first, AccessibilityActionReadNext for handler in next
278 if ( !mIndicatorFocused )
280 if( !mActionReadNextSignal.Empty() )
282 mActionReadNextSignal.Emit( handle );
286 if( mIndicator && mIndicatorFocused )
288 Elm_Access_Action_Info actionInfo;
289 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
291 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
293 else if( mActionHandler )
295 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
298 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
303 bool AccessibilityManager::HandleActionReadPreviousEvent(bool allowEndFeedback)
307 Dali::AccessibilityManager handle( this );
310 * In order to application decide reading action first,
311 * emit ActionReadPrevious signal in first, AccessibilityActionReadPrevious for handler in next
313 if ( !mIndicatorFocused )
315 if( !mActionReadPreviousSignal.Empty() )
317 mActionReadPreviousSignal.Emit( handle );
321 if( mIndicator && mIndicatorFocused )
323 Elm_Access_Action_Info actionInfo;
324 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
326 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
328 else if( mActionHandler )
330 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
333 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
338 bool AccessibilityManager::HandleActionUpEvent()
342 Dali::AccessibilityManager handle( this );
345 * In order to application decide reading action first,
346 * emit ActionUp signal in first, AccessibilityActionUp for handler in next
348 if ( !mIndicatorFocused )
350 if( !mActionUpSignal.Empty() )
352 mActionUpSignal.Emit( handle );
356 if( mIndicator && mIndicatorFocused )
358 Elm_Access_Action_Info actionInfo;
359 actionInfo.action_type = ELM_ACCESS_ACTION_UP;
361 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
363 else if( mActionHandler )
365 ret = mActionHandler->AccessibilityActionUp();
368 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
373 bool AccessibilityManager::HandleActionDownEvent()
377 Dali::AccessibilityManager handle( this );
380 * In order to application decide reading action first,
381 * emit ActionDown signal in first, AccessibilityActionDown for handler in next
383 if ( !mIndicatorFocused )
385 if( !mActionDownSignal.Empty() )
387 mActionDownSignal.Emit( handle );
391 if( mIndicator && mIndicatorFocused )
393 Elm_Access_Action_Info actionInfo;
394 actionInfo.action_type = ELM_ACCESS_ACTION_DOWN;
396 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
398 else if( mActionHandler )
400 ret = mActionHandler->AccessibilityActionDown();
403 DALI_LOG_INFO(gAccessibilityManagerLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
408 } // namespace Adaptor
410 } // namespace Internal