2 * Copyright (c) 2015 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-adaptor-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* gAccessibilityAdaptorLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACCESSIBILITY_ADAPTOR");
47 } // unnamed namespace
49 bool AccessibilityAdaptor::HandleActionNextEvent(bool allowEndFeedback)
53 if( mIndicator && mIndicatorFocused )
55 Elm_Access_Action_Info actionInfo;
56 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
58 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
60 else if( mActionHandler )
62 ret = mActionHandler->AccessibilityActionNext(allowEndFeedback);
65 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
70 bool AccessibilityAdaptor::HandleActionPreviousEvent(bool allowEndFeedback)
74 if( mIndicator && mIndicatorFocused )
76 Elm_Access_Action_Info actionInfo;
77 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
79 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
81 else if( mActionHandler )
83 ret = mActionHandler->AccessibilityActionPrevious(allowEndFeedback);
86 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
91 bool AccessibilityAdaptor::HandleActionActivateEvent()
95 if( mIndicator && mIndicatorFocused )
97 Elm_Access_Action_Info actionInfo;
98 actionInfo.action_type = ELM_ACCESS_ACTION_ACTIVATE;
100 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
102 else if( mActionHandler )
104 ret = mActionHandler->AccessibilityActionActivate();
107 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
112 bool AccessibilityAdaptor::HandleActionReadEvent(unsigned int x, unsigned int y, bool allowReadAgain)
116 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %d , %d\n", __FUNCTION__, __LINE__, x, y);
121 Dali::AccessibilityAdaptor handle( this );
123 bool indicatorFocused = false;
125 // Check whether the Indicator is focused
126 if( mIndicator && mIndicator->IsConnected() )
128 // Check the position and size of Indicator actor
129 Dali::Actor indicatorActor = mIndicator->GetActor();
130 Vector3 position = Vector3(0.0f, 0.0f, 0.0f);
131 Vector3 size = indicatorActor.GetCurrentSize();
133 if(mReadPosition.x >= position.x &&
134 mReadPosition.x <= position.x + size.width &&
135 mReadPosition.y >= position.y &&
136 mReadPosition.y <= position.y + size.height)
138 indicatorFocused = true;
139 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] Indicator area!!!!\n", __FUNCTION__, __LINE__);
145 if( !mIndicatorFocused && indicatorFocused )
147 // If Indicator is focused, the focus should be cleared in Dali focus chain.
150 mActionHandler->ClearAccessibilityFocus();
153 else if( mIndicatorFocused && !indicatorFocused )
155 Elm_Access_Action_Info actionInfo;
156 actionInfo.action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
158 // Indicator should be unhighlighted
159 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
160 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] Send unhighlight message to indicator!!!!\n", __FUNCTION__, __LINE__);
163 mIndicatorFocused = indicatorFocused;
165 // Send accessibility READ action information to Indicator
166 if( mIndicatorFocused )
168 Elm_Access_Action_Info actionInfo;
169 actionInfo.x = mReadPosition.x;
170 actionInfo.y = mReadPosition.y;
174 actionInfo.action_type = ELM_ACCESS_ACTION_READ;
178 actionInfo.action_type = static_cast<Elm_Access_Action_Type>( GetElmAccessActionOver() );
181 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
183 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] Send READ message to indicator!!!!\n", __FUNCTION__, __LINE__);
187 if( mActionHandler && !mIndicatorFocused)
189 // If Indicator is not focused, the accessibility actions should be handled by the registered
190 // accessibility action handler (e.g. focus manager)
191 ret = mActionHandler->AccessibilityActionRead(allowReadAgain);
192 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
198 bool AccessibilityAdaptor::HandleActionReadNextEvent(bool allowEndFeedback)
202 if( mIndicator && mIndicatorFocused )
204 Elm_Access_Action_Info actionInfo;
205 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
207 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
209 else if( mActionHandler )
211 ret = mActionHandler->AccessibilityActionReadNext(allowEndFeedback);
214 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
219 bool AccessibilityAdaptor::HandleActionReadPreviousEvent(bool allowEndFeedback)
223 if( mIndicator && mIndicatorFocused )
225 Elm_Access_Action_Info actionInfo;
226 actionInfo.action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
228 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
230 else if( mActionHandler )
232 ret = mActionHandler->AccessibilityActionReadPrevious(allowEndFeedback);
235 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
240 bool AccessibilityAdaptor::HandleActionUpEvent()
244 if( mIndicator && mIndicatorFocused )
246 Elm_Access_Action_Info actionInfo;
247 actionInfo.action_type = ELM_ACCESS_ACTION_UP;
249 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
251 else if( mActionHandler )
253 ret = mActionHandler->AccessibilityActionUp();
256 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
261 bool AccessibilityAdaptor::HandleActionDownEvent()
265 if( mIndicator && mIndicatorFocused )
267 Elm_Access_Action_Info actionInfo;
268 actionInfo.action_type = ELM_ACCESS_ACTION_DOWN;
270 ret = mIndicator->SendMessage(MSG_DOMAIN_CONTROL_ACCESS, actionInfo.action_type, &actionInfo, sizeof(actionInfo));
272 else if( mActionHandler )
274 ret = mActionHandler->AccessibilityActionDown();
277 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
282 bool AccessibilityAdaptor::HandleActionScrollUpEvent()
286 if( mIndicator && mIndicatorFocused )
288 // TODO: Send message to indicator with the correct action type
290 else if( mActionHandler )
292 ret = mActionHandler->AccessibilityActionScrollUp();
295 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
301 bool AccessibilityAdaptor::HandleActionScrollDownEvent()
305 if( mIndicator && mIndicatorFocused )
307 // TODO: Send message to indicator with the correct action type
309 else if( mActionHandler )
311 ret = mActionHandler->AccessibilityActionScrollDown();
314 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
319 bool AccessibilityAdaptor::HandleActionPageLeftEvent()
323 if( mIndicator && mIndicatorFocused )
325 // TODO: Send message to indicator with the correct action type
327 else if( mActionHandler )
329 ret = mActionHandler->AccessibilityActionPageLeft();
332 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
337 bool AccessibilityAdaptor::HandleActionPageRightEvent()
341 if( mIndicator && mIndicatorFocused )
343 // TODO: Send message to indicator with the correct action type
345 else if( mActionHandler )
347 ret = mActionHandler->AccessibilityActionPageRight();
350 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
355 bool AccessibilityAdaptor::HandleActionPageUpEvent()
359 if( mIndicator && mIndicatorFocused )
361 // TODO: Send message to indicator with the correct action type
363 else if( mActionHandler )
365 ret = mActionHandler->AccessibilityActionPageUp();
368 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
373 bool AccessibilityAdaptor::HandleActionPageDownEvent()
377 if( mIndicator && mIndicatorFocused )
379 // TODO: Send message to indicator with the correct action type
381 else if( mActionHandler )
383 ret = mActionHandler->AccessibilityActionPageDown();
386 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
391 bool AccessibilityAdaptor::HandleActionMoveToFirstEvent()
395 if( mIndicator && mIndicatorFocused )
397 // TODO: Send message to indicator with the correct action type
399 else if( mActionHandler )
401 ret = mActionHandler->AccessibilityActionMoveToFirst();
404 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
409 bool AccessibilityAdaptor::HandleActionMoveToLastEvent()
413 if( mIndicator && mIndicatorFocused )
415 // TODO: Send message to indicator with the correct action type
417 else if( mActionHandler )
419 ret = mActionHandler->AccessibilityActionMoveToLast();
422 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
427 bool AccessibilityAdaptor::HandleActionReadFromTopEvent()
431 if( mIndicator && mIndicatorFocused )
433 // TODO: Send message to indicator with the correct action type
435 else if( mActionHandler )
437 ret = mActionHandler->AccessibilityActionReadFromTop();
440 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
445 bool AccessibilityAdaptor::HandleActionReadFromNextEvent()
449 if( mIndicator && mIndicatorFocused )
451 // TODO: Send message to indicator with the correct action type
453 else if( mActionHandler )
455 ret = mActionHandler->AccessibilityActionReadFromNext();
458 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
463 bool AccessibilityAdaptor::HandleActionZoomEvent()
467 if( mIndicator && mIndicatorFocused )
469 // TODO: Send message to indicator with the correct action type
471 else if( mActionHandler )
473 ret = mActionHandler->AccessibilityActionZoom();
476 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
481 bool AccessibilityAdaptor::HandleActionReadIndicatorInformationEvent()
485 if( mIndicator && mIndicatorFocused )
487 // TODO: Send message to indicator with the correct action type
489 else if( mActionHandler )
491 ret = mActionHandler->AccessibilityActionReadIndicatorInformation();
494 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
499 bool AccessibilityAdaptor::HandleActionReadPauseResumeEvent()
503 if( mIndicator && mIndicatorFocused )
505 // TODO: Send message to indicator with the correct action type
507 else if( mActionHandler )
509 ret = mActionHandler->AccessibilityActionReadPauseResume();
512 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
517 bool AccessibilityAdaptor::HandleActionStartStopEvent()
521 if( mIndicator && mIndicatorFocused )
523 // TODO: Send message to indicator with the correct action type
525 else if( mActionHandler )
527 ret = mActionHandler->AccessibilityActionStartStop();
530 DALI_LOG_INFO(gAccessibilityAdaptorLogFilter, Debug::General, "[%s:%d] %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
535 } // namespace Adaptor
537 } // namespace Internal