2 * Copyright (c) 2017 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>
22 // Ecore is littered with C style cast
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wold-style-cast"
26 #include <Ecore_Input.h>
27 #include <ecore-wl-render-surface.h>
32 #ifndef DALI_PROFILE_UBUNTU
34 #include <vconf-keys.h>
35 #endif // DALI_PROFILE_UBUNTU
37 #ifdef DALI_ELDBUS_AVAILABLE
39 #endif // DALI_ELDBUS_AVAILABLE
41 #include <dali/public-api/common/vector-wrapper.h>
42 #include <dali/public-api/events/touch-point.h>
43 #include <dali/public-api/events/key-event.h>
44 #include <dali/public-api/events/wheel-event.h>
45 #include <dali/integration-api/debug.h>
46 #include <dali/integration-api/events/key-event-integ.h>
47 #include <dali/integration-api/events/touch-event-integ.h>
48 #include <dali/integration-api/events/hover-event-integ.h>
49 #include <dali/integration-api/events/wheel-event-integ.h>
50 #include <dali/devel-api/events/device.h>
53 #include <events/gesture-manager.h>
54 #include <window-render-surface.h>
55 #include <clipboard-impl.h>
57 #include <physical-keyboard-impl.h>
58 #include <style-monitor-impl.h>
59 #include <base/core-event-interface.h>
60 #include <virtual-keyboard.h>
71 #if defined(DEBUG_ENABLED)
74 Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
75 Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
76 Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
77 Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
78 } // unnamed namespace
86 const char* BUS = "org.enlightenment.wm-screen-reader";
87 const char* INTERFACE = "org.tizen.GestureNavigation";
88 const char* PATH = "/org/tizen/GestureNavigation";
90 const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
92 const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
95 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
96 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
97 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
98 * @return the Ecore_IMF_Keyboard_Modifiers output.
100 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
102 int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
105 if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
107 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
110 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
112 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
115 if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
117 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
120 if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
122 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
125 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
127 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
130 return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
134 // Copied from x server
135 static unsigned int GetCurrentMilliSeconds(void)
140 static clockid_t clockid;
144 #ifdef CLOCK_MONOTONIC_COARSE
145 if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
146 (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
148 clockid = CLOCK_MONOTONIC_COARSE;
152 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
154 clockid = CLOCK_MONOTONIC;
161 if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
163 return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
166 gettimeofday(&tv, NULL);
167 return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
170 #ifndef DALI_PROFILE_UBUNTU
171 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
172 #endif // DALI_PROFILE_UBUNTU
175 * Get the device name from the provided ecore key event
177 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
179 const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
181 if ( ecoreDeviceName )
183 result = ecoreDeviceName;
188 * Get the device class from the provided ecore event
190 void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, DevelDevice::Class::Type& deviceClass )
192 switch( ecoreDeviceClass )
194 case ECORE_DEVICE_CLASS_SEAT:
196 deviceClass = DevelDevice::Class::USER;
199 case ECORE_DEVICE_CLASS_KEYBOARD:
201 deviceClass = DevelDevice::Class::KEYBOARD;
204 case ECORE_DEVICE_CLASS_MOUSE:
206 deviceClass = DevelDevice::Class::MOUSE;
209 case ECORE_DEVICE_CLASS_TOUCH:
211 deviceClass = DevelDevice::Class::TOUCH;
214 case ECORE_DEVICE_CLASS_PEN:
216 deviceClass = DevelDevice::Class::PEN;
219 case ECORE_DEVICE_CLASS_POINTER:
221 deviceClass = DevelDevice::Class::POINTER;
224 case ECORE_DEVICE_CLASS_GAMEPAD:
226 deviceClass = DevelDevice::Class::GAMEPAD;
231 deviceClass = DevelDevice::Class::NONE;
237 void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, DevelDevice::Subclass::Type& deviceSubclass )
239 switch( ecoreDeviceSubclass )
241 case ECORE_DEVICE_SUBCLASS_FINGER:
243 deviceSubclass = DevelDevice::Subclass::FINGER;
246 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
248 deviceSubclass = DevelDevice::Subclass::FINGERNAIL;
251 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
253 deviceSubclass = DevelDevice::Subclass::KNUCKLE;
256 case ECORE_DEVICE_SUBCLASS_PALM:
258 deviceSubclass = DevelDevice::Subclass::PALM;
261 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
263 deviceSubclass = DevelDevice::Subclass::HAND_SIDE;
266 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
268 deviceSubclass = DevelDevice::Subclass::HAND_FLAT;
271 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
273 deviceSubclass = DevelDevice::Subclass::PEN_TIP;
276 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
278 deviceSubclass = DevelDevice::Subclass::TRACKPAD;
281 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
283 deviceSubclass = DevelDevice::Subclass::TRACKPOINT;
286 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
288 deviceSubclass = DevelDevice::Subclass::TRACKBALL;
293 deviceSubclass = DevelDevice::Subclass::NONE;
299 } // unnamed namespace
301 // Impl to hide EFL implementation.
302 struct EventHandler::Impl
304 // Construction & Destruction
309 Impl( EventHandler* handler, Ecore_Wl_Window* window )
310 : mHandler( handler ),
311 mEcoreEventHandler(),
316 #ifdef DALI_ELDBUS_AVAILABLE
317 , mSystemConnection( NULL )
318 #endif // DALI_ELDBUS_AVAILABLE
320 // Only register for touch and key events if we have a window
323 // Register Touch events
324 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
325 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
326 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
327 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, handler ) );
329 // Register Mouse wheel events
330 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
332 // Register Focus events
333 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
334 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
336 // Register Key events
337 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
338 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
340 // Register Selection event - clipboard selection
341 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, handler ) );
342 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, handler ) );
344 // Register Rotate event
345 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, handler) );
347 // Register Detent event
348 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetent, handler) );
350 #ifndef DALI_PROFILE_UBUNTU
351 // Register Vconf notify - font name and size
352 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged, handler );
353 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
354 #endif // DALI_PROFILE_UBUNTU
356 #ifdef DALI_ELDBUS_AVAILABLE
357 // Initialize ElDBus.
358 DALI_LOG_INFO( gImfLogging, Debug::General, "Starting DBus Initialization\n" );
361 EcoreElDBusInitialisation( handler );
363 DALI_LOG_INFO( gImfLogging, Debug::General, "Finished DBus Initialization\n" );
364 #endif // DALI_ELDBUS_AVAILABLE
373 #ifndef DALI_PROFILE_UBUNTU
374 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
375 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged );
376 #endif // DALI_PROFILE_UBUNTU
378 for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
380 ecore_event_handler_del( *iter );
383 #ifdef DALI_ELDBUS_AVAILABLE
384 // Close down ElDBus connections.
385 if( mSystemConnection )
387 eldbus_connection_unref( mSystemConnection );
389 #endif // DALI_ELDBUS_AVAILABLE
394 /////////////////////////////////////////////////////////////////////////////////////////////////
396 /////////////////////////////////////////////////////////////////////////////////////////////////
399 * Called when a touch down is received.
401 static Eina_Bool EcoreEventMouseButtonDown( 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 PointState::Type state ( PointState::DOWN );
410 // Check if the buttons field is set and ensure it's the primary touch button.
411 // If this event was triggered by buttons other than the primary button (used for touch), then
412 // just send an interrupted event to Core.
413 if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
415 state = PointState::INTERRUPTED;
418 DevelDevice::Class::Type deviceClass;
419 DevelDevice::Subclass::Type deviceSubclass;
421 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
422 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
424 Integration::Point point;
425 point.SetDeviceId( touchEvent->multi.device );
426 point.SetState( state );
427 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
428 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
429 point.SetPressure( touchEvent->multi.pressure );
430 point.SetAngle( Degree( touchEvent->multi.angle ) );
431 point.SetDeviceClass( deviceClass );
432 point.SetDeviceSubclass( deviceSubclass );
434 handler->SendEvent( point, touchEvent->timestamp );
437 return ECORE_CALLBACK_PASS_ON;
441 * Called when a touch up is received.
443 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
445 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
446 EventHandler* handler( (EventHandler*)data );
448 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
450 DevelDevice::Class::Type deviceClass;
451 DevelDevice::Subclass::Type deviceSubclass;
453 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
454 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
456 Integration::Point point;
457 point.SetDeviceId( touchEvent->multi.device );
458 point.SetState( PointState::UP );
459 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
460 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
461 point.SetPressure( touchEvent->multi.pressure );
462 point.SetAngle( Degree( touchEvent->multi.angle ) );
463 point.SetDeviceClass( deviceClass );
464 point.SetDeviceSubclass( deviceSubclass );
466 handler->SendEvent( point, touchEvent->timestamp );
469 return ECORE_CALLBACK_PASS_ON;
473 * Called when a touch motion is received.
475 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
477 Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
478 EventHandler* handler( (EventHandler*)data );
480 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
482 DevelDevice::Class::Type deviceClass;
483 DevelDevice::Subclass::Type deviceSubclass;
485 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
486 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
488 Integration::Point point;
489 point.SetDeviceId( touchEvent->multi.device );
490 point.SetState( PointState::MOTION );
491 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
492 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
493 point.SetPressure( touchEvent->multi.pressure );
494 point.SetAngle( Degree( touchEvent->multi.angle ) );
495 point.SetDeviceClass( deviceClass );
496 point.SetDeviceSubclass( deviceSubclass );
498 handler->SendEvent( point, touchEvent->timestamp );
501 return ECORE_CALLBACK_PASS_ON;
505 * Called when a touch is canceled.
507 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
509 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
510 EventHandler* handler( (EventHandler*)data );
512 if( touchEvent->window == (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
514 Integration::Point point;
515 point.SetDeviceId( touchEvent->multi.device );
516 point.SetState( PointState::INTERRUPTED );
517 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
518 handler->SendEvent( point, touchEvent->timestamp );
520 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventMouseButtonCancel\n" );
523 return ECORE_CALLBACK_PASS_ON;
527 * Called when a mouse wheel is received.
529 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
531 Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
533 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);
535 EventHandler* handler( (EventHandler*)data );
536 if ( mouseWheelEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
538 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp );
539 handler->SendWheelEvent( wheelEvent );
541 return ECORE_CALLBACK_PASS_ON;
544 /////////////////////////////////////////////////////////////////////////////////////////////////
546 /////////////////////////////////////////////////////////////////////////////////////////////////
549 * Called when a key down is received.
551 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
553 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
555 EventHandler* handler( (EventHandler*)data );
556 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
557 bool eventHandled( false );
559 // If a device key then skip ecore_imf_context_filter_event.
560 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
562 Ecore_IMF_Context* imfContext = NULL;
563 Dali::ImfManager imfManager( ImfManager::Get() );
566 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
571 // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
572 Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
573 ecoreKeyDownEvent.keyname = keyEvent->keyname;
574 ecoreKeyDownEvent.key = keyEvent->key;
575 ecoreKeyDownEvent.string = keyEvent->string;
576 ecoreKeyDownEvent.compose = keyEvent->compose;
577 ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
578 ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
579 ecoreKeyDownEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
580 ecoreKeyDownEvent.dev_name = "";
581 ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
582 ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
584 std::string checkDevice;
585 GetDeviceName( keyEvent, checkDevice );
587 // If the device is IME and the focused key is the direction keys, then we should send a key event to move a key cursor.
588 if( ( checkDevice == "ime" ) && ( ( !strncmp( keyEvent->keyname, "Left", 4 ) ) ||
589 ( !strncmp( keyEvent->keyname, "Right", 5 ) ) ||
590 ( !strncmp( keyEvent->keyname, "Up", 2 ) ) ||
591 ( !strncmp( keyEvent->keyname, "Down", 4 ) ) ) )
597 eventHandled = ecore_imf_context_filter_event( imfContext,
598 ECORE_IMF_EVENT_KEY_DOWN,
599 (Ecore_IMF_Event *) &ecoreKeyDownEvent );
602 // If the event has not been handled by IMF then check if we should reset our IMF context
605 if ( !strcmp( keyEvent->keyname, "Escape" ) ||
606 !strcmp( keyEvent->keyname, "Return" ) ||
607 !strcmp( keyEvent->keyname, "KP_Enter" ) )
609 ecore_imf_context_reset( imfContext );
615 // If the event wasn't handled then we should send a key event.
618 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
620 std::string keyName( keyEvent->keyname );
621 std::string keyString( "" );
622 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
623 keyCode = (keyCode == -1) ? 0 : keyCode;
624 int modifier( keyEvent->modifiers );
625 unsigned long time = keyEvent->timestamp;
626 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
627 keyCode = atoi(keyEvent->keyname + 8);
629 // Ensure key event string is not NULL as keys like SHIFT have a null string.
630 if ( keyEvent->string )
632 keyString = keyEvent->string;
635 std::string deviceName;
636 DevelDevice::Class::Type deviceClass;
637 DevelDevice::Subclass::Type deviceSubclass;
639 GetDeviceName( keyEvent, deviceName );
640 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
641 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
643 DALI_LOG_INFO( gImfLogging, Debug::Verbose, "EVENT EcoreEventKeyDown - >>EcoreEventKeyDown deviceName(%s) deviceClass(%d)\n", deviceName.c_str(), deviceClass );
645 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, deviceName, deviceClass, deviceSubclass );
646 handler->SendEvent( keyEvent );
650 return ECORE_CALLBACK_PASS_ON;
654 * Called when a key up is received.
656 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
658 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp\n" );
660 EventHandler* handler( (EventHandler*)data );
661 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
662 bool eventHandled( false );
664 // Device keys like Menu, home, back button must skip ecore_imf_context_filter_event.
665 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
667 Ecore_IMF_Context* imfContext = NULL;
668 Dali::ImfManager imfManager( ImfManager::Get() );
671 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
676 // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
677 Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
678 ecoreKeyUpEvent.keyname = keyEvent->keyname;
679 ecoreKeyUpEvent.key = keyEvent->key;
680 ecoreKeyUpEvent.string = keyEvent->string;
681 ecoreKeyUpEvent.compose = keyEvent->compose;
682 ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
683 ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
684 ecoreKeyUpEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
685 ecoreKeyUpEvent.dev_name = "";
686 ecoreKeyUpEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
687 ecoreKeyUpEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
689 eventHandled = ecore_imf_context_filter_event( imfContext,
690 ECORE_IMF_EVENT_KEY_UP,
691 (Ecore_IMF_Event *) &ecoreKeyUpEvent );
695 // If the event wasn't handled then we should send a key event.
698 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
700 std::string keyName( keyEvent->keyname );
701 std::string keyString( "" );
702 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
703 keyCode = (keyCode == -1) ? 0 : keyCode;
704 int modifier( keyEvent->modifiers );
705 unsigned long time = keyEvent->timestamp;
706 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
707 keyCode = atoi(keyEvent->keyname + 8);
709 // Ensure key event string is not NULL as keys like SHIFT have a null string.
710 if ( keyEvent->string )
712 keyString = keyEvent->string;
715 std::string deviceName;
716 DevelDevice::Class::Type deviceClass;
717 DevelDevice::Subclass::Type deviceSubclass;
719 GetDeviceName( keyEvent, deviceName );
720 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
721 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
723 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, deviceName, deviceClass, deviceSubclass );
724 handler->SendEvent( keyEvent );
728 return ECORE_CALLBACK_PASS_ON;
731 /////////////////////////////////////////////////////////////////////////////////////////////////
733 /////////////////////////////////////////////////////////////////////////////////////////////////
736 * Called when the window gains focus.
738 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
740 Ecore_Wl_Event_Focus_In* focusInEvent( (Ecore_Wl_Event_Focus_In*)event );
741 EventHandler* handler( (EventHandler*)data );
743 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
745 // If the window gains focus and we hid the keyboard then show it again.
746 if ( focusInEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
748 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
750 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
752 Dali::ImfManager imfManager( ImfManager::Get() );
755 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
756 if( imfManagerImpl.RestoreAfterFocusLost() )
758 imfManagerImpl.Activate();
762 Dali::Clipboard clipboard = Clipboard::Get();
763 clipboard.HideClipboard();
766 return ECORE_CALLBACK_PASS_ON;
770 * Called when the window loses focus.
772 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
774 Ecore_Wl_Event_Focus_Out* focusOutEvent( (Ecore_Wl_Event_Focus_Out*)event );
775 EventHandler* handler( (EventHandler*)data );
777 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
779 // If the window loses focus then hide the keyboard.
780 if ( focusOutEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
782 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
784 Dali::ImfManager imfManager( ImfManager::Get() );
787 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
788 if( imfManagerImpl.RestoreAfterFocusLost() )
790 imfManagerImpl.Deactivate();
795 // Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard
796 Dali::Clipboard clipboard = Clipboard::Get();
799 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
800 clipBoardImpl.HideClipboard(true);
804 return ECORE_CALLBACK_PASS_ON;
808 * Called when the window is damaged.
810 static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
812 return ECORE_CALLBACK_PASS_ON;
816 * Called when the window properties are changed.
817 * We are only interested in the font change.
821 /////////////////////////////////////////////////////////////////////////////////////////////////
822 // Drag & Drop Callbacks
823 /////////////////////////////////////////////////////////////////////////////////////////////////
826 * Called when a dragged item enters our window's bounds.
827 * This is when items are dragged INTO our window.
829 static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
831 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
833 return ECORE_CALLBACK_PASS_ON;
837 * Called when a dragged item is moved within our window.
838 * This is when items are dragged INTO our window.
840 static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
842 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
844 return ECORE_CALLBACK_PASS_ON;
848 * Called when a dragged item leaves our window's bounds.
849 * This is when items are dragged INTO our window.
851 static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
853 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
855 return ECORE_CALLBACK_PASS_ON;
859 * Called when the dragged item is dropped within our window's bounds.
860 * This is when items are dragged INTO our window.
862 static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
864 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
866 return ECORE_CALLBACK_PASS_ON;
870 * Called when a dragged item is moved from our window and the target window has done processing it.
871 * This is when items are dragged FROM our window.
873 static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
875 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
876 return ECORE_CALLBACK_PASS_ON;
880 * Called when a dragged item is moved from our window and the target window has sent us a status.
881 * This is when items are dragged FROM our window.
883 static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
885 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
886 return ECORE_CALLBACK_PASS_ON;
890 * Called when the client messages (i.e. the accessibility events) are received.
892 static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
894 return ECORE_CALLBACK_PASS_ON;
898 /////////////////////////////////////////////////////////////////////////////////////////////////
899 // ElDBus Accessibility Callbacks
900 /////////////////////////////////////////////////////////////////////////////////////////////////
902 #ifdef DALI_ELDBUS_AVAILABLE
903 // Callback for Ecore ElDBus accessibility events.
904 static void OnEcoreElDBusAccessibilityNotification( void *context EINA_UNUSED, const Eldbus_Message *message )
906 EventHandler* handler = static_cast< EventHandler* >( context );
907 // Ignore any accessibility events when paused.
908 if( handler->mPaused )
913 if( !handler->mAccessibilityAdaptor )
915 DALI_LOG_ERROR( "Invalid accessibility adaptor\n" );
919 AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( handler->mAccessibilityAdaptor ) );
920 if( !accessibilityAdaptor )
922 DALI_LOG_ERROR( "Cannot access accessibility adaptor\n" );
928 int state; // 0 - begin, 1 - ongoing, 2 - ended, 3 - aborted
931 // The string defines the arg-list's respective types.
932 if( !eldbus_message_arguments_get( message, "iiiiiiu", &gestureValue, &xS, &yS, &xE, &yE, &state, &eventTime ) )
934 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
937 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Name: %d Args: %d,%d,%d,%d State: %d\n", gestureValue, xS, yS, xE, yE );
939 // Create a touch point object.
940 TouchPoint::State touchPointState( TouchPoint::Down );
943 touchPointState = TouchPoint::Down; // Mouse down.
945 else if( state == 1 )
947 touchPointState = TouchPoint::Motion; // Mouse move.
949 else if( state == 2 )
951 touchPointState = TouchPoint::Up; // Mouse up.
955 touchPointState = TouchPoint::Interrupted; // Error.
958 // Send touch event to accessibility adaptor.
959 TouchPoint point( 0, touchPointState, (float)xS, (float)yS );
961 // Perform actions based on received gestures.
962 // Note: This is seperated from the reading so we can have other input readers without changing the below code.
963 switch( gestureValue )
965 case 0: // OneFingerHover
968 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
971 case 1: // TwoFingersHover
973 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
974 accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
977 case 2: // ThreeFingersHover
979 // Read from top item on screen continuously.
980 accessibilityAdaptor->HandleActionReadFromTopEvent();
983 case 3: // OneFingerFlickLeft
985 // Move to previous item.
986 accessibilityAdaptor->HandleActionReadPreviousEvent();
989 case 4: // OneFingerFlickRight
991 // Move to next item.
992 accessibilityAdaptor->HandleActionReadNextEvent();
995 case 5: // OneFingerFlickUp
997 // Move to previous item.
998 accessibilityAdaptor->HandleActionPreviousEvent();
1001 case 6: // OneFingerFlickDown
1003 // Move to next item.
1004 accessibilityAdaptor->HandleActionNextEvent();
1007 case 7: // TwoFingersFlickUp
1009 // Scroll up the list.
1010 accessibilityAdaptor->HandleActionScrollUpEvent();
1013 case 8: // TwoFingersFlickDown
1015 // Scroll down the list.
1016 accessibilityAdaptor->HandleActionScrollDownEvent();
1019 case 9: // TwoFingersFlickLeft
1021 // Scroll left to the previous page
1022 accessibilityAdaptor->HandleActionPageLeftEvent();
1025 case 10: // TwoFingersFlickRight
1027 // Scroll right to the next page
1028 accessibilityAdaptor->HandleActionPageRightEvent();
1031 case 11: // ThreeFingersFlickLeft
1036 case 12: // ThreeFingersFlickRight
1041 case 13: // ThreeFingersFlickUp
1046 case 14: // ThreeFingersFlickDown
1051 case 15: // OneFingerSingleTap
1054 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
1057 case 16: // OneFingerDoubleTap
1059 // Activate selected item / active edit mode.
1060 accessibilityAdaptor->HandleActionActivateEvent();
1063 case 17: // OneFingerTripleTap
1066 accessibilityAdaptor->HandleActionZoomEvent();
1069 case 18: // TwoFingersSingleTap
1071 // Pause/Resume current speech
1072 accessibilityAdaptor->HandleActionReadPauseResumeEvent();
1075 case 19: // TwoFingersDoubleTap
1077 // Start/Stop current action
1078 accessibilityAdaptor->HandleActionStartStopEvent();
1081 case 20: // TwoFingersTripleTap
1083 // Read information from indicator
1084 accessibilityAdaptor->HandleActionReadIndicatorInformationEvent();
1087 case 21: // ThreeFingersSingleTap
1089 // Read from top item on screen continuously.
1090 accessibilityAdaptor->HandleActionReadFromTopEvent();
1093 case 22: // ThreeFingersDoubleTap
1095 // Read from next item continuously.
1096 accessibilityAdaptor->HandleActionReadFromNextEvent();
1099 case 23: // ThreeFingersTripleTap
1104 case 24: // OneFingerFlickLeftReturn
1106 // Scroll up to the previous page
1107 accessibilityAdaptor->HandleActionPageUpEvent();
1110 case 25: // OneFingerFlickRightReturn
1112 // Scroll down to the next page
1113 accessibilityAdaptor->HandleActionPageDownEvent();
1116 case 26: // OneFingerFlickUpReturn
1118 // Move to the first item on screen
1119 accessibilityAdaptor->HandleActionMoveToFirstEvent();
1122 case 27: // OneFingerFlickDownReturn
1124 // Move to the last item on screen
1125 accessibilityAdaptor->HandleActionMoveToLastEvent();
1128 case 28: // TwoFingersFlickLeftReturn
1133 case 29: // TwoFingersFlickRightReturn
1138 case 30: // TwoFingersFlickUpReturn
1143 case 31: // TwoFingersFlickDownReturn
1148 case 32: // ThreeFingersFlickLeftReturn
1153 case 33: // ThreeFingersFlickRightReturn
1158 case 34: // ThreeFingersFlickUpReturn
1163 case 35: // ThreeFingersFlickDownReturn
1171 void EcoreElDBusInitialisation( void *handle )
1173 Eldbus_Object *object;
1174 Eldbus_Proxy *manager;
1176 if( !( mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM) ) )
1178 DALI_LOG_ERROR( "Unable to get system bus\n" );
1181 object = eldbus_object_get( mSystemConnection, BUS, PATH );
1184 DALI_LOG_ERROR( "Getting object failed\n" );
1188 manager = eldbus_proxy_get( object, INTERFACE );
1191 DALI_LOG_ERROR( "Getting proxy failed\n" );
1195 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", OnEcoreElDBusAccessibilityNotification, handle ) )
1197 DALI_LOG_ERROR( "No signal handler returned\n" );
1200 #endif // DALI_ELDBUS_AVAILABLE
1203 * Called when the source window notifies us the content in clipboard is selected.
1205 static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
1207 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
1208 return ECORE_CALLBACK_PASS_ON;
1212 * Called when the source window sends us about the selected content.
1213 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
1215 static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
1217 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
1218 return ECORE_CALLBACK_PASS_ON;
1222 * Called when the source window notifies us the content in clipboard is selected.
1224 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
1226 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataSend\n" );
1228 Dali::Clipboard clipboard = Clipboard::Get();
1231 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1232 clipBoardImpl.ExcuteBuffered( true, event );
1234 return ECORE_CALLBACK_PASS_ON;
1238 * Called when the source window sends us about the selected content.
1239 * For example, when item is selected in the clipboard.
1241 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
1243 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataReceive\n" );
1245 EventHandler* handler( (EventHandler*)data );
1246 Dali::Clipboard clipboard = Clipboard::Get();
1247 char *selectionData = NULL;
1250 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1251 selectionData = clipBoardImpl.ExcuteBuffered( false, event );
1253 if ( selectionData && handler->mClipboardEventNotifier )
1255 ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
1256 std::string content( selectionData, strlen(selectionData) );
1258 clipboardEventNotifier.SetContent( content );
1259 clipboardEventNotifier.EmitContentSelectedSignal();
1261 return ECORE_CALLBACK_PASS_ON;
1265 * Called when rotate event is recevied
1267 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
1269 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::Concise, "EcoreEventRotate\n" );
1271 EventHandler* handler( (EventHandler*)data );
1272 Ecore_Wl_Event_Window_Rotate* ev( (Ecore_Wl_Event_Window_Rotate*)event );
1274 if( ev->win != (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
1276 return ECORE_CALLBACK_PASS_ON;
1279 RotationEvent rotationEvent;
1280 rotationEvent.angle = ev->angle;
1281 rotationEvent.winResize = 0;
1283 if( ev->angle == 0 || ev->angle == 180 )
1285 rotationEvent.width = ev->w;
1286 rotationEvent.height = ev->h;
1290 rotationEvent.width = ev->h;
1291 rotationEvent.height = ev->w;
1294 handler->SendRotationPrepareEvent( rotationEvent );
1296 return ECORE_CALLBACK_PASS_ON;
1300 * Called when detent event is recevied
1302 static Eina_Bool EcoreEventDetent( void* data, int type, void* event )
1304 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDetent\n" );
1305 EventHandler* handler( (EventHandler*)data );
1306 Ecore_Event_Detent_Rotate *e((Ecore_Event_Detent_Rotate *)event);
1307 int direction = (e->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1308 int timeStamp = e->timestamp;
1310 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp );
1311 handler->SendWheelEvent( wheelEvent );
1312 return ECORE_CALLBACK_PASS_ON;
1315 /////////////////////////////////////////////////////////////////////////////////////////////////
1317 /////////////////////////////////////////////////////////////////////////////////////////////////
1319 * Called when a font name is changed.
1321 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
1323 EventHandler* handler = static_cast<EventHandler*>( data );
1324 handler->SendEvent( StyleChange::DEFAULT_FONT_CHANGE );
1328 * Called when a font size is changed.
1330 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
1332 EventHandler* handler = static_cast<EventHandler*>( data );
1333 handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1336 void ConvertTouchPosition( Integration::Point& point )
1338 Vector2 position = point.GetScreenPosition();
1339 Vector2 convertedPosition;
1341 switch( mRotationAngle )
1345 convertedPosition.x = mWindowWidth - position.y;
1346 convertedPosition.y = position.x;
1351 convertedPosition.x = mWindowWidth - position.x;
1352 convertedPosition.y = mWindowHeight - position.y;
1357 convertedPosition.x = position.y;
1358 convertedPosition.y = mWindowHeight - position.x;
1363 convertedPosition = position;
1368 point.SetScreenPosition( convertedPosition );
1372 EventHandler* mHandler;
1373 std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
1374 Ecore_Wl_Window* mWindow;
1378 #ifdef DALI_ELDBUS_AVAILABLE
1379 Eldbus_Connection* mSystemConnection;
1380 #endif // DALI_ELDBUS_AVAILABLE
1383 EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
1384 : mCoreEventInterface( coreEventInterface ),
1385 mGestureManager( gestureManager ),
1386 mStyleMonitor( StyleMonitor::Get() ),
1387 mDamageObserver( damageObserver ),
1388 mRotationObserver( NULL ),
1389 mDragAndDropDetector( dndDetector ),
1390 mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
1391 mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
1392 mClipboard( Clipboard::Get() ),
1396 Ecore_Wl_Window* window = 0;
1398 // this code only works with the Ecore RenderSurface so need to downcast
1399 ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
1402 window = ecoreSurface->GetWlWindow();
1405 mImpl = new Impl(this, window);
1408 EventHandler::~EventHandler()
1415 mGestureManager.Stop();
1418 void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
1422 timeStamp = GetCurrentMilliSeconds();
1425 mImpl->ConvertTouchPosition( point );
1427 Integration::TouchEvent touchEvent;
1428 Integration::HoverEvent hoverEvent;
1429 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
1430 if(type != Integration::TouchEventCombiner::DispatchNone )
1432 DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y);
1434 // First the touch and/or hover event & related gesture events are queued
1435 if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
1437 mCoreEventInterface.QueueCoreEvent( touchEvent );
1438 mGestureManager.SendEvent(touchEvent);
1441 if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
1443 mCoreEventInterface.QueueCoreEvent( hoverEvent );
1446 // Next the events are processed with a single call into Core
1447 mCoreEventInterface.ProcessCoreEvents();
1451 void EventHandler::SendEvent(Integration::KeyEvent& keyEvent)
1453 Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
1454 if ( physicalKeyboard )
1456 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
1458 GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
1462 // Create send KeyEvent to Core.
1463 mCoreEventInterface.QueueCoreEvent( keyEvent );
1464 mCoreEventInterface.ProcessCoreEvents();
1467 void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
1469 // Create WheelEvent and send to Core.
1470 Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
1471 mCoreEventInterface.QueueCoreEvent( event );
1472 mCoreEventInterface.ProcessCoreEvents();
1475 void EventHandler::SendEvent( StyleChange::Type styleChange )
1477 DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
1478 GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
1481 void EventHandler::SendEvent( const DamageArea& area )
1483 mDamageObserver.OnDamaged( area );
1486 void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
1488 if( mRotationObserver != NULL )
1490 mImpl->mRotationAngle = event.angle;
1491 mImpl->mWindowWidth = event.width;
1492 mImpl->mWindowHeight = event.height;
1494 mRotationObserver->OnRotationPrepare( event );
1495 mRotationObserver->OnRotationRequest();
1499 void EventHandler::SendRotationRequestEvent( )
1501 // No need to separate event into prepare and request in wayland
1504 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
1506 Integration::Point convertedPoint( point );
1507 SendEvent(convertedPoint, timeStamp);
1510 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
1512 SendWheelEvent( wheelEvent );
1515 void EventHandler::FeedKeyEvent( KeyEvent& event )
1517 Integration::KeyEvent convertedEvent( event );
1518 SendEvent( convertedEvent );
1521 void EventHandler::FeedEvent( Integration::Event& event )
1523 mCoreEventInterface.QueueCoreEvent( event );
1524 mCoreEventInterface.ProcessCoreEvents();
1527 void EventHandler::Reset()
1531 // Any touch listeners should be told of the interruption.
1532 Integration::TouchEvent event;
1533 Integration::Point point;
1534 point.SetState( PointState::INTERRUPTED );
1535 event.AddPoint( point );
1537 // First the touch event & related gesture events are queued
1538 mCoreEventInterface.QueueCoreEvent( event );
1539 mGestureManager.SendEvent( event );
1541 // Next the events are processed with a single call into Core
1542 mCoreEventInterface.ProcessCoreEvents();
1545 void EventHandler::Pause()
1551 void EventHandler::Resume()
1557 void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
1559 mDragAndDropDetector = detector;
1562 void EventHandler::SetRotationObserver( RotationObserver* observer )
1564 mRotationObserver = observer;
1567 } // namespace Adaptor
1569 } // namespace Internal
1573 #pragma GCC diagnostic pop