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" ) ||
649 !strcmp( keyEvent->keyname, "XF86Exit" ) )
651 ecore_imf_context_reset( imfContext );
657 // If the event wasn't handled then we should send a key event.
660 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
662 std::string keyName( keyEvent->keyname );
663 std::string keyString( "" );
664 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
665 keyCode = (keyCode == -1) ? 0 : keyCode;
666 int modifier( keyEvent->modifiers );
667 unsigned long time = keyEvent->timestamp;
668 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
669 keyCode = atoi(keyEvent->keyname + 8);
671 // Ensure key event string is not NULL as keys like SHIFT have a null string.
672 if ( keyEvent->string )
674 keyString = keyEvent->string;
677 std::string deviceName;
678 Device::Class::Type deviceClass;
679 Device::Subclass::Type deviceSubclass;
681 GetDeviceName( keyEvent, deviceName );
682 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
683 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
685 DALI_LOG_INFO( gImfLogging, Debug::Verbose, "EVENT EcoreEventKeyDown - >>EcoreEventKeyDown deviceName(%s) deviceClass(%d)\n", deviceName.c_str(), deviceClass );
687 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, deviceName, deviceClass, deviceSubclass );
688 handler->SendEvent( keyEvent );
692 return ECORE_CALLBACK_PASS_ON;
696 * Called when a key up is received.
698 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
700 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp\n" );
702 EventHandler* handler( (EventHandler*)data );
703 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
704 bool eventHandled( false );
706 // Device keys like Menu, home, back button must skip ecore_imf_context_filter_event.
707 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
709 Ecore_IMF_Context* imfContext = NULL;
710 Dali::ImfManager imfManager( ImfManager::Get() );
713 imfContext = reinterpret_cast<Ecore_IMF_Context*>(ImfManager::GetImplementation( imfManager ).GetContext());
718 // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
719 Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
720 ecoreKeyUpEvent.keyname = keyEvent->keyname;
721 ecoreKeyUpEvent.key = keyEvent->key;
722 ecoreKeyUpEvent.string = keyEvent->string;
723 ecoreKeyUpEvent.compose = keyEvent->compose;
724 ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
725 ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
726 ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent->modifiers );
727 ecoreKeyUpEvent.dev_name = ecore_device_name_get( keyEvent->dev );
728 ecoreKeyUpEvent.dev_class = static_cast<Ecore_IMF_Device_Class>( ecore_device_class_get( keyEvent->dev ) );
729 ecoreKeyUpEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass>( ecore_device_subclass_get( keyEvent->dev ) );
731 eventHandled = ecore_imf_context_filter_event( imfContext,
732 ECORE_IMF_EVENT_KEY_UP,
733 (Ecore_IMF_Event *) &ecoreKeyUpEvent );
737 // If the event wasn't handled then we should send a key event.
740 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
742 std::string keyName( keyEvent->keyname );
743 std::string keyString( "" );
744 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
745 keyCode = (keyCode == -1) ? 0 : keyCode;
746 int modifier( keyEvent->modifiers );
747 unsigned long time = keyEvent->timestamp;
748 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
749 keyCode = atoi(keyEvent->keyname + 8);
751 // Ensure key event string is not NULL as keys like SHIFT have a null string.
752 if ( keyEvent->string )
754 keyString = keyEvent->string;
757 std::string deviceName;
758 Device::Class::Type deviceClass;
759 Device::Subclass::Type deviceSubclass;
761 GetDeviceName( keyEvent, deviceName );
762 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
763 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
765 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, deviceName, deviceClass, deviceSubclass );
766 handler->SendEvent( keyEvent );
770 return ECORE_CALLBACK_PASS_ON;
773 /////////////////////////////////////////////////////////////////////////////////////////////////
775 /////////////////////////////////////////////////////////////////////////////////////////////////
778 * Called when the window gains focus.
780 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
782 Ecore_Wl_Event_Focus_In* focusInEvent( (Ecore_Wl_Event_Focus_In*)event );
783 EventHandler* handler( (EventHandler*)data );
785 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
787 // If the window gains focus and we hid the keyboard then show it again.
788 if ( focusInEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
790 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
792 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
794 Dali::ImfManager imfManager( ImfManager::Get() );
797 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
798 if( imfManagerImpl.RestoreAfterFocusLost() )
800 imfManagerImpl.Activate();
804 Dali::Clipboard clipboard = Clipboard::Get();
805 clipboard.HideClipboard();
808 return ECORE_CALLBACK_PASS_ON;
812 * Called when the window loses focus.
814 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
816 Ecore_Wl_Event_Focus_Out* focusOutEvent( (Ecore_Wl_Event_Focus_Out*)event );
817 EventHandler* handler( (EventHandler*)data );
819 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
821 // If the window loses focus then hide the keyboard.
822 if ( focusOutEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
824 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
826 Dali::ImfManager imfManager( ImfManager::Get() );
829 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
830 if( imfManagerImpl.RestoreAfterFocusLost() )
832 imfManagerImpl.Deactivate();
837 // Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard
838 Dali::Clipboard clipboard = Clipboard::Get();
841 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
842 clipBoardImpl.HideClipboard(true);
846 return ECORE_CALLBACK_PASS_ON;
850 * Called when the window is damaged.
852 static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
854 return ECORE_CALLBACK_PASS_ON;
858 * Called when the window properties are changed.
859 * We are only interested in the font change.
863 /////////////////////////////////////////////////////////////////////////////////////////////////
864 // Drag & Drop Callbacks
865 /////////////////////////////////////////////////////////////////////////////////////////////////
868 * Called when a dragged item enters our window's bounds.
869 * This is when items are dragged INTO our window.
871 static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
873 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
875 return ECORE_CALLBACK_PASS_ON;
879 * Called when a dragged item is moved within our window.
880 * This is when items are dragged INTO our window.
882 static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
884 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
886 return ECORE_CALLBACK_PASS_ON;
890 * Called when a dragged item leaves our window's bounds.
891 * This is when items are dragged INTO our window.
893 static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
895 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
897 return ECORE_CALLBACK_PASS_ON;
901 * Called when the dragged item is dropped within our window's bounds.
902 * This is when items are dragged INTO our window.
904 static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
906 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
908 return ECORE_CALLBACK_PASS_ON;
912 * Called when a dragged item is moved from our window and the target window has done processing it.
913 * This is when items are dragged FROM our window.
915 static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
917 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
918 return ECORE_CALLBACK_PASS_ON;
922 * Called when a dragged item is moved from our window and the target window has sent us a status.
923 * This is when items are dragged FROM our window.
925 static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
927 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
928 return ECORE_CALLBACK_PASS_ON;
932 * Called when the client messages (i.e. the accessibility events) are received.
934 static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
936 return ECORE_CALLBACK_PASS_ON;
940 /////////////////////////////////////////////////////////////////////////////////////////////////
941 // ElDBus Accessibility Callbacks
942 /////////////////////////////////////////////////////////////////////////////////////////////////
944 #ifdef DALI_ELDBUS_AVAILABLE
945 // Callback for Ecore ElDBus accessibility events.
946 static void OnEcoreElDBusAccessibilityNotification( void *context EINA_UNUSED, const Eldbus_Message *message )
948 EventHandler* handler = static_cast< EventHandler* >( context );
949 // Ignore any accessibility events when paused.
950 if( handler->mPaused )
955 if( !handler->mAccessibilityAdaptor )
957 DALI_LOG_ERROR( "Invalid accessibility adaptor\n" );
961 AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( handler->mAccessibilityAdaptor ) );
962 if( !accessibilityAdaptor )
964 DALI_LOG_ERROR( "Cannot access accessibility adaptor\n" );
970 int state; // 0 - begin, 1 - ongoing, 2 - ended, 3 - aborted
973 // The string defines the arg-list's respective types.
974 if( !eldbus_message_arguments_get( message, "iiiiiiu", &gestureValue, &xS, &yS, &xE, &yE, &state, &eventTime ) )
976 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
979 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Name: %d Args: %d,%d,%d,%d State: %d\n", gestureValue, xS, yS, xE, yE );
981 // Create a touch point object.
982 TouchPoint::State touchPointState( TouchPoint::Down );
985 touchPointState = TouchPoint::Down; // Mouse down.
987 else if( state == 1 )
989 touchPointState = TouchPoint::Motion; // Mouse move.
991 else if( state == 2 )
993 touchPointState = TouchPoint::Up; // Mouse up.
997 touchPointState = TouchPoint::Interrupted; // Error.
1000 // Send touch event to accessibility adaptor.
1001 TouchPoint point( 0, touchPointState, (float)xS, (float)yS );
1003 // Perform actions based on received gestures.
1004 // Note: This is seperated from the reading so we can have other input readers without changing the below code.
1005 switch( gestureValue )
1007 case 0: // OneFingerHover
1010 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
1013 case 1: // TwoFingersHover
1015 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
1016 accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
1019 case 2: // ThreeFingersHover
1021 // Read from top item on screen continuously.
1022 accessibilityAdaptor->HandleActionReadFromTopEvent();
1025 case 3: // OneFingerFlickLeft
1027 // Move to previous item.
1028 accessibilityAdaptor->HandleActionReadPreviousEvent();
1031 case 4: // OneFingerFlickRight
1033 // Move to next item.
1034 accessibilityAdaptor->HandleActionReadNextEvent();
1037 case 5: // OneFingerFlickUp
1039 // Move to previous item.
1040 accessibilityAdaptor->HandleActionPreviousEvent();
1043 case 6: // OneFingerFlickDown
1045 // Move to next item.
1046 accessibilityAdaptor->HandleActionNextEvent();
1049 case 7: // TwoFingersFlickUp
1051 // Scroll up the list.
1052 accessibilityAdaptor->HandleActionScrollUpEvent();
1055 case 8: // TwoFingersFlickDown
1057 // Scroll down the list.
1058 accessibilityAdaptor->HandleActionScrollDownEvent();
1061 case 9: // TwoFingersFlickLeft
1063 // Scroll left to the previous page
1064 accessibilityAdaptor->HandleActionPageLeftEvent();
1067 case 10: // TwoFingersFlickRight
1069 // Scroll right to the next page
1070 accessibilityAdaptor->HandleActionPageRightEvent();
1073 case 11: // ThreeFingersFlickLeft
1078 case 12: // ThreeFingersFlickRight
1083 case 13: // ThreeFingersFlickUp
1088 case 14: // ThreeFingersFlickDown
1093 case 15: // OneFingerSingleTap
1096 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
1099 case 16: // OneFingerDoubleTap
1101 // Activate selected item / active edit mode.
1102 accessibilityAdaptor->HandleActionActivateEvent();
1105 case 17: // OneFingerTripleTap
1108 accessibilityAdaptor->HandleActionZoomEvent();
1111 case 18: // TwoFingersSingleTap
1113 // Pause/Resume current speech
1114 accessibilityAdaptor->HandleActionReadPauseResumeEvent();
1117 case 19: // TwoFingersDoubleTap
1119 // Start/Stop current action
1120 accessibilityAdaptor->HandleActionStartStopEvent();
1123 case 20: // TwoFingersTripleTap
1125 // Read information from indicator
1126 accessibilityAdaptor->HandleActionReadIndicatorInformationEvent();
1129 case 21: // ThreeFingersSingleTap
1131 // Read from top item on screen continuously.
1132 accessibilityAdaptor->HandleActionReadFromTopEvent();
1135 case 22: // ThreeFingersDoubleTap
1137 // Read from next item continuously.
1138 accessibilityAdaptor->HandleActionReadFromNextEvent();
1141 case 23: // ThreeFingersTripleTap
1146 case 24: // OneFingerFlickLeftReturn
1148 // Scroll up to the previous page
1149 accessibilityAdaptor->HandleActionPageUpEvent();
1152 case 25: // OneFingerFlickRightReturn
1154 // Scroll down to the next page
1155 accessibilityAdaptor->HandleActionPageDownEvent();
1158 case 26: // OneFingerFlickUpReturn
1160 // Move to the first item on screen
1161 accessibilityAdaptor->HandleActionMoveToFirstEvent();
1164 case 27: // OneFingerFlickDownReturn
1166 // Move to the last item on screen
1167 accessibilityAdaptor->HandleActionMoveToLastEvent();
1170 case 28: // TwoFingersFlickLeftReturn
1175 case 29: // TwoFingersFlickRightReturn
1180 case 30: // TwoFingersFlickUpReturn
1185 case 31: // TwoFingersFlickDownReturn
1190 case 32: // ThreeFingersFlickLeftReturn
1195 case 33: // ThreeFingersFlickRightReturn
1200 case 34: // ThreeFingersFlickUpReturn
1205 case 35: // ThreeFingersFlickDownReturn
1213 void EcoreElDBusInitialisation( void *handle )
1215 Eldbus_Object *object;
1216 Eldbus_Proxy *manager;
1218 if( !( mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM) ) )
1220 DALI_LOG_ERROR( "Unable to get system bus\n" );
1223 object = eldbus_object_get( mSystemConnection, BUS, PATH );
1226 DALI_LOG_ERROR( "Getting object failed\n" );
1230 manager = eldbus_proxy_get( object, INTERFACE );
1233 DALI_LOG_ERROR( "Getting proxy failed\n" );
1237 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", OnEcoreElDBusAccessibilityNotification, handle ) )
1239 DALI_LOG_ERROR( "No signal handler returned\n" );
1242 #endif // DALI_ELDBUS_AVAILABLE
1245 * Called when the source window notifies us the content in clipboard is selected.
1247 static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
1249 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
1250 return ECORE_CALLBACK_PASS_ON;
1254 * Called when the source window sends us about the selected content.
1255 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
1257 static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
1259 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
1260 return ECORE_CALLBACK_PASS_ON;
1264 * Called when the source window notifies us the content in clipboard is selected.
1266 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
1268 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataSend\n" );
1270 Dali::Clipboard clipboard = Clipboard::Get();
1273 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1274 clipBoardImpl.ExcuteBuffered( true, event );
1276 return ECORE_CALLBACK_PASS_ON;
1280 * Called when the source window sends us about the selected content.
1281 * For example, when item is selected in the clipboard.
1283 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
1285 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataReceive\n" );
1287 EventHandler* handler( (EventHandler*)data );
1288 Dali::Clipboard clipboard = Clipboard::Get();
1289 char *selectionData = NULL;
1292 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1293 selectionData = clipBoardImpl.ExcuteBuffered( false, event );
1295 if ( selectionData && handler->mClipboardEventNotifier )
1297 ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
1298 std::string content( selectionData, strlen(selectionData) );
1300 clipboardEventNotifier.SetContent( content );
1301 clipboardEventNotifier.EmitContentSelectedSignal();
1303 return ECORE_CALLBACK_PASS_ON;
1307 * Called when rotate event is recevied
1309 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
1311 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::Concise, "EcoreEventRotate\n" );
1313 EventHandler* handler( (EventHandler*)data );
1314 Ecore_Wl_Event_Window_Rotate* ev( (Ecore_Wl_Event_Window_Rotate*)event );
1316 if( ev->win != (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
1318 return ECORE_CALLBACK_PASS_ON;
1321 RotationEvent rotationEvent;
1322 rotationEvent.angle = ev->angle;
1323 rotationEvent.winResize = 0;
1325 if( ev->angle == 0 || ev->angle == 180 )
1327 rotationEvent.width = ev->w;
1328 rotationEvent.height = ev->h;
1332 rotationEvent.width = ev->h;
1333 rotationEvent.height = ev->w;
1336 handler->SendRotationPrepareEvent( rotationEvent );
1338 return ECORE_CALLBACK_PASS_ON;
1342 * Called when detent event is recevied
1344 static Eina_Bool EcoreEventDetent( void* data, int type, void* event )
1346 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDetent\n" );
1347 EventHandler* handler( (EventHandler*)data );
1348 Ecore_Event_Detent_Rotate *e((Ecore_Event_Detent_Rotate *)event);
1349 int direction = (e->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1350 int timeStamp = e->timestamp;
1352 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp );
1353 handler->SendWheelEvent( wheelEvent );
1354 return ECORE_CALLBACK_PASS_ON;
1357 /////////////////////////////////////////////////////////////////////////////////////////////////
1359 /////////////////////////////////////////////////////////////////////////////////////////////////
1361 * Called when a font name is changed.
1363 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
1365 EventHandler* handler = static_cast<EventHandler*>( data );
1366 handler->SendEvent( StyleChange::DEFAULT_FONT_CHANGE );
1370 * Called when a font size is changed.
1372 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
1374 EventHandler* handler = static_cast<EventHandler*>( data );
1375 handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1378 void ConvertTouchPosition( Integration::Point& point )
1380 Vector2 position = point.GetScreenPosition();
1381 Vector2 convertedPosition;
1383 switch( mRotationAngle )
1387 convertedPosition.x = mWindowWidth - position.y;
1388 convertedPosition.y = position.x;
1393 convertedPosition.x = mWindowWidth - position.x;
1394 convertedPosition.y = mWindowHeight - position.y;
1399 convertedPosition.x = position.y;
1400 convertedPosition.y = mWindowHeight - position.x;
1405 convertedPosition = position;
1410 point.SetScreenPosition( convertedPosition );
1414 EventHandler* mHandler;
1415 std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
1416 Ecore_Wl_Window* mWindow;
1420 #ifdef DALI_ELDBUS_AVAILABLE
1421 Eldbus_Connection* mSystemConnection;
1422 #endif // DALI_ELDBUS_AVAILABLE
1425 EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
1426 : mCoreEventInterface( coreEventInterface ),
1427 mGestureManager( gestureManager ),
1428 mStyleMonitor( StyleMonitor::Get() ),
1429 mDamageObserver( damageObserver ),
1430 mRotationObserver( NULL ),
1431 mDragAndDropDetector( dndDetector ),
1432 mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
1433 mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
1434 mClipboard( Clipboard::Get() ),
1438 Ecore_Wl_Window* window = 0;
1440 // this code only works with the Ecore RenderSurface so need to downcast
1441 ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
1444 window = ecoreSurface->GetWlWindow();
1447 mImpl = new Impl(this, window);
1450 EventHandler::~EventHandler()
1457 mGestureManager.Stop();
1460 void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
1464 timeStamp = GetCurrentMilliSeconds();
1467 mImpl->ConvertTouchPosition( point );
1469 Integration::TouchEvent touchEvent;
1470 Integration::HoverEvent hoverEvent;
1471 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
1472 if(type != Integration::TouchEventCombiner::DispatchNone )
1474 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);
1476 // First the touch and/or hover event & related gesture events are queued
1477 if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
1479 mCoreEventInterface.QueueCoreEvent( touchEvent );
1480 mGestureManager.SendEvent(touchEvent);
1483 if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
1485 mCoreEventInterface.QueueCoreEvent( hoverEvent );
1488 // Next the events are processed with a single call into Core
1489 mCoreEventInterface.ProcessCoreEvents();
1493 void EventHandler::SendEvent(Integration::KeyEvent& keyEvent)
1495 Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
1496 if ( physicalKeyboard )
1498 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
1500 GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
1504 // Create send KeyEvent to Core.
1505 mCoreEventInterface.QueueCoreEvent( keyEvent );
1506 mCoreEventInterface.ProcessCoreEvents();
1509 void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
1511 // Create WheelEvent and send to Core.
1512 Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
1513 mCoreEventInterface.QueueCoreEvent( event );
1514 mCoreEventInterface.ProcessCoreEvents();
1517 void EventHandler::SendEvent( StyleChange::Type styleChange )
1519 DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
1520 GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
1523 void EventHandler::SendEvent( const DamageArea& area )
1525 mDamageObserver.OnDamaged( area );
1528 void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
1530 if( mRotationObserver != NULL )
1532 mImpl->mRotationAngle = event.angle;
1533 mImpl->mWindowWidth = event.width;
1534 mImpl->mWindowHeight = event.height;
1536 mRotationObserver->OnRotationPrepare( event );
1537 mRotationObserver->OnRotationRequest();
1541 void EventHandler::SendRotationRequestEvent( )
1543 // No need to separate event into prepare and request in wayland
1546 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
1548 Integration::Point convertedPoint( point );
1549 SendEvent(convertedPoint, timeStamp);
1552 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
1554 SendWheelEvent( wheelEvent );
1557 void EventHandler::FeedKeyEvent( KeyEvent& event )
1559 Integration::KeyEvent convertedEvent( event );
1560 SendEvent( convertedEvent );
1563 void EventHandler::FeedEvent( Integration::Event& event )
1565 mCoreEventInterface.QueueCoreEvent( event );
1566 mCoreEventInterface.ProcessCoreEvents();
1569 void EventHandler::Reset()
1573 // Any touch listeners should be told of the interruption.
1574 Integration::TouchEvent event;
1575 Integration::Point point;
1576 point.SetState( PointState::INTERRUPTED );
1577 event.AddPoint( point );
1579 // First the touch event & related gesture events are queued
1580 mCoreEventInterface.QueueCoreEvent( event );
1581 mGestureManager.SendEvent( event );
1583 // Next the events are processed with a single call into Core
1584 mCoreEventInterface.ProcessCoreEvents();
1587 void EventHandler::Pause()
1593 void EventHandler::Resume()
1599 void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
1601 mDragAndDropDetector = detector;
1604 void EventHandler::SetRotationObserver( RotationObserver* observer )
1606 mRotationObserver = observer;
1609 } // namespace Adaptor
1611 } // namespace Internal
1615 #pragma GCC diagnostic pop