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>
47 #include <dali/devel-api/events/key-event-devel.h>
50 #include <events/gesture-manager.h>
51 #include <window-render-surface.h>
52 #include <clipboard-impl.h>
54 #include <physical-keyboard-impl.h>
55 #include <style-monitor-impl.h>
56 #include <base/core-event-interface.h>
57 #include <virtual-keyboard.h>
68 #if defined(DEBUG_ENABLED)
71 Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
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 const char* BUS = "org.enlightenment.wm-screen-reader";
84 const char* INTERFACE = "org.tizen.GestureNavigation";
85 const char* PATH = "/org/tizen/GestureNavigation";
87 const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
89 const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
91 #ifdef DALI_ELDBUS_AVAILABLE
92 // DBus gesture string matching lists.
93 // TODO: This needs moving to its own module.
94 const char * ElDBusAccessibilityFingerCountStrings[] =
100 const unsigned int FingerCountStringsTotal = sizeof( ElDBusAccessibilityFingerCountStrings ) / sizeof( ElDBusAccessibilityFingerCountStrings[0] );
105 GESTURE_TYPE_SINGLE_TAP,
106 GESTURE_TYPE_DOUBLE_TAP,
107 GESTURE_TYPE_TRIPLE_TAP
109 struct GestureTypeTable
112 const GestureType type;
114 GestureTypeTable ElDBusAccessibilityFullEventTypeStrings[] =
116 { "Hover", GESTURE_TYPE_HOVER },
117 { "SingleTap", GESTURE_TYPE_SINGLE_TAP },
118 { "DoubleTap", GESTURE_TYPE_DOUBLE_TAP },
119 { "TripleTap", GESTURE_TYPE_TRIPLE_TAP }
121 const unsigned int FullEventTypeStringsTotal = sizeof( ElDBusAccessibilityFullEventTypeStrings ) / sizeof( ElDBusAccessibilityFullEventTypeStrings[0] );
124 SUB_GESTURE_TYPE_NONE,
125 SUB_GESTURE_TYPE_FLICK
127 struct SubGestureTypeTable
130 const SubGestureType type;
132 SubGestureTypeTable ElDBusAccessibilityDirectionalEventTypeStrings[] =
134 { "Flick", SUB_GESTURE_TYPE_FLICK }
136 const unsigned int DirectionalEventTypeStringsTotal = sizeof( ElDBusAccessibilityDirectionalEventTypeStrings ) / sizeof( ElDBusAccessibilityDirectionalEventTypeStrings[0] );
137 enum GestureDirection
139 GESTURE_DIRECTION_NONE,
140 GESTURE_DIRECTION_UP,
141 GESTURE_DIRECTION_DOWN,
142 GESTURE_DIRECTION_LEFT,
143 GESTURE_DIRECTION_RIGHT,
144 GESTURE_DIRECTION_UP_RETURN,
145 GESTURE_DIRECTION_DOWN_RETURN,
146 GESTURE_DIRECTION_LEFT_RETURN,
147 GESTURE_DIRECTION_RIGHT_RETURN
149 struct GestureDirectionTable
152 const GestureDirection direction;
154 GestureDirectionTable ElDBusAccessibilityDirectionStrings[] =
156 { "Up", GESTURE_DIRECTION_UP },
157 { "Down", GESTURE_DIRECTION_DOWN },
158 { "Left", GESTURE_DIRECTION_LEFT },
159 { "Right", GESTURE_DIRECTION_RIGHT },
160 { "UpReturn", GESTURE_DIRECTION_UP_RETURN },
161 { "DownReturn", GESTURE_DIRECTION_DOWN_RETURN },
162 { "LeftReturn", GESTURE_DIRECTION_LEFT_RETURN },
163 { "RightReturn", GESTURE_DIRECTION_RIGHT_RETURN }
165 const unsigned int DirectionStringsTotal = sizeof( ElDBusAccessibilityDirectionStrings ) / sizeof( ElDBusAccessibilityDirectionStrings[0] );
166 #endif // DALI_ELDBUS_AVAILABLE
169 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
170 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
171 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
172 * @return the Ecore_IMF_Keyboard_Modifiers output.
174 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
176 int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
179 if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
181 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
184 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
186 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
189 if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
191 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
194 if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
196 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
199 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
201 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
204 return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
208 // Copied from x server
209 static unsigned int GetCurrentMilliSeconds(void)
214 static clockid_t clockid;
218 #ifdef CLOCK_MONOTONIC_COARSE
219 if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
220 (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
222 clockid = CLOCK_MONOTONIC_COARSE;
226 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
228 clockid = CLOCK_MONOTONIC;
235 if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
237 return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
240 gettimeofday(&tv, NULL);
241 return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
244 #ifndef DALI_PROFILE_UBUNTU
245 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
246 #endif // DALI_PROFILE_UBUNTU
249 * Get the device name from the provided ecore key event
251 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
253 const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
255 if ( ecoreDeviceName )
257 result = ecoreDeviceName;
262 * Get the device class from the provided ecore key event
264 void GetDeviceClass( Ecore_Event_Key* keyEvent, DevelKeyEvent::DeviceClass::Type& deviceClass )
266 Ecore_Device_Class ecoreDeviceClass = ecore_device_class_get( keyEvent->dev );
268 switch( ecoreDeviceClass )
270 case ECORE_DEVICE_CLASS_SEAT:
272 deviceClass = DevelKeyEvent::DeviceClass::USER;
275 case ECORE_DEVICE_CLASS_KEYBOARD:
277 deviceClass = DevelKeyEvent::DeviceClass::KEYBOARD;
280 case ECORE_DEVICE_CLASS_MOUSE:
282 deviceClass = DevelKeyEvent::DeviceClass::MOUSE;
285 case ECORE_DEVICE_CLASS_TOUCH:
287 deviceClass = DevelKeyEvent::DeviceClass::TOUCH;
290 case ECORE_DEVICE_CLASS_PEN:
292 deviceClass = DevelKeyEvent::DeviceClass::PEN;
295 case ECORE_DEVICE_CLASS_POINTER:
297 deviceClass = DevelKeyEvent::DeviceClass::POINTER;
300 case ECORE_DEVICE_CLASS_GAMEPAD:
302 deviceClass = DevelKeyEvent::DeviceClass::GAMEPAD;
307 deviceClass = DevelKeyEvent::DeviceClass::NONE;
313 } // unnamed namespace
315 // Impl to hide EFL implementation.
316 struct EventHandler::Impl
318 // Construction & Destruction
323 Impl( EventHandler* handler, Ecore_Wl_Window* window )
324 : mHandler( handler ),
325 mEcoreEventHandler(),
327 #ifdef DALI_ELDBUS_AVAILABLE
328 , mSystemConnection( NULL )
329 #endif // DALI_ELDBUS_AVAILABLE
331 // Only register for touch and key events if we have a window
334 // Register Touch events
335 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
336 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
337 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
338 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, handler ) ); // process mouse out event like up event
339 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, handler ) );
341 // Register Mouse wheel events
342 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
344 // Register Focus events
345 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
346 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
348 // Register Key events
349 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
350 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
352 // Register Selection event - clipboard selection
353 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, handler ) );
354 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, handler ) );
356 // Register Rotate event
357 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, handler) );
359 // Register Detent event
360 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetent, handler) );
362 #ifndef DALI_PROFILE_UBUNTU
363 // Register Vconf notify - font name and size
364 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged, handler );
365 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
366 #endif // DALI_PROFILE_UBUNTU
368 #ifdef DALI_ELDBUS_AVAILABLE
369 // Initialize ElDBus.
370 DALI_LOG_INFO( gImfLogging, Debug::General, "Starting DBus Initialization\n" );
373 EcoreElDBusInitialisation( handler );
375 DALI_LOG_INFO( gImfLogging, Debug::General, "Finished DBus Initialization\n" );
376 #endif // DALI_ELDBUS_AVAILABLE
385 #ifndef DALI_PROFILE_UBUNTU
386 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
387 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged );
388 #endif // DALI_PROFILE_UBUNTU
390 for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
392 ecore_event_handler_del( *iter );
395 #ifdef DALI_ELDBUS_AVAILABLE
396 // Close down ElDBus connections.
397 if( mSystemConnection )
399 eldbus_connection_unref( mSystemConnection );
401 #endif // DALI_ELDBUS_AVAILABLE
406 /////////////////////////////////////////////////////////////////////////////////////////////////
408 /////////////////////////////////////////////////////////////////////////////////////////////////
411 * Called when a touch down is received.
413 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
415 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
416 EventHandler* handler( (EventHandler*)data );
418 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
420 PointState::Type state ( PointState::DOWN );
422 // Check if the buttons field is set and ensure it's the primary touch button.
423 // If this event was triggered by buttons other than the primary button (used for touch), then
424 // just send an interrupted event to Core.
425 if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
427 state = PointState::INTERRUPTED;
430 Integration::Point point;
431 point.SetDeviceId( touchEvent->multi.device );
432 point.SetState( state );
433 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
434 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
435 point.SetPressure( touchEvent->multi.pressure );
436 point.SetAngle( Degree( touchEvent->multi.angle ) );
437 handler->SendEvent( point, touchEvent->timestamp );
440 return ECORE_CALLBACK_PASS_ON;
444 * Called when a touch up is received.
446 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
448 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
449 EventHandler* handler( (EventHandler*)data );
451 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
453 Integration::Point point;
454 point.SetDeviceId( touchEvent->multi.device );
455 point.SetState( PointState::UP );
456 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
457 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
458 point.SetPressure( touchEvent->multi.pressure );
459 point.SetAngle( Degree( touchEvent->multi.angle ) );
460 handler->SendEvent( point, touchEvent->timestamp );
463 return ECORE_CALLBACK_PASS_ON;
467 * Called when a touch motion is received.
469 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
471 Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
472 EventHandler* handler( (EventHandler*)data );
474 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
476 Integration::Point point;
477 point.SetDeviceId( touchEvent->multi.device );
478 point.SetState( PointState::MOTION );
479 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
480 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
481 point.SetPressure( touchEvent->multi.pressure );
482 point.SetAngle( Degree( touchEvent->multi.angle ) );
483 handler->SendEvent( point, touchEvent->timestamp );
486 return ECORE_CALLBACK_PASS_ON;
490 * Called when a touch is canceled.
492 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
494 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
495 EventHandler* handler( (EventHandler*)data );
497 if( touchEvent->window == (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
499 Integration::Point point;
500 point.SetDeviceId( touchEvent->multi.device );
501 point.SetState( PointState::INTERRUPTED );
502 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
503 handler->SendEvent( point, touchEvent->timestamp );
505 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventMouseButtonCancel\n" );
508 return ECORE_CALLBACK_PASS_ON;
512 * Called when a mouse wheel is received.
514 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
516 Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
518 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);
520 EventHandler* handler( (EventHandler*)data );
521 if ( mouseWheelEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
523 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp );
524 handler->SendWheelEvent( wheelEvent );
526 return ECORE_CALLBACK_PASS_ON;
529 /////////////////////////////////////////////////////////////////////////////////////////////////
531 /////////////////////////////////////////////////////////////////////////////////////////////////
534 * Called when a key down is received.
536 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
538 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
540 EventHandler* handler( (EventHandler*)data );
541 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
542 bool eventHandled( false );
544 // If a device key then skip ecore_imf_context_filter_event.
545 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
547 Ecore_IMF_Context* imfContext = NULL;
548 Dali::ImfManager imfManager( ImfManager::Get() );
551 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
556 // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
557 Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
558 ecoreKeyDownEvent.keyname = keyEvent->keyname;
559 ecoreKeyDownEvent.key = keyEvent->key;
560 ecoreKeyDownEvent.string = keyEvent->string;
561 ecoreKeyDownEvent.compose = keyEvent->compose;
562 ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
563 ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
564 ecoreKeyDownEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
565 #ifdef ECORE_IMF_1_13
566 ecoreKeyDownEvent.dev_name = "";
567 ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
568 ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
569 #endif // ECORE_IMF_1_13
571 eventHandled = ecore_imf_context_filter_event( imfContext,
572 ECORE_IMF_EVENT_KEY_DOWN,
573 (Ecore_IMF_Event *) &ecoreKeyDownEvent );
575 // If the event has not been handled by IMF then check if we should reset our IMF context
578 if ( !strcmp( keyEvent->keyname, "Escape" ) ||
579 !strcmp( keyEvent->keyname, "Return" ) ||
580 !strcmp( keyEvent->keyname, "KP_Enter" ) )
582 ecore_imf_context_reset( imfContext );
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 std::string deviceName;
609 DevelKeyEvent::DeviceClass::Type deviceClass;
611 GetDeviceName( keyEvent, deviceName );
612 GetDeviceClass( keyEvent, deviceClass );
614 DALI_LOG_INFO( gImfLogging, Debug::Verbose, "EVENT EcoreEventKeyDown - >>EcoreEventKeyDown deviceName(%s) deviceClass(%d)\n", deviceName.c_str(), deviceClass );
616 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, deviceName, deviceClass );
617 handler->SendEvent( keyEvent );
621 return ECORE_CALLBACK_PASS_ON;
625 * Called when a key up is received.
627 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
629 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp\n" );
631 EventHandler* handler( (EventHandler*)data );
632 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
633 bool eventHandled( false );
635 // Device keys like Menu, home, back button must skip ecore_imf_context_filter_event.
636 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
638 Ecore_IMF_Context* imfContext = NULL;
639 Dali::ImfManager imfManager( ImfManager::Get() );
642 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
647 // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
648 Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
649 ecoreKeyUpEvent.keyname = keyEvent->keyname;
650 ecoreKeyUpEvent.key = keyEvent->key;
651 ecoreKeyUpEvent.string = keyEvent->string;
652 ecoreKeyUpEvent.compose = keyEvent->compose;
653 ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
654 ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
655 ecoreKeyUpEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
656 #ifdef ECORE_IMF_1_13
657 ecoreKeyUpEvent.dev_name = "";
658 ecoreKeyUpEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
659 ecoreKeyUpEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
660 #endif // ECORE_IMF_1_13
662 eventHandled = ecore_imf_context_filter_event( imfContext,
663 ECORE_IMF_EVENT_KEY_UP,
664 (Ecore_IMF_Event *) &ecoreKeyUpEvent );
668 // If the event wasn't handled then we should send a key event.
671 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
673 std::string keyName( keyEvent->keyname );
674 std::string keyString( "" );
675 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
676 keyCode = (keyCode == -1) ? 0 : keyCode;
677 int modifier( keyEvent->modifiers );
678 unsigned long time = keyEvent->timestamp;
679 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
680 keyCode = atoi(keyEvent->keyname + 8);
682 // Ensure key event string is not NULL as keys like SHIFT have a null string.
683 if ( keyEvent->string )
685 keyString = keyEvent->string;
688 std::string deviceName;
689 DevelKeyEvent::DeviceClass::Type deviceClass;
691 GetDeviceName( keyEvent, deviceName );
692 GetDeviceClass( keyEvent, deviceClass );
694 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, deviceName, deviceClass );
695 handler->SendEvent( keyEvent );
699 return ECORE_CALLBACK_PASS_ON;
702 /////////////////////////////////////////////////////////////////////////////////////////////////
704 /////////////////////////////////////////////////////////////////////////////////////////////////
707 * Called when the window gains focus.
709 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
711 Ecore_Wl_Event_Focus_In* focusInEvent( (Ecore_Wl_Event_Focus_In*)event );
712 EventHandler* handler( (EventHandler*)data );
714 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
716 // If the window gains focus and we hid the keyboard then show it again.
717 if ( focusInEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
719 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
721 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
723 Dali::ImfManager imfManager( ImfManager::Get() );
726 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
727 if( imfManagerImpl.RestoreAfterFocusLost() )
729 imfManagerImpl.Activate();
733 Dali::Clipboard clipboard = Clipboard::Get();
734 clipboard.HideClipboard();
737 return ECORE_CALLBACK_PASS_ON;
741 * Called when the window loses focus.
743 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
745 Ecore_Wl_Event_Focus_Out* focusOutEvent( (Ecore_Wl_Event_Focus_Out*)event );
746 EventHandler* handler( (EventHandler*)data );
748 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
750 // If the window loses focus then hide the keyboard.
751 if ( focusOutEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
753 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
755 Dali::ImfManager imfManager( ImfManager::Get() );
758 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
759 if( imfManagerImpl.RestoreAfterFocusLost() )
761 imfManagerImpl.Deactivate();
766 // Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard
767 Dali::Clipboard clipboard = Clipboard::Get();
770 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
771 clipBoardImpl.HideClipboard(true);
775 return ECORE_CALLBACK_PASS_ON;
779 * Called when the window is damaged.
781 static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
783 return ECORE_CALLBACK_PASS_ON;
787 * Called when the window properties are changed.
788 * We are only interested in the font change.
792 /////////////////////////////////////////////////////////////////////////////////////////////////
793 // Drag & Drop Callbacks
794 /////////////////////////////////////////////////////////////////////////////////////////////////
797 * Called when a dragged item enters our window's bounds.
798 * This is when items are dragged INTO our window.
800 static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
802 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
804 return ECORE_CALLBACK_PASS_ON;
808 * Called when a dragged item is moved within our window.
809 * This is when items are dragged INTO our window.
811 static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
813 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
815 return ECORE_CALLBACK_PASS_ON;
819 * Called when a dragged item leaves our window's bounds.
820 * This is when items are dragged INTO our window.
822 static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
824 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
826 return ECORE_CALLBACK_PASS_ON;
830 * Called when the dragged item is dropped within our window's bounds.
831 * This is when items are dragged INTO our window.
833 static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
835 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
837 return ECORE_CALLBACK_PASS_ON;
841 * Called when a dragged item is moved from our window and the target window has done processing it.
842 * This is when items are dragged FROM our window.
844 static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
846 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
847 return ECORE_CALLBACK_PASS_ON;
851 * Called when a dragged item is moved from our window and the target window has sent us a status.
852 * This is when items are dragged FROM our window.
854 static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
856 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
857 return ECORE_CALLBACK_PASS_ON;
861 * Called when the client messages (i.e. the accessibility events) are received.
863 static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
865 return ECORE_CALLBACK_PASS_ON;
869 /////////////////////////////////////////////////////////////////////////////////////////////////
870 // ElDBus Accessibility Callbacks
871 /////////////////////////////////////////////////////////////////////////////////////////////////
873 #ifdef DALI_ELDBUS_AVAILABLE
874 // Callback for Ecore ElDBus accessibility events.
875 static void OnEcoreElDBusAccessibilityNotification( void *context EINA_UNUSED, const Eldbus_Message *message )
877 EventHandler* handler = static_cast< EventHandler* >( context );
878 // Ignore any accessibility events when paused.
879 if( handler->mPaused )
884 if( !handler->mAccessibilityAdaptor )
886 DALI_LOG_ERROR( "Invalid accessibility adaptor\n" );
890 AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( handler->mAccessibilityAdaptor ) );
891 if( !accessibilityAdaptor )
893 DALI_LOG_ERROR( "Cannot access accessibility adaptor\n" );
899 int state; // 0 - begin, 1 - ongoing, 2 - ended, 3 - aborted
902 // The string defines the arg-list's respective types.
903 if( !eldbus_message_arguments_get( message, "iiiiiiu", &gestureValue, &xS, &yS, &xE, &yE, &state, &eventTime ) )
905 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
908 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Name: %d Args: %d,%d,%d,%d State: %d\n", gestureValue, xS, yS, xE, yE );
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 have other input readers without changing the below code.
934 switch( gestureValue )
936 case 0: // OneFingerHover
939 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
942 case 1: // TwoFingersHover
944 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
945 accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
948 case 2: // ThreeFingersHover
950 // Read from top item on screen continuously.
951 accessibilityAdaptor->HandleActionReadFromTopEvent();
954 case 3: // OneFingerFlickLeft
956 // Move to previous item.
957 accessibilityAdaptor->HandleActionReadPreviousEvent();
960 case 4: // OneFingerFlickRight
962 // Move to next item.
963 accessibilityAdaptor->HandleActionReadNextEvent();
966 case 5: // OneFingerFlickUp
968 // Move to previous item.
969 accessibilityAdaptor->HandleActionPreviousEvent();
972 case 6: // OneFingerFlickDown
974 // Move to next item.
975 accessibilityAdaptor->HandleActionNextEvent();
978 case 7: // TwoFingersFlickUp
980 // Scroll up the list.
981 accessibilityAdaptor->HandleActionScrollUpEvent();
984 case 8: // TwoFingersFlickDown
986 // Scroll down the list.
987 accessibilityAdaptor->HandleActionScrollDownEvent();
990 case 9: // TwoFingersFlickLeft
992 // Scroll left to the previous page
993 accessibilityAdaptor->HandleActionPageLeftEvent();
996 case 10: // TwoFingersFlickRight
998 // Scroll right to the next page
999 accessibilityAdaptor->HandleActionPageRightEvent();
1002 case 11: // ThreeFingersFlickLeft
1007 case 12: // ThreeFingersFlickRight
1012 case 13: // ThreeFingersFlickUp
1017 case 14: // ThreeFingersFlickDown
1022 case 15: // OneFingerSingleTap
1025 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
1028 case 16: // OneFingerDoubleTap
1030 // Activate selected item / active edit mode.
1031 accessibilityAdaptor->HandleActionActivateEvent();
1034 case 17: // OneFingerTripleTap
1037 accessibilityAdaptor->HandleActionZoomEvent();
1040 case 18: // TwoFingersSingleTap
1042 // Pause/Resume current speech
1043 accessibilityAdaptor->HandleActionReadPauseResumeEvent();
1046 case 19: // TwoFingersDoubleTap
1048 // Start/Stop current action
1049 accessibilityAdaptor->HandleActionStartStopEvent();
1052 case 20: // TwoFingersTripleTap
1054 // Read information from indicator
1055 accessibilityAdaptor->HandleActionReadIndicatorInformationEvent();
1058 case 21: // ThreeFingersSingleTap
1060 // Read from top item on screen continuously.
1061 accessibilityAdaptor->HandleActionReadFromTopEvent();
1064 case 22: // ThreeFingersDoubleTap
1066 // Read from next item continuously.
1067 accessibilityAdaptor->HandleActionReadFromNextEvent();
1070 case 23: // ThreeFingersTripleTap
1075 case 24: // OneFingerFlickLeftReturn
1077 // Scroll up to the previous page
1078 accessibilityAdaptor->HandleActionPageUpEvent();
1081 case 25: // OneFingerFlickRightReturn
1083 // Scroll down to the next page
1084 accessibilityAdaptor->HandleActionPageDownEvent();
1087 case 26: // OneFingerFlickUpReturn
1089 // Move to the first item on screen
1090 accessibilityAdaptor->HandleActionMoveToFirstEvent();
1093 case 27: // OneFingerFlickDownReturn
1095 // Move to the last item on screen
1096 accessibilityAdaptor->HandleActionMoveToLastEvent();
1099 case 28: // TwoFingersFlickLeftReturn
1104 case 29: // TwoFingersFlickRightReturn
1109 case 30: // TwoFingersFlickUpReturn
1114 case 31: // TwoFingersFlickDownReturn
1119 case 32: // ThreeFingersFlickLeftReturn
1124 case 33: // ThreeFingersFlickRightReturn
1129 case 34: // ThreeFingersFlickUpReturn
1134 case 35: // ThreeFingersFlickDownReturn
1142 void EcoreElDBusInitialisation( void *handle )
1144 Eldbus_Object *object;
1145 Eldbus_Proxy *manager;
1147 if( !( mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM) ) )
1149 DALI_LOG_ERROR( "Unable to get system bus\n" );
1152 object = eldbus_object_get( mSystemConnection, BUS, PATH );
1155 DALI_LOG_ERROR( "Getting object failed\n" );
1159 manager = eldbus_proxy_get( object, INTERFACE );
1162 DALI_LOG_ERROR( "Getting proxy failed\n" );
1166 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", OnEcoreElDBusAccessibilityNotification, handle ) )
1168 DALI_LOG_ERROR( "No signal handler returned\n" );
1171 #endif // DALI_ELDBUS_AVAILABLE
1174 * Called when the source window notifies us the content in clipboard is selected.
1176 static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
1178 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
1179 return ECORE_CALLBACK_PASS_ON;
1183 * Called when the source window sends us about the selected content.
1184 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
1186 static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
1188 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
1189 return ECORE_CALLBACK_PASS_ON;
1193 * Called when the source window notifies us the content in clipboard is selected.
1195 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
1197 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataSend\n" );
1199 Dali::Clipboard clipboard = Clipboard::Get();
1202 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1203 clipBoardImpl.ExcuteBuffered( true, event );
1205 return ECORE_CALLBACK_PASS_ON;
1209 * Called when the source window sends us about the selected content.
1210 * For example, when item is selected in the clipboard.
1212 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
1214 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataReceive\n" );
1216 EventHandler* handler( (EventHandler*)data );
1217 Dali::Clipboard clipboard = Clipboard::Get();
1218 char *selectionData = NULL;
1221 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1222 selectionData = clipBoardImpl.ExcuteBuffered( false, event );
1224 if ( selectionData && handler->mClipboardEventNotifier )
1226 ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
1227 std::string content( selectionData, strlen(selectionData) );
1229 clipboardEventNotifier.SetContent( content );
1230 clipboardEventNotifier.EmitContentSelectedSignal();
1232 return ECORE_CALLBACK_PASS_ON;
1236 * Called when rotate event is recevied
1238 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
1240 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::Concise, "EcoreEventRotate\n" );
1242 EventHandler* handler( (EventHandler*)data );
1243 Ecore_Wl_Event_Window_Rotate* ev( (Ecore_Wl_Event_Window_Rotate*)event );
1245 if( ev->win != (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
1247 return ECORE_CALLBACK_PASS_ON;
1250 RotationEvent rotationEvent;
1251 rotationEvent.angle = ev->angle;
1252 rotationEvent.winResize = 0;
1253 rotationEvent.width = ev->w;
1254 rotationEvent.height = ev->h;
1255 handler->SendRotationPrepareEvent( rotationEvent );
1257 return ECORE_CALLBACK_PASS_ON;
1261 * Called when detent event is recevied
1263 static Eina_Bool EcoreEventDetent( void* data, int type, void* event )
1265 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDetent\n" );
1266 EventHandler* handler( (EventHandler*)data );
1267 Ecore_Event_Detent_Rotate *e((Ecore_Event_Detent_Rotate *)event);
1268 int direction = (e->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1269 int timeStamp = e->timestamp;
1271 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp );
1272 handler->SendWheelEvent( wheelEvent );
1273 return ECORE_CALLBACK_PASS_ON;
1276 /////////////////////////////////////////////////////////////////////////////////////////////////
1278 /////////////////////////////////////////////////////////////////////////////////////////////////
1280 * Called when a font name is changed.
1282 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
1284 EventHandler* handler = static_cast<EventHandler*>( data );
1285 handler->SendEvent( StyleChange::DEFAULT_FONT_CHANGE );
1289 * Called when a font size is changed.
1291 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
1293 EventHandler* handler = static_cast<EventHandler*>( data );
1294 handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1298 EventHandler* mHandler;
1299 std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
1300 Ecore_Wl_Window* mWindow;
1301 #ifdef DALI_ELDBUS_AVAILABLE
1302 Eldbus_Connection* mSystemConnection;
1303 #endif // DALI_ELDBUS_AVAILABLE
1306 EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
1307 : mCoreEventInterface( coreEventInterface ),
1308 mGestureManager( gestureManager ),
1309 mStyleMonitor( StyleMonitor::Get() ),
1310 mDamageObserver( damageObserver ),
1311 mRotationObserver( NULL ),
1312 mDragAndDropDetector( dndDetector ),
1313 mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
1314 mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
1315 mClipboard( Clipboard::Get() ),
1319 Ecore_Wl_Window* window = 0;
1321 // this code only works with the Ecore RenderSurface so need to downcast
1322 ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
1325 window = ecoreSurface->GetWlWindow();
1328 mImpl = new Impl(this, window);
1331 EventHandler::~EventHandler()
1338 mGestureManager.Stop();
1341 void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
1345 timeStamp = GetCurrentMilliSeconds();
1348 Integration::TouchEvent touchEvent;
1349 Integration::HoverEvent hoverEvent;
1350 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
1351 if(type != Integration::TouchEventCombiner::DispatchNone )
1353 DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetLocalPosition().x, point.GetLocalPosition().y);
1355 // First the touch and/or hover event & related gesture events are queued
1356 if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
1358 mCoreEventInterface.QueueCoreEvent( touchEvent );
1359 mGestureManager.SendEvent(touchEvent);
1362 if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
1364 mCoreEventInterface.QueueCoreEvent( hoverEvent );
1367 // Next the events are processed with a single call into Core
1368 mCoreEventInterface.ProcessCoreEvents();
1372 void EventHandler::SendEvent(Integration::KeyEvent& keyEvent)
1374 Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
1375 if ( physicalKeyboard )
1377 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
1379 GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
1383 // Create send KeyEvent to Core.
1384 mCoreEventInterface.QueueCoreEvent( keyEvent );
1385 mCoreEventInterface.ProcessCoreEvents();
1388 void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
1390 // Create WheelEvent and send to Core.
1391 Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
1392 mCoreEventInterface.QueueCoreEvent( event );
1393 mCoreEventInterface.ProcessCoreEvents();
1396 void EventHandler::SendEvent( StyleChange::Type styleChange )
1398 DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
1399 GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
1402 void EventHandler::SendEvent( const DamageArea& area )
1404 mDamageObserver.OnDamaged( area );
1407 void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
1409 if( mRotationObserver != NULL )
1411 mRotationObserver->OnRotationPrepare( event );
1412 mRotationObserver->OnRotationRequest();
1416 void EventHandler::SendRotationRequestEvent( )
1418 // No need to separate event into prepare and request in wayland
1421 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
1423 Integration::Point convertedPoint( point );
1424 SendEvent(convertedPoint, timeStamp);
1427 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
1429 SendWheelEvent( wheelEvent );
1432 void EventHandler::FeedKeyEvent( KeyEvent& event )
1434 Integration::KeyEvent convertedEvent( event );
1435 SendEvent( convertedEvent );
1438 void EventHandler::FeedEvent( Integration::Event& event )
1440 mCoreEventInterface.QueueCoreEvent( event );
1441 mCoreEventInterface.ProcessCoreEvents();
1444 void EventHandler::Reset()
1448 // Any touch listeners should be told of the interruption.
1449 Integration::TouchEvent event;
1450 Integration::Point point;
1451 point.SetState( PointState::INTERRUPTED );
1452 event.AddPoint( point );
1454 // First the touch event & related gesture events are queued
1455 mCoreEventInterface.QueueCoreEvent( event );
1456 mGestureManager.SendEvent( event );
1458 // Next the events are processed with a single call into Core
1459 mCoreEventInterface.ProcessCoreEvents();
1462 void EventHandler::Pause()
1468 void EventHandler::Resume()
1474 void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
1476 mDragAndDropDetector = detector;
1479 void EventHandler::SetRotationObserver( RotationObserver* observer )
1481 mRotationObserver = observer;
1484 } // namespace Adaptor
1486 } // namespace Internal