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 <events/event-handler.h>
23 #include <Ecore_Input.h>
24 #include <ecore-wl-render-surface.h>
29 #ifndef DALI_PROFILE_UBUNTU
31 #include <vconf-keys.h>
32 #endif // DALI_PROFILE_UBUNTU
34 #ifdef DALI_ELDBUS_AVAILABLE
36 #endif // DALI_ELDBUS_AVAILABLE
38 #include <dali/public-api/common/vector-wrapper.h>
39 #include <dali/public-api/events/touch-point.h>
40 #include <dali/public-api/events/key-event.h>
41 #include <dali/public-api/events/wheel-event.h>
42 #include <dali/integration-api/debug.h>
43 #include <dali/integration-api/events/key-event-integ.h>
44 #include <dali/integration-api/events/touch-event-integ.h>
45 #include <dali/integration-api/events/hover-event-integ.h>
46 #include <dali/integration-api/events/wheel-event-integ.h>
49 #include <events/gesture-manager.h>
50 #include <window-render-surface.h>
51 #include <clipboard-impl.h>
53 #include <physical-keyboard-impl.h>
54 #include <style-monitor-impl.h>
55 #include <base/core-event-interface.h>
56 #include <virtual-keyboard.h>
67 #if defined(DEBUG_ENABLED)
70 Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
71 Integration::Log::Filter* gClientMessageLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_CLIENT_MESSAGE");
72 Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
73 Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
74 Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
75 } // unnamed namespace
83 #define A11Y_BUS "org.a11y.Bus"
84 #define A11Y_INTERFACE "org.a11y.Bus"
85 #define A11Y_PATH "/org/a11y/bus"
86 #define A11Y_GET_ADDRESS "GetAddress"
87 #define BUS "com.samsung.EModule"
88 #define INTERFACE "com.samsung.GestureNavigation"
89 #define PATH "/com/samsung/GestureNavigation"
90 #define SIGNAL "GestureDetected"
92 const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
94 const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
96 #ifdef DALI_ELDBUS_AVAILABLE
97 // DBus gesture string matching lists.
98 // TODO: This needs moving to its own module.
99 const char * ElDBusAccessibilityFingerCountStrings[] =
105 const unsigned int FingerCountStringsTotal = sizeof( ElDBusAccessibilityFingerCountStrings ) / sizeof( ElDBusAccessibilityFingerCountStrings[0] );
110 GESTURE_TYPE_SINGLE_TAP,
111 GESTURE_TYPE_DOUBLE_TAP,
112 GESTURE_TYPE_TRIPLE_TAP
114 struct GestureTypeTable
117 const GestureType type;
119 GestureTypeTable ElDBusAccessibilityFullEventTypeStrings[] =
121 { "Hover", GESTURE_TYPE_HOVER },
122 { "SingleTap", GESTURE_TYPE_SINGLE_TAP },
123 { "DoubleTap", GESTURE_TYPE_DOUBLE_TAP },
124 { "TripleTap", GESTURE_TYPE_TRIPLE_TAP }
126 const unsigned int FullEventTypeStringsTotal = sizeof( ElDBusAccessibilityFullEventTypeStrings ) / sizeof( ElDBusAccessibilityFullEventTypeStrings[0] );
129 SUB_GESTURE_TYPE_NONE,
130 SUB_GESTURE_TYPE_FLICK
132 struct SubGestureTypeTable
135 const SubGestureType type;
137 SubGestureTypeTable ElDBusAccessibilityDirectionalEventTypeStrings[] =
139 { "Flick", SUB_GESTURE_TYPE_FLICK }
141 const unsigned int DirectionalEventTypeStringsTotal = sizeof( ElDBusAccessibilityDirectionalEventTypeStrings ) / sizeof( ElDBusAccessibilityDirectionalEventTypeStrings[0] );
142 enum GestureDirection
144 GESTURE_DIRECTION_NONE,
145 GESTURE_DIRECTION_UP,
146 GESTURE_DIRECTION_DOWN,
147 GESTURE_DIRECTION_LEFT,
148 GESTURE_DIRECTION_RIGHT,
149 GESTURE_DIRECTION_UP_RETURN,
150 GESTURE_DIRECTION_DOWN_RETURN,
151 GESTURE_DIRECTION_LEFT_RETURN,
152 GESTURE_DIRECTION_RIGHT_RETURN
154 struct GestureDirectionTable
157 const GestureDirection direction;
159 GestureDirectionTable ElDBusAccessibilityDirectionStrings[] =
161 { "Up", GESTURE_DIRECTION_UP },
162 { "Down", GESTURE_DIRECTION_DOWN },
163 { "Left", GESTURE_DIRECTION_LEFT },
164 { "Right", GESTURE_DIRECTION_RIGHT },
165 { "UpReturn", GESTURE_DIRECTION_UP_RETURN },
166 { "DownReturn", GESTURE_DIRECTION_DOWN_RETURN },
167 { "LeftReturn", GESTURE_DIRECTION_LEFT_RETURN },
168 { "RightReturn", GESTURE_DIRECTION_RIGHT_RETURN }
170 const unsigned int DirectionStringsTotal = sizeof( ElDBusAccessibilityDirectionStrings ) / sizeof( ElDBusAccessibilityDirectionStrings[0] );
171 #endif // DALI_ELDBUS_AVAILABLE
174 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
175 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
176 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
177 * @return the Ecore_IMF_Keyboard_Modifiers output.
179 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
181 int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
184 if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
186 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
189 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
191 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
194 if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
196 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
199 if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
201 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
204 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
206 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
209 return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
213 // Copied from x server
214 static unsigned int GetCurrentMilliSeconds(void)
219 static clockid_t clockid;
223 #ifdef CLOCK_MONOTONIC_COARSE
224 if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
225 (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
227 clockid = CLOCK_MONOTONIC_COARSE;
231 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
233 clockid = CLOCK_MONOTONIC;
240 if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
242 return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
245 gettimeofday(&tv, NULL);
246 return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
249 #ifndef DALI_PROFILE_UBUNTU
250 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
251 #endif // DALI_PROFILE_UBUNTU
253 } // unnamed namespace
255 // Impl to hide EFL implementation.
256 struct EventHandler::Impl
258 // Construction & Destruction
263 Impl( EventHandler* handler, Ecore_Wl_Window* window )
264 : mHandler( handler ),
265 mEcoreEventHandler(),
267 #ifdef DALI_ELDBUS_AVAILABLE
268 , mSessionConnection( NULL ),
269 mA11yConnection( NULL )
272 // Only register for touch and key events if we have a window
275 // Register Touch events
276 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
277 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
278 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
279 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, handler ) ); // process mouse out event like up event
281 // Register Mouse wheel events
282 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
284 // Register Focus events
285 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
286 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
288 // Register Key events
289 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
290 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
292 // Register Selection event - clipboard selection
293 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, handler ) );
294 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, handler ) );
296 // Register Rotate event
297 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, handler) );
299 // Register Detent event
300 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetent, handler) );
302 #ifndef DALI_PROFILE_UBUNTU
303 // Register Vconf notify - font name and size
304 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged, handler );
305 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
306 #endif // DALI_PROFILE_UBUNTU
308 #ifdef DALI_ELDBUS_AVAILABLE
310 // Initialize ElDBus.
311 DALI_LOG_INFO( gImfLogging, Debug::General, "Starting DBus Initialization\n" );
314 mSessionConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SESSION );
316 Eldbus_Object *a11yObject = eldbus_object_get( mSessionConnection, A11Y_BUS, A11Y_PATH );
317 Eldbus_Proxy *elDBusManager = eldbus_proxy_get( a11yObject, A11Y_INTERFACE );
319 // Pass in handler in the cb_data field so we can access the accessibility adaptor within the callback.
320 eldbus_proxy_call( elDBusManager, A11Y_GET_ADDRESS, EcoreElDBusInitialisation, handler, -1, "" );
322 DALI_LOG_INFO( gImfLogging, Debug::General, "Finished DBus Initialization\n" );
324 #endif // DALI_ELDBUS_AVAILABLE
333 #ifndef DALI_PROFILE_UBUNTU
334 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
335 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged );
336 #endif // DALI_PROFILE_UBUNTU
338 for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
340 ecore_event_handler_del( *iter );
343 #ifdef DALI_ELDBUS_AVAILABLE
345 if( mA11yConnection )
347 eldbus_connection_unref( mA11yConnection );
350 if( mSessionConnection )
352 eldbus_connection_unref( mSessionConnection );
356 #endif // DALI_ELDBUS_AVAILABLE
361 /////////////////////////////////////////////////////////////////////////////////////////////////
363 /////////////////////////////////////////////////////////////////////////////////////////////////
366 * Called when a touch down is received.
368 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
370 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
371 EventHandler* handler( (EventHandler*)data );
373 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
375 PointState::Type state ( PointState::DOWN );
377 // Check if the buttons field is set and ensure it's the primary touch button.
378 // If this event was triggered by buttons other than the primary button (used for touch), then
379 // just send an interrupted event to Core.
380 if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
382 state = PointState::INTERRUPTED;
385 Integration::Point point;
386 point.SetDeviceId( touchEvent->multi.device );
387 point.SetState( state );
388 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
389 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
390 point.SetPressure( touchEvent->multi.pressure );
391 point.SetAngle( Degree( touchEvent->multi.angle ) );
392 handler->SendEvent( point, touchEvent->timestamp );
395 return ECORE_CALLBACK_PASS_ON;
399 * Called when a touch up is received.
401 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
403 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
404 EventHandler* handler( (EventHandler*)data );
406 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
408 Integration::Point point;
409 point.SetDeviceId( touchEvent->multi.device );
410 point.SetState( PointState::UP );
411 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
412 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
413 point.SetPressure( touchEvent->multi.pressure );
414 point.SetAngle( Degree( touchEvent->multi.angle ) );
415 handler->SendEvent( point, touchEvent->timestamp );
418 return ECORE_CALLBACK_PASS_ON;
422 * Called when a touch up is received.
424 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
426 Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
428 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT Ecore_Event_Mouse_Wheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
430 EventHandler* handler( (EventHandler*)data );
431 if ( mouseWheelEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
433 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp );
434 handler->SendWheelEvent( wheelEvent );
436 return ECORE_CALLBACK_PASS_ON;
440 * Called when a touch motion is received.
442 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
444 Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
445 EventHandler* handler( (EventHandler*)data );
447 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
449 Integration::Point point;
450 point.SetDeviceId( touchEvent->multi.device );
451 point.SetState( PointState::MOTION );
452 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
453 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
454 point.SetPressure( touchEvent->multi.pressure );
455 point.SetAngle( Degree( touchEvent->multi.angle ) );
456 handler->SendEvent( point, touchEvent->timestamp );
459 return ECORE_CALLBACK_PASS_ON;
462 /////////////////////////////////////////////////////////////////////////////////////////////////
464 /////////////////////////////////////////////////////////////////////////////////////////////////
467 * Called when a key down is received.
469 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
471 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
473 EventHandler* handler( (EventHandler*)data );
474 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
475 bool eventHandled( false );
477 // If a device key then skip ecore_imf_context_filter_event.
478 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
480 Ecore_IMF_Context* imfContext = NULL;
481 Dali::ImfManager imfManager( ImfManager::Get() );
484 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
489 // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
490 Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
491 ecoreKeyDownEvent.keyname = keyEvent->keyname;
492 ecoreKeyDownEvent.key = keyEvent->key;
493 ecoreKeyDownEvent.string = keyEvent->string;
494 ecoreKeyDownEvent.compose = keyEvent->compose;
495 ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
496 ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
497 ecoreKeyDownEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
498 #ifdef ECORE_IMF_1_13
499 ecoreKeyDownEvent.dev_name = "";
500 ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
501 ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
502 #endif // ECORE_IMF_1_13
504 eventHandled = ecore_imf_context_filter_event( imfContext,
505 ECORE_IMF_EVENT_KEY_DOWN,
506 (Ecore_IMF_Event *) &ecoreKeyDownEvent );
508 // If the event has not been handled by IMF then check if we should reset our IMF context
511 if ( !strcmp( keyEvent->keyname, "Escape" ) ||
512 !strcmp( keyEvent->keyname, "Return" ) ||
513 !strcmp( keyEvent->keyname, "KP_Enter" ) )
515 ecore_imf_context_reset( imfContext );
521 // If the event wasn't handled then we should send a key event.
524 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
526 std::string keyName( keyEvent->keyname );
527 std::string keyString( "" );
528 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
529 keyCode = (keyCode == -1) ? 0 : keyCode;
530 int modifier( keyEvent->modifiers );
531 unsigned long time = keyEvent->timestamp;
532 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
533 keyCode = atoi(keyEvent->keyname + 8);
535 // Ensure key event string is not NULL as keys like SHIFT have a null string.
536 if ( keyEvent->string )
538 keyString = keyEvent->string;
541 KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Down);
542 handler->SendEvent( keyEvent );
546 return ECORE_CALLBACK_PASS_ON;
550 * Called when a key up is received.
552 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
554 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp\n" );
556 EventHandler* handler( (EventHandler*)data );
557 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
558 bool eventHandled( false );
560 // Device keys like Menu, home, back button must skip ecore_imf_context_filter_event.
561 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
563 Ecore_IMF_Context* imfContext = NULL;
564 Dali::ImfManager imfManager( ImfManager::Get() );
567 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
572 // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
573 Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
574 ecoreKeyUpEvent.keyname = keyEvent->keyname;
575 ecoreKeyUpEvent.key = keyEvent->key;
576 ecoreKeyUpEvent.string = keyEvent->string;
577 ecoreKeyUpEvent.compose = keyEvent->compose;
578 ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
579 ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
580 ecoreKeyUpEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
582 eventHandled = ecore_imf_context_filter_event( imfContext,
583 ECORE_IMF_EVENT_KEY_UP,
584 (Ecore_IMF_Event *) &ecoreKeyUpEvent );
588 // If the event wasn't handled then we should send a key event.
591 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
593 std::string keyName( keyEvent->keyname );
594 std::string keyString( "" );
595 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
596 keyCode = (keyCode == -1) ? 0 : keyCode;
597 int modifier( keyEvent->modifiers );
598 unsigned long time = keyEvent->timestamp;
599 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
600 keyCode = atoi(keyEvent->keyname + 8);
602 // Ensure key event string is not NULL as keys like SHIFT have a null string.
603 if ( keyEvent->string )
605 keyString = keyEvent->string;
608 KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, KeyEvent::Up);
609 handler->SendEvent( keyEvent );
613 return ECORE_CALLBACK_PASS_ON;
616 /////////////////////////////////////////////////////////////////////////////////////////////////
618 /////////////////////////////////////////////////////////////////////////////////////////////////
621 * Called when the window gains focus.
623 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
625 Ecore_Wl_Event_Focus_In* focusInEvent( (Ecore_Wl_Event_Focus_In*)event );
626 EventHandler* handler( (EventHandler*)data );
628 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
630 // If the window gains focus and we hid the keyboard then show it again.
631 if ( focusInEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
633 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
635 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
637 Dali::ImfManager imfManager( ImfManager::Get() );
640 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
641 if( imfManagerImpl.RestoreAfterFocusLost() )
643 imfManagerImpl.Activate();
647 Dali::Clipboard clipboard = Clipboard::Get();
648 clipboard.HideClipboard();
651 return ECORE_CALLBACK_PASS_ON;
655 * Called when the window loses focus.
657 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
659 Ecore_Wl_Event_Focus_Out* focusOutEvent( (Ecore_Wl_Event_Focus_Out*)event );
660 EventHandler* handler( (EventHandler*)data );
662 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
664 // If the window loses focus then hide the keyboard.
665 if ( focusOutEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
667 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
669 Dali::ImfManager imfManager( ImfManager::Get() );
672 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
673 if( imfManagerImpl.RestoreAfterFocusLost() )
675 imfManagerImpl.Deactivate();
680 // Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard
681 Dali::Clipboard clipboard = Clipboard::Get();
684 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
685 clipBoardImpl.HideClipboard(true);
689 return ECORE_CALLBACK_PASS_ON;
693 * Called when the window is damaged.
695 static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
697 return ECORE_CALLBACK_PASS_ON;
701 * Called when the window properties are changed.
702 * We are only interested in the font change.
706 /////////////////////////////////////////////////////////////////////////////////////////////////
707 // Drag & Drop Callbacks
708 /////////////////////////////////////////////////////////////////////////////////////////////////
711 * Called when a dragged item enters our window's bounds.
712 * This is when items are dragged INTO our window.
714 static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
716 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
718 return ECORE_CALLBACK_PASS_ON;
722 * Called when a dragged item is moved within our window.
723 * This is when items are dragged INTO our window.
725 static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
727 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
729 return ECORE_CALLBACK_PASS_ON;
733 * Called when a dragged item leaves our window's bounds.
734 * This is when items are dragged INTO our window.
736 static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
738 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
740 return ECORE_CALLBACK_PASS_ON;
744 * Called when the dragged item is dropped within our window's bounds.
745 * This is when items are dragged INTO our window.
747 static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
749 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
751 return ECORE_CALLBACK_PASS_ON;
755 * Called when a dragged item is moved from our window and the target window has done processing it.
756 * This is when items are dragged FROM our window.
758 static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
760 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
761 return ECORE_CALLBACK_PASS_ON;
765 * Called when a dragged item is moved from our window and the target window has sent us a status.
766 * This is when items are dragged FROM our window.
768 static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
770 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
771 return ECORE_CALLBACK_PASS_ON;
775 * Called when the client messages (i.e. the accessibility events) are received.
777 static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
779 return ECORE_CALLBACK_PASS_ON;
783 /////////////////////////////////////////////////////////////////////////////////////////////////
784 // ElDBus Accessibility Callbacks
785 /////////////////////////////////////////////////////////////////////////////////////////////////
787 #ifdef DALI_ELDBUS_AVAILABLE
788 // Callback for Ecore ElDBus accessibility events.
789 static void OnEcoreElDBusAccessibilityNotification( void *context EINA_UNUSED, const Eldbus_Message *message )
791 EventHandler* handler = static_cast< EventHandler* >( context );
792 // Ignore any accessibility events when paused.
793 if( handler->mPaused )
798 if ( !handler->mAccessibilityAdaptor )
800 DALI_LOG_ERROR( "Invalid accessibility adaptor\n" );
804 AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( handler->mAccessibilityAdaptor ) );
805 if ( !accessibilityAdaptor )
807 DALI_LOG_ERROR( "Cannot access accessibility adaptor\n" );
811 const char *gestureName;
815 // The string defines the arg-list's respective types.
816 if( !eldbus_message_arguments_get( message, "siiiiu", &gestureName, &xS, &yS, &xE, &yE, &state ) )
818 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
821 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Name: %s Args: %d,%d,%d,%d State: %d\n", gestureName, xS, yS, xE, yE );
823 unsigned int fingers = 0;
824 char* stringPosition = ( char* )gestureName;
826 // Check how many fingers the gesture uses.
827 for( unsigned int i = 0; i < FingerCountStringsTotal; ++i )
829 unsigned int matchLength = strlen( ElDBusAccessibilityFingerCountStrings[ i ] );
830 if( strncmp( gestureName, ElDBusAccessibilityFingerCountStrings[ i ], matchLength ) == 0 )
833 stringPosition += matchLength;
840 // Error: invalid gesture.
844 GestureType gestureType = GESTURE_TYPE_NONE;
845 SubGestureType subGestureType = SUB_GESTURE_TYPE_NONE;
846 GestureDirection direction = GESTURE_DIRECTION_NONE;
848 // Check for full gesture type names first.
849 for( unsigned int i = 0; i < FullEventTypeStringsTotal; ++i )
851 unsigned int matchLength = strlen( ElDBusAccessibilityFullEventTypeStrings[ i ].name );
852 if( strncmp( stringPosition, ElDBusAccessibilityFullEventTypeStrings[ i ].name, matchLength ) == 0 )
854 gestureType = ElDBusAccessibilityFullEventTypeStrings[ i ].type;
859 // If we didn't find a full gesture, check for sub gesture type names.
860 if( gestureType == GESTURE_TYPE_NONE )
862 // No full gesture name found, look for partial types.
863 for( unsigned int i = 0; i < DirectionalEventTypeStringsTotal; ++i )
865 unsigned int matchLength = strlen( ElDBusAccessibilityDirectionalEventTypeStrings[ i ].name );
866 if( strncmp( stringPosition, ElDBusAccessibilityDirectionalEventTypeStrings[ i ].name, matchLength ) == 0 )
868 subGestureType = ElDBusAccessibilityDirectionalEventTypeStrings[ i ].type;
869 stringPosition += matchLength;
874 if( subGestureType == SUB_GESTURE_TYPE_NONE )
876 // ERROR: Gesture not recognised.
880 // If the gesture was a sub type, get it's respective direction.
881 for( unsigned int i = 0; i < DirectionStringsTotal; ++i )
883 unsigned int matchLength = strlen( ElDBusAccessibilityDirectionStrings[ i ].name );
884 if( strncmp( stringPosition, ElDBusAccessibilityDirectionStrings[ i ].name, matchLength ) == 0 )
886 direction = ElDBusAccessibilityDirectionStrings[ i ].direction;
887 stringPosition += matchLength;
892 if( direction == GESTURE_DIRECTION_NONE )
894 // ERROR: Gesture not recognised.
899 // Action the detected gesture here.
900 if( gestureType != GESTURE_TYPE_NONE )
902 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Fingers: %d Gesture type: %d\n", fingers, gestureType );
906 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Fingers: %d Gesture sub type: %d Gesture direction: %d\n",
907 fingers, subGestureType, direction );
910 // Create a touch point object.
911 TouchPoint::State touchPointState( TouchPoint::Down );
914 touchPointState = TouchPoint::Down; // Mouse down.
916 else if ( state == 1 )
918 touchPointState = TouchPoint::Motion; // Mouse move.
920 else if ( state == 2 )
922 touchPointState = TouchPoint::Up; // Mouse up.
926 touchPointState = TouchPoint::Interrupted; // Error.
929 // Send touch event to accessibility adaptor.
930 TouchPoint point( 0, touchPointState, (float)xS, (float)yS );
932 // Perform actions based on received gestures.
933 // Note: This is seperated from the reading so we can (in future)
934 // have other input readers without changing the below code.
939 if( gestureType == GESTURE_TYPE_SINGLE_TAP || ( gestureType == GESTURE_TYPE_HOVER && touchPointState == TouchPoint::Motion ) )
942 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
944 else if( gestureType == GESTURE_TYPE_DOUBLE_TAP )
946 if( false ) // TODO: how to detect double tap + hold
948 // Move or drag icon / view more options for selected items.
949 // accessibilityAdaptor->HandleActionTouchEvent( point, GetCurrentMilliSeconds() );
953 // Activate selected item / active edit mode.
954 accessibilityAdaptor->HandleActionActivateEvent();
957 else if( gestureType == GESTURE_TYPE_TRIPLE_TAP )
960 accessibilityAdaptor->HandleActionZoomEvent();
962 else if( subGestureType == SUB_GESTURE_TYPE_FLICK )
964 if( direction == GESTURE_DIRECTION_LEFT )
966 // Move to previous item.
967 accessibilityAdaptor->HandleActionReadPreviousEvent();
969 else if( direction == GESTURE_DIRECTION_RIGHT )
971 // Move to next item.
972 accessibilityAdaptor->HandleActionReadNextEvent();
974 else if( direction == GESTURE_DIRECTION_UP )
976 // Move to next item.
977 accessibilityAdaptor->HandleActionPreviousEvent();
979 else if( direction == GESTURE_DIRECTION_DOWN )
981 // Move to next item.
982 accessibilityAdaptor->HandleActionNextEvent();
984 else if( direction == GESTURE_DIRECTION_LEFT_RETURN )
986 // Scroll up to the previous page
987 accessibilityAdaptor->HandleActionPageUpEvent();
989 else if( direction == GESTURE_DIRECTION_RIGHT_RETURN )
991 // Scroll down to the next page
992 accessibilityAdaptor->HandleActionPageDownEvent();
994 else if( direction == GESTURE_DIRECTION_UP_RETURN )
996 // Move to the first item on screen
997 accessibilityAdaptor->HandleActionMoveToFirstEvent();
999 else if( direction == GESTURE_DIRECTION_DOWN_RETURN )
1001 // Move to the last item on screen
1002 accessibilityAdaptor->HandleActionMoveToLastEvent();
1010 if( gestureType == GESTURE_TYPE_HOVER )
1012 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
1013 accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
1015 else if( gestureType == GESTURE_TYPE_SINGLE_TAP )
1017 // Pause/Resume current speech
1018 accessibilityAdaptor->HandleActionReadPauseResumeEvent();
1020 else if( gestureType == GESTURE_TYPE_DOUBLE_TAP )
1022 // Start/Stop current action
1023 accessibilityAdaptor->HandleActionStartStopEvent();
1025 else if( gestureType == GESTURE_TYPE_TRIPLE_TAP )
1027 // Read information from indicator
1028 accessibilityAdaptor->HandleActionReadIndicatorInformationEvent();
1030 else if( subGestureType == SUB_GESTURE_TYPE_FLICK )
1032 if( direction == GESTURE_DIRECTION_LEFT )
1034 // Scroll left to the previous page
1035 accessibilityAdaptor->HandleActionPageLeftEvent();
1037 else if( direction == GESTURE_DIRECTION_RIGHT )
1039 // Scroll right to the next page
1040 accessibilityAdaptor->HandleActionPageRightEvent();
1042 else if( direction == GESTURE_DIRECTION_UP )
1044 // Scroll up the list.
1045 accessibilityAdaptor->HandleActionScrollUpEvent();
1047 else if( direction == GESTURE_DIRECTION_DOWN )
1049 // Scroll down the list.
1050 accessibilityAdaptor->HandleActionScrollDownEvent();
1058 if( gestureType == GESTURE_TYPE_SINGLE_TAP )
1060 // Read from top item on screen continuously.
1061 accessibilityAdaptor->HandleActionReadFromTopEvent();
1063 else if( gestureType == GESTURE_TYPE_DOUBLE_TAP )
1065 // Read from next item continuously.
1066 accessibilityAdaptor->HandleActionReadFromNextEvent();
1073 // Callback for to set up Ecore ElDBus for accessibility callbacks.
1074 static void EcoreElDBusInitialisation( void *handle, const Eldbus_Message *message, Eldbus_Pending *pending EINA_UNUSED )
1076 Eldbus_Object *object;
1077 Eldbus_Proxy *manager;
1078 const char *a11yBusAddress = NULL;
1079 EventHandler* handler = static_cast< EventHandler* >( handle );
1081 // The string defines the arg-list's respective types.
1082 if( !eldbus_message_arguments_get( message, "s", &a11yBusAddress ) )
1084 DALI_LOG_ERROR( "EcoreElDBusInitialisation: Error getting arguments\n" );
1087 DALI_LOG_INFO( gImfLogging, Debug::General, "Ecore ElDBus Accessibility address: %s\n", a11yBusAddress );
1089 handler->mImpl->mA11yConnection = eldbus_address_connection_get( a11yBusAddress );
1091 object = eldbus_object_get( handler->mImpl->mA11yConnection, BUS, PATH );
1092 manager = eldbus_proxy_get( object, INTERFACE );
1094 // Pass the callback data through to the signal handler.
1095 eldbus_proxy_signal_handler_add( manager, SIGNAL, OnEcoreElDBusAccessibilityNotification, handle );
1097 #endif // DALI_ELDBUS_AVAILABLE
1100 * Called when the source window notifies us the content in clipboard is selected.
1102 static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
1104 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
1105 return ECORE_CALLBACK_PASS_ON;
1109 * Called when the source window sends us about the selected content.
1110 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
1112 static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
1114 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
1115 return ECORE_CALLBACK_PASS_ON;
1119 * Called when the source window notifies us the content in clipboard is selected.
1121 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
1123 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataSend\n" );
1125 Dali::Clipboard clipboard = Clipboard::Get();
1128 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1129 clipBoardImpl.ExcuteBuffered( true, event );
1131 return ECORE_CALLBACK_PASS_ON;
1135 * Called when the source window sends us about the selected content.
1136 * For example, when item is selected in the clipboard.
1138 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
1140 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataReceive\n" );
1142 EventHandler* handler( (EventHandler*)data );
1143 Dali::Clipboard clipboard = Clipboard::Get();
1144 char *selectionData = NULL;
1147 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1148 selectionData = clipBoardImpl.ExcuteBuffered( false, event );
1150 if ( selectionData && handler->mClipboardEventNotifier )
1152 ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
1153 std::string content( selectionData, strlen(selectionData) );
1155 clipboardEventNotifier.SetContent( content );
1156 clipboardEventNotifier.EmitContentSelectedSignal();
1158 return ECORE_CALLBACK_PASS_ON;
1162 * Called when rotate event is recevied
1164 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
1166 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::Concise, "EcoreEventRotate\n" );
1168 EventHandler* handler( (EventHandler*)data );
1169 Ecore_Wl_Event_Window_Rotate* ev( (Ecore_Wl_Event_Window_Rotate*)event );
1171 if( ev->win != (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
1173 return ECORE_CALLBACK_PASS_ON;
1176 RotationEvent rotationEvent;
1177 rotationEvent.angle = ev->angle;
1178 rotationEvent.winResize = 0;
1179 rotationEvent.width = ev->w;
1180 rotationEvent.height = ev->h;
1181 handler->SendRotationPrepareEvent( rotationEvent );
1183 return ECORE_CALLBACK_PASS_ON;
1187 * Called when detent event is recevied
1189 static Eina_Bool EcoreEventDetent( void* data, int type, void* event )
1191 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDetent\n" );
1192 EventHandler* handler( (EventHandler*)data );
1193 Ecore_Event_Detent_Rotate *e((Ecore_Event_Detent_Rotate *)event);
1194 int direction = (e->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1195 int timeStamp = e->timestamp;
1197 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp );
1198 handler->SendWheelEvent( wheelEvent );
1199 return ECORE_CALLBACK_PASS_ON;
1202 /////////////////////////////////////////////////////////////////////////////////////////////////
1204 /////////////////////////////////////////////////////////////////////////////////////////////////
1206 * Called when a font name is changed.
1208 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
1210 EventHandler* handler = static_cast<EventHandler*>( data );
1211 handler->SendEvent( StyleChange::DEFAULT_FONT_CHANGE );
1215 * Called when a font size is changed.
1217 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
1219 EventHandler* handler = static_cast<EventHandler*>( data );
1220 handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1224 EventHandler* mHandler;
1225 std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
1226 Ecore_Wl_Window* mWindow;
1228 #ifdef DALI_ELDBUS_AVAILABLE
1229 Eldbus_Connection* mSessionConnection;
1230 Eldbus_Connection* mA11yConnection;
1234 EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
1235 : mCoreEventInterface( coreEventInterface ),
1236 mGestureManager( gestureManager ),
1237 mStyleMonitor( StyleMonitor::Get() ),
1238 mDamageObserver( damageObserver ),
1239 mRotationObserver( NULL ),
1240 mDragAndDropDetector( dndDetector ),
1241 mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
1242 mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
1243 mClipboard( Clipboard::Get() ),
1247 Ecore_Wl_Window* window = 0;
1249 // this code only works with the Ecore RenderSurface so need to downcast
1250 ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
1253 window = ecoreSurface->GetWlWindow();
1256 mImpl = new Impl(this, window);
1259 EventHandler::~EventHandler()
1266 mGestureManager.Stop();
1269 void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
1273 timeStamp = GetCurrentMilliSeconds();
1276 Integration::TouchEvent touchEvent;
1277 Integration::HoverEvent hoverEvent;
1278 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
1279 if(type != Integration::TouchEventCombiner::DispatchNone )
1281 DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.deviceId, point.state, point.local.x, point.local.y);
1283 // First the touch and/or hover event & related gesture events are queued
1284 if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
1286 mCoreEventInterface.QueueCoreEvent( touchEvent );
1287 mGestureManager.SendEvent(touchEvent);
1290 if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
1292 mCoreEventInterface.QueueCoreEvent( hoverEvent );
1295 // Next the events are processed with a single call into Core
1296 mCoreEventInterface.ProcessCoreEvents();
1300 void EventHandler::SendEvent(KeyEvent& keyEvent)
1302 Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
1303 if ( physicalKeyboard )
1305 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ) )
1307 GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
1311 // Create KeyEvent and send to Core.
1312 Integration::KeyEvent event(keyEvent.keyPressedName, keyEvent.keyPressed, keyEvent.keyCode,
1313 keyEvent.keyModifier, keyEvent.time, static_cast<Integration::KeyEvent::State>(keyEvent.state));
1314 mCoreEventInterface.QueueCoreEvent( event );
1315 mCoreEventInterface.ProcessCoreEvents();
1318 void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
1320 // Create WheelEvent and send to Core.
1321 Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
1322 mCoreEventInterface.QueueCoreEvent( event );
1323 mCoreEventInterface.ProcessCoreEvents();
1326 void EventHandler::SendEvent( StyleChange::Type styleChange )
1328 DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
1329 GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
1332 void EventHandler::SendEvent( const DamageArea& area )
1334 mDamageObserver.OnDamaged( area );
1337 void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
1339 if( mRotationObserver != NULL )
1341 mRotationObserver->OnRotationPrepare( event );
1342 mRotationObserver->OnRotationRequest();
1346 void EventHandler::SendRotationRequestEvent( )
1348 // No need to separate event into prepare and request in wayland
1351 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
1353 Integration::Point convertedPoint( point );
1354 SendEvent(convertedPoint, timeStamp);
1357 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
1359 SendWheelEvent( wheelEvent );
1362 void EventHandler::FeedKeyEvent( KeyEvent& event )
1367 void EventHandler::FeedEvent( Integration::Event& event )
1369 mCoreEventInterface.QueueCoreEvent( event );
1370 mCoreEventInterface.ProcessCoreEvents();
1373 void EventHandler::Reset()
1377 // Any touch listeners should be told of the interruption.
1378 Integration::TouchEvent event;
1379 Integration::Point point;
1380 point.SetState( PointState::INTERRUPTED );
1381 event.AddPoint( point );
1383 // First the touch event & related gesture events are queued
1384 mCoreEventInterface.QueueCoreEvent( event );
1385 mGestureManager.SendEvent( event );
1387 // Next the events are processed with a single call into Core
1388 mCoreEventInterface.ProcessCoreEvents();
1391 void EventHandler::Pause()
1397 void EventHandler::Resume()
1403 void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
1405 mDragAndDropDetector = detector;
1408 void EventHandler::SetRotationObserver( RotationObserver* observer )
1410 mRotationObserver = observer;
1413 } // namespace Adaptor
1415 } // namespace Internal