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 <dali/internal/window-system/common/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_IMF.h>
28 #include <dali/integration-api/wayland/ecore-wl-render-surface.h>
29 //#include <dali/window-system/tizen-wayland/window-render-surface-ecore-wl.h>
34 #ifndef DALI_PROFILE_UBUNTU
36 #include <vconf-keys.h>
37 #endif // DALI_PROFILE_UBUNTU
39 #ifdef DALI_ELDBUS_AVAILABLE
41 #endif // DALI_ELDBUS_AVAILABLE
43 #include <dali/public-api/common/vector-wrapper.h>
44 #include <dali/public-api/events/device.h>
45 #include <dali/public-api/events/touch-point.h>
46 #include <dali/public-api/events/key-event.h>
47 #include <dali/public-api/events/wheel-event.h>
48 #include <dali/integration-api/debug.h>
49 #include <dali/integration-api/events/key-event-integ.h>
50 #include <dali/integration-api/events/touch-event-integ.h>
51 #include <dali/integration-api/events/hover-event-integ.h>
52 #include <dali/integration-api/events/wheel-event-integ.h>
55 #include <dali/internal/input/common/gesture-manager.h>
56 #include <dali/internal/window-system/tizen-wayland/window-render-surface-ecore-wl.h>
57 #include <dali/internal/clipboard/common/clipboard-impl.h>
58 #include <dali/internal/input/common/key-impl.h>
59 #include <dali/internal/input/common/physical-keyboard-impl.h>
60 #include <dali/internal/styling/common/style-monitor-impl.h>
61 #include <dali/internal/system/common/core-event-interface.h>
62 #include <dali/devel-api/adaptor-framework/virtual-keyboard.h>
73 #if defined(DEBUG_ENABLED)
76 Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
77 Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
78 Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
79 Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
80 } // unnamed namespace
88 const char* BUS = "org.enlightenment.wm-screen-reader";
89 const char* INTERFACE = "org.tizen.GestureNavigation";
90 const char* PATH = "/org/tizen/GestureNavigation";
92 const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
94 const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
97 * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
98 * @param[in] modifier the Ecore_Event_Modifier input.
99 * @return the Ecore_IMF_Keyboard_Locks output.
101 Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier )
103 unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE.
105 if( modifier & ECORE_EVENT_LOCK_NUM )
107 lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
110 if( modifier & ECORE_EVENT_LOCK_CAPS )
112 lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
115 if( modifier & ECORE_EVENT_LOCK_SCROLL )
117 lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
120 return static_cast<Ecore_IMF_Keyboard_Locks>( lock );
124 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
125 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
126 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
127 * @return the Ecore_IMF_Keyboard_Modifiers output.
129 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
131 unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
134 if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
136 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
139 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
141 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
144 if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
146 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
149 if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
151 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
154 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
156 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
159 return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
163 // Copied from x server
164 static unsigned int GetCurrentMilliSeconds(void)
169 static clockid_t clockid;
173 #ifdef CLOCK_MONOTONIC_COARSE
174 if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
175 (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
177 clockid = CLOCK_MONOTONIC_COARSE;
181 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
183 clockid = CLOCK_MONOTONIC;
190 if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
192 return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
195 gettimeofday(&tv, NULL);
196 return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
199 #ifndef DALI_PROFILE_UBUNTU
200 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
201 #endif // DALI_PROFILE_UBUNTU
204 * Get the device name from the provided ecore key event
206 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
208 const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
210 if ( ecoreDeviceName )
212 result = ecoreDeviceName;
217 * Get the device class from the provided ecore event
219 void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
221 switch( ecoreDeviceClass )
223 case ECORE_DEVICE_CLASS_SEAT:
225 deviceClass = Device::Class::USER;
228 case ECORE_DEVICE_CLASS_KEYBOARD:
230 deviceClass = Device::Class::KEYBOARD;
233 case ECORE_DEVICE_CLASS_MOUSE:
235 deviceClass = Device::Class::MOUSE;
238 case ECORE_DEVICE_CLASS_TOUCH:
240 deviceClass = Device::Class::TOUCH;
243 case ECORE_DEVICE_CLASS_PEN:
245 deviceClass = Device::Class::PEN;
248 case ECORE_DEVICE_CLASS_POINTER:
250 deviceClass = Device::Class::POINTER;
253 case ECORE_DEVICE_CLASS_GAMEPAD:
255 deviceClass = Device::Class::GAMEPAD;
260 deviceClass = Device::Class::NONE;
266 void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
268 switch( ecoreDeviceSubclass )
270 case ECORE_DEVICE_SUBCLASS_FINGER:
272 deviceSubclass = Device::Subclass::FINGER;
275 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
277 deviceSubclass = Device::Subclass::FINGERNAIL;
280 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
282 deviceSubclass = Device::Subclass::KNUCKLE;
285 case ECORE_DEVICE_SUBCLASS_PALM:
287 deviceSubclass = Device::Subclass::PALM;
290 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
292 deviceSubclass = Device::Subclass::HAND_SIDE;
295 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
297 deviceSubclass = Device::Subclass::HAND_FLAT;
300 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
302 deviceSubclass = Device::Subclass::PEN_TIP;
305 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
307 deviceSubclass = Device::Subclass::TRACKPAD;
310 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
312 deviceSubclass = Device::Subclass::TRACKPOINT;
315 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
317 deviceSubclass = Device::Subclass::TRACKBALL;
320 #ifdef OVER_TIZEN_VERSION_4
321 case ECORE_DEVICE_SUBCLASS_REMOCON:
323 deviceSubclass = Device::Subclass::REMOCON;
326 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
328 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
334 deviceSubclass = Device::Subclass::NONE;
340 } // unnamed namespace
342 // Impl to hide EFL implementation.
343 struct EventHandler::Impl
345 // Construction & Destruction
350 Impl( EventHandler* handler, Ecore_Wl_Window* window )
351 : mHandler( handler ),
352 mEcoreEventHandler(),
357 #ifdef DALI_ELDBUS_AVAILABLE
358 , mSystemConnection( NULL )
359 #endif // DALI_ELDBUS_AVAILABLE
361 // Only register for touch and key events if we have a window
364 // Register Touch events
365 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
366 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
367 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
368 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, handler ) );
370 // Register Mouse wheel events
371 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
373 // Register Focus events
374 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
375 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
377 // Register Key events
378 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
379 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
381 // Register Selection event - clipboard selection
382 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, handler ) );
383 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, handler ) );
385 // Register Rotate event
386 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, handler) );
388 // Register Detent event
389 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetent, handler) );
391 #ifndef DALI_PROFILE_UBUNTU
392 // Register Vconf notify - font name and size
393 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged, handler );
394 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
395 #endif // DALI_PROFILE_UBUNTU
397 #ifdef DALI_ELDBUS_AVAILABLE
398 // Initialize ElDBus.
399 DALI_LOG_INFO( gImfLogging, Debug::General, "Starting DBus Initialization\n" );
402 EcoreElDBusInitialisation( handler );
404 DALI_LOG_INFO( gImfLogging, Debug::General, "Finished DBus Initialization\n" );
405 #endif // DALI_ELDBUS_AVAILABLE
414 #ifndef DALI_PROFILE_UBUNTU
415 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
416 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged );
417 #endif // DALI_PROFILE_UBUNTU
419 for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
421 ecore_event_handler_del( *iter );
424 #ifdef DALI_ELDBUS_AVAILABLE
425 // Close down ElDBus connections.
426 if( mSystemConnection )
428 eldbus_connection_unref( mSystemConnection );
430 #endif // DALI_ELDBUS_AVAILABLE
435 /////////////////////////////////////////////////////////////////////////////////////////////////
437 /////////////////////////////////////////////////////////////////////////////////////////////////
440 * Called when a touch down is received.
442 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
444 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
445 EventHandler* handler( (EventHandler*)data );
447 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
449 PointState::Type state ( PointState::DOWN );
451 // Check if the buttons field is set and ensure it's the primary touch button.
452 // If this event was triggered by buttons other than the primary button (used for touch), then
453 // just send an interrupted event to Core.
454 if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
456 state = PointState::INTERRUPTED;
459 Device::Class::Type deviceClass;
460 Device::Subclass::Type deviceSubclass;
462 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
463 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
465 Integration::Point point;
466 point.SetDeviceId( touchEvent->multi.device );
467 point.SetState( state );
468 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
469 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
470 point.SetPressure( touchEvent->multi.pressure );
471 point.SetAngle( Degree( touchEvent->multi.angle ) );
472 point.SetDeviceClass( deviceClass );
473 point.SetDeviceSubclass( deviceSubclass );
475 handler->SendEvent( point, touchEvent->timestamp );
478 return ECORE_CALLBACK_PASS_ON;
482 * Called when a touch up is received.
484 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
486 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
487 EventHandler* handler( (EventHandler*)data );
489 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
491 Device::Class::Type deviceClass;
492 Device::Subclass::Type deviceSubclass;
494 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
495 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
497 Integration::Point point;
498 point.SetDeviceId( touchEvent->multi.device );
499 point.SetState( PointState::UP );
500 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
501 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
502 point.SetPressure( touchEvent->multi.pressure );
503 point.SetAngle( Degree( touchEvent->multi.angle ) );
504 point.SetDeviceClass( deviceClass );
505 point.SetDeviceSubclass( deviceSubclass );
507 handler->SendEvent( point, touchEvent->timestamp );
510 return ECORE_CALLBACK_PASS_ON;
514 * Called when a touch motion is received.
516 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
518 Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
519 EventHandler* handler( (EventHandler*)data );
521 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
523 Device::Class::Type deviceClass;
524 Device::Subclass::Type deviceSubclass;
526 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
527 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
529 Integration::Point point;
530 point.SetDeviceId( touchEvent->multi.device );
531 point.SetState( PointState::MOTION );
532 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
533 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
534 point.SetPressure( touchEvent->multi.pressure );
535 point.SetAngle( Degree( touchEvent->multi.angle ) );
536 point.SetDeviceClass( deviceClass );
537 point.SetDeviceSubclass( deviceSubclass );
539 handler->SendEvent( point, touchEvent->timestamp );
542 return ECORE_CALLBACK_PASS_ON;
546 * Called when a touch is canceled.
548 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
550 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
551 EventHandler* handler( (EventHandler*)data );
553 if( touchEvent->window == (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
555 Integration::Point point;
556 point.SetDeviceId( touchEvent->multi.device );
557 point.SetState( PointState::INTERRUPTED );
558 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
559 handler->SendEvent( point, touchEvent->timestamp );
561 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventMouseButtonCancel\n" );
564 return ECORE_CALLBACK_PASS_ON;
568 * Called when a mouse wheel is received.
570 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
572 Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
574 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);
576 EventHandler* handler( (EventHandler*)data );
577 if ( mouseWheelEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
579 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp );
580 handler->SendWheelEvent( wheelEvent );
582 return ECORE_CALLBACK_PASS_ON;
585 /////////////////////////////////////////////////////////////////////////////////////////////////
587 /////////////////////////////////////////////////////////////////////////////////////////////////
590 * Called when a key down is received.
592 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
594 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
596 EventHandler* handler( (EventHandler*)data );
597 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
598 bool eventHandled( false );
600 // If a device key then skip ecore_imf_context_filter_event.
601 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
603 Ecore_IMF_Context* imfContext = NULL;
604 Dali::ImfManager imfManager( ImfManager::Get() );
607 imfContext = reinterpret_cast<Ecore_IMF_Context*>(ImfManager::GetImplementation( imfManager ).GetContext());
612 // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
613 Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
614 ecoreKeyDownEvent.keyname = keyEvent->keyname;
615 ecoreKeyDownEvent.key = keyEvent->key;
616 ecoreKeyDownEvent.string = keyEvent->string;
617 ecoreKeyDownEvent.compose = keyEvent->compose;
618 ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
619 ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
620 ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent->modifiers );
621 ecoreKeyDownEvent.dev_name = ecore_device_name_get( keyEvent->dev );
622 ecoreKeyDownEvent.dev_class = static_cast<Ecore_IMF_Device_Class>( ecore_device_class_get( keyEvent->dev ) );
623 ecoreKeyDownEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass>( ecore_device_subclass_get( keyEvent->dev ) );
625 std::string checkDevice;
626 GetDeviceName( keyEvent, checkDevice );
628 // 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.
629 if( ( checkDevice == "ime" ) && ( ( !strncmp( keyEvent->keyname, "Left", 4 ) ) ||
630 ( !strncmp( keyEvent->keyname, "Right", 5 ) ) ||
631 ( !strncmp( keyEvent->keyname, "Up", 2 ) ) ||
632 ( !strncmp( keyEvent->keyname, "Down", 4 ) ) ) )
638 eventHandled = ecore_imf_context_filter_event( imfContext,
639 ECORE_IMF_EVENT_KEY_DOWN,
640 (Ecore_IMF_Event *) &ecoreKeyDownEvent );
643 // If the event has not been handled by IMF then check if we should reset our IMF context
646 if ( !strcmp( keyEvent->keyname, "Escape" ) ||
647 !strcmp( keyEvent->keyname, "Return" ) ||
648 !strcmp( keyEvent->keyname, "KP_Enter" ) )
650 ecore_imf_context_reset( imfContext );
656 // If the event wasn't handled then we should send a key event.
659 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
661 std::string keyName( keyEvent->keyname );
662 std::string keyString( "" );
663 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
664 keyCode = (keyCode == -1) ? 0 : keyCode;
665 int modifier( keyEvent->modifiers );
666 unsigned long time = keyEvent->timestamp;
667 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
668 keyCode = atoi(keyEvent->keyname + 8);
670 // Ensure key event string is not NULL as keys like SHIFT have a null string.
671 if ( keyEvent->string )
673 keyString = keyEvent->string;
676 std::string deviceName;
677 Device::Class::Type deviceClass;
678 Device::Subclass::Type deviceSubclass;
680 GetDeviceName( keyEvent, deviceName );
681 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
682 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
684 DALI_LOG_INFO( gImfLogging, Debug::Verbose, "EVENT EcoreEventKeyDown - >>EcoreEventKeyDown deviceName(%s) deviceClass(%d)\n", deviceName.c_str(), deviceClass );
686 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, deviceName, deviceClass, deviceSubclass );
687 handler->SendEvent( keyEvent );
691 return ECORE_CALLBACK_PASS_ON;
695 * Called when a key up is received.
697 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
699 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp\n" );
701 EventHandler* handler( (EventHandler*)data );
702 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
703 bool eventHandled( false );
705 // Device keys like Menu, home, back button must skip ecore_imf_context_filter_event.
706 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
708 Ecore_IMF_Context* imfContext = NULL;
709 Dali::ImfManager imfManager( ImfManager::Get() );
712 imfContext = reinterpret_cast<Ecore_IMF_Context*>(ImfManager::GetImplementation( imfManager ).GetContext());
717 // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
718 Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
719 ecoreKeyUpEvent.keyname = keyEvent->keyname;
720 ecoreKeyUpEvent.key = keyEvent->key;
721 ecoreKeyUpEvent.string = keyEvent->string;
722 ecoreKeyUpEvent.compose = keyEvent->compose;
723 ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
724 ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
725 ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent->modifiers );
726 ecoreKeyUpEvent.dev_name = ecore_device_name_get( keyEvent->dev );
727 ecoreKeyUpEvent.dev_class = static_cast<Ecore_IMF_Device_Class>( ecore_device_class_get( keyEvent->dev ) );
728 ecoreKeyUpEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass>( ecore_device_subclass_get( keyEvent->dev ) );
730 eventHandled = ecore_imf_context_filter_event( imfContext,
731 ECORE_IMF_EVENT_KEY_UP,
732 (Ecore_IMF_Event *) &ecoreKeyUpEvent );
736 // If the event wasn't handled then we should send a key event.
739 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
741 std::string keyName( keyEvent->keyname );
742 std::string keyString( "" );
743 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
744 keyCode = (keyCode == -1) ? 0 : keyCode;
745 int modifier( keyEvent->modifiers );
746 unsigned long time = keyEvent->timestamp;
747 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
748 keyCode = atoi(keyEvent->keyname + 8);
750 // Ensure key event string is not NULL as keys like SHIFT have a null string.
751 if ( keyEvent->string )
753 keyString = keyEvent->string;
756 std::string deviceName;
757 Device::Class::Type deviceClass;
758 Device::Subclass::Type deviceSubclass;
760 GetDeviceName( keyEvent, deviceName );
761 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
762 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
764 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, deviceName, deviceClass, deviceSubclass );
765 handler->SendEvent( keyEvent );
769 return ECORE_CALLBACK_PASS_ON;
772 /////////////////////////////////////////////////////////////////////////////////////////////////
774 /////////////////////////////////////////////////////////////////////////////////////////////////
777 * Called when the window gains focus.
779 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
781 Ecore_Wl_Event_Focus_In* focusInEvent( (Ecore_Wl_Event_Focus_In*)event );
782 EventHandler* handler( (EventHandler*)data );
784 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
786 // If the window gains focus and we hid the keyboard then show it again.
787 if ( focusInEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
789 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
791 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
793 Dali::ImfManager imfManager( ImfManager::Get() );
796 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
797 if( imfManagerImpl.RestoreAfterFocusLost() )
799 imfManagerImpl.Activate();
803 Dali::Clipboard clipboard = Clipboard::Get();
804 clipboard.HideClipboard();
807 return ECORE_CALLBACK_PASS_ON;
811 * Called when the window loses focus.
813 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
815 Ecore_Wl_Event_Focus_Out* focusOutEvent( (Ecore_Wl_Event_Focus_Out*)event );
816 EventHandler* handler( (EventHandler*)data );
818 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
820 // If the window loses focus then hide the keyboard.
821 if ( focusOutEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
823 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
825 Dali::ImfManager imfManager( ImfManager::Get() );
828 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
829 if( imfManagerImpl.RestoreAfterFocusLost() )
831 imfManagerImpl.Deactivate();
836 // Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard
837 Dali::Clipboard clipboard = Clipboard::Get();
840 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
841 clipBoardImpl.HideClipboard(true);
845 return ECORE_CALLBACK_PASS_ON;
849 * Called when the window is damaged.
851 static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
853 return ECORE_CALLBACK_PASS_ON;
857 * Called when the window properties are changed.
858 * We are only interested in the font change.
862 /////////////////////////////////////////////////////////////////////////////////////////////////
863 // Drag & Drop Callbacks
864 /////////////////////////////////////////////////////////////////////////////////////////////////
867 * Called when a dragged item enters our window's bounds.
868 * This is when items are dragged INTO our window.
870 static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
872 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
874 return ECORE_CALLBACK_PASS_ON;
878 * Called when a dragged item is moved within our window.
879 * This is when items are dragged INTO our window.
881 static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
883 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
885 return ECORE_CALLBACK_PASS_ON;
889 * Called when a dragged item leaves our window's bounds.
890 * This is when items are dragged INTO our window.
892 static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
894 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
896 return ECORE_CALLBACK_PASS_ON;
900 * Called when the dragged item is dropped within our window's bounds.
901 * This is when items are dragged INTO our window.
903 static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
905 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
907 return ECORE_CALLBACK_PASS_ON;
911 * Called when a dragged item is moved from our window and the target window has done processing it.
912 * This is when items are dragged FROM our window.
914 static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
916 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
917 return ECORE_CALLBACK_PASS_ON;
921 * Called when a dragged item is moved from our window and the target window has sent us a status.
922 * This is when items are dragged FROM our window.
924 static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
926 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
927 return ECORE_CALLBACK_PASS_ON;
931 * Called when the client messages (i.e. the accessibility events) are received.
933 static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
935 return ECORE_CALLBACK_PASS_ON;
939 /////////////////////////////////////////////////////////////////////////////////////////////////
940 // ElDBus Accessibility Callbacks
941 /////////////////////////////////////////////////////////////////////////////////////////////////
943 #ifdef DALI_ELDBUS_AVAILABLE
944 // Callback for Ecore ElDBus accessibility events.
945 static void OnEcoreElDBusAccessibilityNotification( void *context EINA_UNUSED, const Eldbus_Message *message )
947 EventHandler* handler = static_cast< EventHandler* >( context );
948 // Ignore any accessibility events when paused.
949 if( handler->mPaused )
954 if( !handler->mAccessibilityAdaptor )
956 DALI_LOG_ERROR( "Invalid accessibility adaptor\n" );
960 AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( handler->mAccessibilityAdaptor ) );
961 if( !accessibilityAdaptor )
963 DALI_LOG_ERROR( "Cannot access accessibility adaptor\n" );
969 int state; // 0 - begin, 1 - ongoing, 2 - ended, 3 - aborted
972 // The string defines the arg-list's respective types.
973 if( !eldbus_message_arguments_get( message, "iiiiiiu", &gestureValue, &xS, &yS, &xE, &yE, &state, &eventTime ) )
975 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
978 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Name: %d Args: %d,%d,%d,%d State: %d\n", gestureValue, xS, yS, xE, yE );
980 // Create a touch point object.
981 TouchPoint::State touchPointState( TouchPoint::Down );
984 touchPointState = TouchPoint::Down; // Mouse down.
986 else if( state == 1 )
988 touchPointState = TouchPoint::Motion; // Mouse move.
990 else if( state == 2 )
992 touchPointState = TouchPoint::Up; // Mouse up.
996 touchPointState = TouchPoint::Interrupted; // Error.
999 // Send touch event to accessibility adaptor.
1000 TouchPoint point( 0, touchPointState, (float)xS, (float)yS );
1002 // Perform actions based on received gestures.
1003 // Note: This is seperated from the reading so we can have other input readers without changing the below code.
1004 switch( gestureValue )
1006 case 0: // OneFingerHover
1009 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
1012 case 1: // TwoFingersHover
1014 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
1015 accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
1018 case 2: // ThreeFingersHover
1020 // Read from top item on screen continuously.
1021 accessibilityAdaptor->HandleActionReadFromTopEvent();
1024 case 3: // OneFingerFlickLeft
1026 // Move to previous item.
1027 accessibilityAdaptor->HandleActionReadPreviousEvent();
1030 case 4: // OneFingerFlickRight
1032 // Move to next item.
1033 accessibilityAdaptor->HandleActionReadNextEvent();
1036 case 5: // OneFingerFlickUp
1038 // Move to previous item.
1039 accessibilityAdaptor->HandleActionPreviousEvent();
1042 case 6: // OneFingerFlickDown
1044 // Move to next item.
1045 accessibilityAdaptor->HandleActionNextEvent();
1048 case 7: // TwoFingersFlickUp
1050 // Scroll up the list.
1051 accessibilityAdaptor->HandleActionScrollUpEvent();
1054 case 8: // TwoFingersFlickDown
1056 // Scroll down the list.
1057 accessibilityAdaptor->HandleActionScrollDownEvent();
1060 case 9: // TwoFingersFlickLeft
1062 // Scroll left to the previous page
1063 accessibilityAdaptor->HandleActionPageLeftEvent();
1066 case 10: // TwoFingersFlickRight
1068 // Scroll right to the next page
1069 accessibilityAdaptor->HandleActionPageRightEvent();
1072 case 11: // ThreeFingersFlickLeft
1077 case 12: // ThreeFingersFlickRight
1082 case 13: // ThreeFingersFlickUp
1087 case 14: // ThreeFingersFlickDown
1092 case 15: // OneFingerSingleTap
1095 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
1098 case 16: // OneFingerDoubleTap
1100 // Activate selected item / active edit mode.
1101 accessibilityAdaptor->HandleActionActivateEvent();
1104 case 17: // OneFingerTripleTap
1107 accessibilityAdaptor->HandleActionZoomEvent();
1110 case 18: // TwoFingersSingleTap
1112 // Pause/Resume current speech
1113 accessibilityAdaptor->HandleActionReadPauseResumeEvent();
1116 case 19: // TwoFingersDoubleTap
1118 // Start/Stop current action
1119 accessibilityAdaptor->HandleActionStartStopEvent();
1122 case 20: // TwoFingersTripleTap
1124 // Read information from indicator
1125 accessibilityAdaptor->HandleActionReadIndicatorInformationEvent();
1128 case 21: // ThreeFingersSingleTap
1130 // Read from top item on screen continuously.
1131 accessibilityAdaptor->HandleActionReadFromTopEvent();
1134 case 22: // ThreeFingersDoubleTap
1136 // Read from next item continuously.
1137 accessibilityAdaptor->HandleActionReadFromNextEvent();
1140 case 23: // ThreeFingersTripleTap
1145 case 24: // OneFingerFlickLeftReturn
1147 // Scroll up to the previous page
1148 accessibilityAdaptor->HandleActionPageUpEvent();
1151 case 25: // OneFingerFlickRightReturn
1153 // Scroll down to the next page
1154 accessibilityAdaptor->HandleActionPageDownEvent();
1157 case 26: // OneFingerFlickUpReturn
1159 // Move to the first item on screen
1160 accessibilityAdaptor->HandleActionMoveToFirstEvent();
1163 case 27: // OneFingerFlickDownReturn
1165 // Move to the last item on screen
1166 accessibilityAdaptor->HandleActionMoveToLastEvent();
1169 case 28: // TwoFingersFlickLeftReturn
1174 case 29: // TwoFingersFlickRightReturn
1179 case 30: // TwoFingersFlickUpReturn
1184 case 31: // TwoFingersFlickDownReturn
1189 case 32: // ThreeFingersFlickLeftReturn
1194 case 33: // ThreeFingersFlickRightReturn
1199 case 34: // ThreeFingersFlickUpReturn
1204 case 35: // ThreeFingersFlickDownReturn
1212 void EcoreElDBusInitialisation( void *handle )
1214 Eldbus_Object *object;
1215 Eldbus_Proxy *manager;
1217 if( !( mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM) ) )
1219 DALI_LOG_ERROR( "Unable to get system bus\n" );
1222 object = eldbus_object_get( mSystemConnection, BUS, PATH );
1225 DALI_LOG_ERROR( "Getting object failed\n" );
1229 manager = eldbus_proxy_get( object, INTERFACE );
1232 DALI_LOG_ERROR( "Getting proxy failed\n" );
1236 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", OnEcoreElDBusAccessibilityNotification, handle ) )
1238 DALI_LOG_ERROR( "No signal handler returned\n" );
1241 #endif // DALI_ELDBUS_AVAILABLE
1244 * Called when the source window notifies us the content in clipboard is selected.
1246 static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
1248 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
1249 return ECORE_CALLBACK_PASS_ON;
1253 * Called when the source window sends us about the selected content.
1254 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
1256 static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
1258 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
1259 return ECORE_CALLBACK_PASS_ON;
1263 * Called when the source window notifies us the content in clipboard is selected.
1265 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
1267 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataSend\n" );
1269 Dali::Clipboard clipboard = Clipboard::Get();
1272 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1273 clipBoardImpl.ExcuteBuffered( true, event );
1275 return ECORE_CALLBACK_PASS_ON;
1279 * Called when the source window sends us about the selected content.
1280 * For example, when item is selected in the clipboard.
1282 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
1284 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataReceive\n" );
1286 EventHandler* handler( (EventHandler*)data );
1287 Dali::Clipboard clipboard = Clipboard::Get();
1288 char *selectionData = NULL;
1291 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1292 selectionData = clipBoardImpl.ExcuteBuffered( false, event );
1294 if ( selectionData && handler->mClipboardEventNotifier )
1296 ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
1297 std::string content( selectionData, strlen(selectionData) );
1299 clipboardEventNotifier.SetContent( content );
1300 clipboardEventNotifier.EmitContentSelectedSignal();
1302 return ECORE_CALLBACK_PASS_ON;
1306 * Called when rotate event is recevied
1308 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
1310 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::Concise, "EcoreEventRotate\n" );
1312 EventHandler* handler( (EventHandler*)data );
1313 Ecore_Wl_Event_Window_Rotate* ev( (Ecore_Wl_Event_Window_Rotate*)event );
1315 if( ev->win != (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
1317 return ECORE_CALLBACK_PASS_ON;
1320 RotationEvent rotationEvent;
1321 rotationEvent.angle = ev->angle;
1322 rotationEvent.winResize = 0;
1324 if( ev->angle == 0 || ev->angle == 180 )
1326 rotationEvent.width = ev->w;
1327 rotationEvent.height = ev->h;
1331 rotationEvent.width = ev->h;
1332 rotationEvent.height = ev->w;
1335 handler->SendRotationPrepareEvent( rotationEvent );
1337 return ECORE_CALLBACK_PASS_ON;
1341 * Called when detent event is recevied
1343 static Eina_Bool EcoreEventDetent( void* data, int type, void* event )
1345 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDetent\n" );
1346 EventHandler* handler( (EventHandler*)data );
1347 Ecore_Event_Detent_Rotate *e((Ecore_Event_Detent_Rotate *)event);
1348 int direction = (e->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1349 int timeStamp = e->timestamp;
1351 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp );
1352 handler->SendWheelEvent( wheelEvent );
1353 return ECORE_CALLBACK_PASS_ON;
1356 /////////////////////////////////////////////////////////////////////////////////////////////////
1358 /////////////////////////////////////////////////////////////////////////////////////////////////
1360 * Called when a font name is changed.
1362 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
1364 EventHandler* handler = static_cast<EventHandler*>( data );
1365 handler->SendEvent( StyleChange::DEFAULT_FONT_CHANGE );
1369 * Called when a font size is changed.
1371 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
1373 EventHandler* handler = static_cast<EventHandler*>( data );
1374 handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1377 void ConvertTouchPosition( Integration::Point& point )
1379 Vector2 position = point.GetScreenPosition();
1380 Vector2 convertedPosition;
1382 switch( mRotationAngle )
1386 convertedPosition.x = mWindowWidth - position.y;
1387 convertedPosition.y = position.x;
1392 convertedPosition.x = mWindowWidth - position.x;
1393 convertedPosition.y = mWindowHeight - position.y;
1398 convertedPosition.x = position.y;
1399 convertedPosition.y = mWindowHeight - position.x;
1404 convertedPosition = position;
1409 point.SetScreenPosition( convertedPosition );
1413 EventHandler* mHandler;
1414 std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
1415 Ecore_Wl_Window* mWindow;
1419 #ifdef DALI_ELDBUS_AVAILABLE
1420 Eldbus_Connection* mSystemConnection;
1421 #endif // DALI_ELDBUS_AVAILABLE
1424 EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
1425 : mCoreEventInterface( coreEventInterface ),
1426 mGestureManager( gestureManager ),
1427 mStyleMonitor( StyleMonitor::Get() ),
1428 mDamageObserver( damageObserver ),
1429 mRotationObserver( NULL ),
1430 mDragAndDropDetector( dndDetector ),
1431 mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
1432 mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
1433 mClipboard( Clipboard::Get() ),
1437 Ecore_Wl_Window* window = 0;
1439 // this code only works with the Ecore RenderSurface so need to downcast
1440 ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
1443 window = ecoreSurface->GetWlWindow();
1446 mImpl = new Impl(this, window);
1449 EventHandler::~EventHandler()
1456 mGestureManager.Stop();
1459 void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
1463 timeStamp = GetCurrentMilliSeconds();
1466 mImpl->ConvertTouchPosition( point );
1468 Integration::TouchEvent touchEvent;
1469 Integration::HoverEvent hoverEvent;
1470 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
1471 if(type != Integration::TouchEventCombiner::DispatchNone )
1473 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);
1475 // First the touch and/or hover event & related gesture events are queued
1476 if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
1478 mCoreEventInterface.QueueCoreEvent( touchEvent );
1479 mGestureManager.SendEvent(touchEvent);
1482 if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
1484 mCoreEventInterface.QueueCoreEvent( hoverEvent );
1487 // Next the events are processed with a single call into Core
1488 mCoreEventInterface.ProcessCoreEvents();
1492 void EventHandler::SendEvent(Integration::KeyEvent& keyEvent)
1494 Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
1495 if ( physicalKeyboard )
1497 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
1499 GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
1503 // Create send KeyEvent to Core.
1504 mCoreEventInterface.QueueCoreEvent( keyEvent );
1505 mCoreEventInterface.ProcessCoreEvents();
1508 void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
1510 // Create WheelEvent and send to Core.
1511 Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
1512 mCoreEventInterface.QueueCoreEvent( event );
1513 mCoreEventInterface.ProcessCoreEvents();
1516 void EventHandler::SendEvent( StyleChange::Type styleChange )
1518 DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
1519 GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
1522 void EventHandler::SendEvent( const DamageArea& area )
1524 mDamageObserver.OnDamaged( area );
1527 void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
1529 if( mRotationObserver != NULL )
1531 mImpl->mRotationAngle = event.angle;
1532 mImpl->mWindowWidth = event.width;
1533 mImpl->mWindowHeight = event.height;
1535 mRotationObserver->OnRotationPrepare( event );
1536 mRotationObserver->OnRotationRequest();
1540 void EventHandler::SendRotationRequestEvent( )
1542 // No need to separate event into prepare and request in wayland
1545 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
1547 Integration::Point convertedPoint( point );
1548 SendEvent(convertedPoint, timeStamp);
1551 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
1553 SendWheelEvent( wheelEvent );
1556 void EventHandler::FeedKeyEvent( KeyEvent& event )
1558 Integration::KeyEvent convertedEvent( event );
1559 SendEvent( convertedEvent );
1562 void EventHandler::FeedEvent( Integration::Event& event )
1564 mCoreEventInterface.QueueCoreEvent( event );
1565 mCoreEventInterface.ProcessCoreEvents();
1568 void EventHandler::Reset()
1572 // Any touch listeners should be told of the interruption.
1573 Integration::TouchEvent event;
1574 Integration::Point point;
1575 point.SetState( PointState::INTERRUPTED );
1576 event.AddPoint( point );
1578 // First the touch event & related gesture events are queued
1579 mCoreEventInterface.QueueCoreEvent( event );
1580 mGestureManager.SendEvent( event );
1582 // Next the events are processed with a single call into Core
1583 mCoreEventInterface.ProcessCoreEvents();
1586 void EventHandler::Pause()
1592 void EventHandler::Resume()
1598 void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
1600 mDragAndDropDetector = detector;
1603 void EventHandler::SetRotationObserver( RotationObserver* observer )
1605 mRotationObserver = observer;
1608 } // namespace Adaptor
1610 } // namespace Internal
1614 #pragma GCC diagnostic pop