2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <events/event-handler.h>
22 // Ecore is littered with C style cast
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wold-style-cast"
26 #include <Ecore_Input.h>
27 #include <ecore-wl-render-surface.h>
32 #ifndef DALI_PROFILE_UBUNTU
34 #include <vconf-keys.h>
35 #endif // DALI_PROFILE_UBUNTU
37 #ifdef DALI_ELDBUS_AVAILABLE
39 #endif // DALI_ELDBUS_AVAILABLE
41 #include <dali/public-api/common/vector-wrapper.h>
42 #include <dali/public-api/events/device.h>
43 #include <dali/public-api/events/touch-point.h>
44 #include <dali/public-api/events/key-event.h>
45 #include <dali/public-api/events/wheel-event.h>
46 #include <dali/integration-api/debug.h>
47 #include <dali/integration-api/events/key-event-integ.h>
48 #include <dali/integration-api/events/touch-event-integ.h>
49 #include <dali/integration-api/events/hover-event-integ.h>
50 #include <dali/integration-api/events/wheel-event-integ.h>
53 #include <events/gesture-manager.h>
54 #include <window-render-surface.h>
55 #include <clipboard-impl.h>
57 #include <physical-keyboard-impl.h>
58 #include <style-monitor-impl.h>
59 #include <base/core-event-interface.h>
60 #include <virtual-keyboard.h>
71 #if defined(DEBUG_ENABLED)
74 Integration::Log::Filter* gTouchEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
75 Integration::Log::Filter* gDragAndDropLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DND");
76 Integration::Log::Filter* gImfLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_IMF");
77 Integration::Log::Filter* gSelectionEventLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_SELECTION");
78 } // unnamed namespace
86 const char* BUS = "org.enlightenment.wm-screen-reader";
87 const char* INTERFACE = "org.tizen.GestureNavigation";
88 const char* PATH = "/org/tizen/GestureNavigation";
90 const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
92 const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
95 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
96 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
97 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
98 * @return the Ecore_IMF_Keyboard_Modifiers output.
100 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
102 int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
105 if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
107 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
110 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
112 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
115 if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
117 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
120 if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
122 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
125 if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
127 modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
130 return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
134 // Copied from x server
135 static unsigned int GetCurrentMilliSeconds(void)
140 static clockid_t clockid;
144 #ifdef CLOCK_MONOTONIC_COARSE
145 if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
146 (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
148 clockid = CLOCK_MONOTONIC_COARSE;
152 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
154 clockid = CLOCK_MONOTONIC;
161 if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
163 return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
166 gettimeofday(&tv, NULL);
167 return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
170 #ifndef DALI_PROFILE_UBUNTU
171 const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
172 #endif // DALI_PROFILE_UBUNTU
175 * Get the device name from the provided ecore key event
177 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
179 const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
181 if ( ecoreDeviceName )
183 result = ecoreDeviceName;
188 * Get the device class from the provided ecore event
190 void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
192 switch( ecoreDeviceClass )
194 case ECORE_DEVICE_CLASS_SEAT:
196 deviceClass = Device::Class::USER;
199 case ECORE_DEVICE_CLASS_KEYBOARD:
201 deviceClass = Device::Class::KEYBOARD;
204 case ECORE_DEVICE_CLASS_MOUSE:
206 deviceClass = Device::Class::MOUSE;
209 case ECORE_DEVICE_CLASS_TOUCH:
211 deviceClass = Device::Class::TOUCH;
214 case ECORE_DEVICE_CLASS_PEN:
216 deviceClass = Device::Class::PEN;
219 case ECORE_DEVICE_CLASS_POINTER:
221 deviceClass = Device::Class::POINTER;
224 case ECORE_DEVICE_CLASS_GAMEPAD:
226 deviceClass = Device::Class::GAMEPAD;
231 deviceClass = Device::Class::NONE;
237 void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
239 switch( ecoreDeviceSubclass )
241 case ECORE_DEVICE_SUBCLASS_FINGER:
243 deviceSubclass = Device::Subclass::FINGER;
246 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
248 deviceSubclass = Device::Subclass::FINGERNAIL;
251 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
253 deviceSubclass = Device::Subclass::KNUCKLE;
256 case ECORE_DEVICE_SUBCLASS_PALM:
258 deviceSubclass = Device::Subclass::PALM;
261 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
263 deviceSubclass = Device::Subclass::HAND_SIDE;
266 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
268 deviceSubclass = Device::Subclass::HAND_FLAT;
271 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
273 deviceSubclass = Device::Subclass::PEN_TIP;
276 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
278 deviceSubclass = Device::Subclass::TRACKPAD;
281 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
283 deviceSubclass = Device::Subclass::TRACKPOINT;
286 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
288 deviceSubclass = Device::Subclass::TRACKBALL;
291 #ifdef OVER_TIZEN_VERSION_4
292 case ECORE_DEVICE_SUBCLASS_REMOCON:
294 deviceSubclass = Device::Subclass::REMOCON;
297 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
299 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
305 deviceSubclass = Device::Subclass::NONE;
311 } // unnamed namespace
313 // Impl to hide EFL implementation.
314 struct EventHandler::Impl
316 // Construction & Destruction
321 Impl( EventHandler* handler, Ecore_Wl_Window* window )
322 : mHandler( handler ),
323 mEcoreEventHandler(),
328 #ifdef DALI_ELDBUS_AVAILABLE
329 , mSystemConnection( NULL )
330 #endif // DALI_ELDBUS_AVAILABLE
332 // Only register for touch and key events if we have a window
335 // Register Touch events
336 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, handler ) );
337 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, handler ) );
338 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, handler ) );
339 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, handler ) );
341 // Register Mouse wheel events
342 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, handler ) );
344 // Register Focus events
345 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, handler ) );
346 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, handler ) );
348 // Register Key events
349 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, handler ) );
350 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, handler ) );
352 // Register Selection event - clipboard selection
353 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, handler ) );
354 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, handler ) );
356 // Register Rotate event
357 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, handler) );
359 // Register Detent event
360 mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetent, handler) );
362 #ifndef DALI_PROFILE_UBUNTU
363 // Register Vconf notify - font name and size
364 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged, handler );
365 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, handler );
366 #endif // DALI_PROFILE_UBUNTU
368 #ifdef DALI_ELDBUS_AVAILABLE
369 // Initialize ElDBus.
370 DALI_LOG_INFO( gImfLogging, Debug::General, "Starting DBus Initialization\n" );
373 EcoreElDBusInitialisation( handler );
375 DALI_LOG_INFO( gImfLogging, Debug::General, "Finished DBus Initialization\n" );
376 #endif // DALI_ELDBUS_AVAILABLE
385 #ifndef DALI_PROFILE_UBUNTU
386 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
387 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontNameChanged );
388 #endif // DALI_PROFILE_UBUNTU
390 for( std::vector<Ecore_Event_Handler*>::iterator iter = mEcoreEventHandler.begin(), endIter = mEcoreEventHandler.end(); iter != endIter; ++iter )
392 ecore_event_handler_del( *iter );
395 #ifdef DALI_ELDBUS_AVAILABLE
396 // Close down ElDBus connections.
397 if( mSystemConnection )
399 eldbus_connection_unref( mSystemConnection );
401 #endif // DALI_ELDBUS_AVAILABLE
406 /////////////////////////////////////////////////////////////////////////////////////////////////
408 /////////////////////////////////////////////////////////////////////////////////////////////////
411 * Called when a touch down is received.
413 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
415 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
416 EventHandler* handler( (EventHandler*)data );
418 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
420 PointState::Type state ( PointState::DOWN );
422 // Check if the buttons field is set and ensure it's the primary touch button.
423 // If this event was triggered by buttons other than the primary button (used for touch), then
424 // just send an interrupted event to Core.
425 if ( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
427 state = PointState::INTERRUPTED;
430 Device::Class::Type deviceClass;
431 Device::Subclass::Type deviceSubclass;
433 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
434 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
436 Integration::Point point;
437 point.SetDeviceId( touchEvent->multi.device );
438 point.SetState( state );
439 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
440 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
441 point.SetPressure( touchEvent->multi.pressure );
442 point.SetAngle( Degree( touchEvent->multi.angle ) );
443 point.SetDeviceClass( deviceClass );
444 point.SetDeviceSubclass( deviceSubclass );
446 handler->SendEvent( point, touchEvent->timestamp );
449 return ECORE_CALLBACK_PASS_ON;
453 * Called when a touch up is received.
455 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
457 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
458 EventHandler* handler( (EventHandler*)data );
460 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
462 Device::Class::Type deviceClass;
463 Device::Subclass::Type deviceSubclass;
465 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
466 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
468 Integration::Point point;
469 point.SetDeviceId( touchEvent->multi.device );
470 point.SetState( PointState::UP );
471 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
472 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
473 point.SetPressure( touchEvent->multi.pressure );
474 point.SetAngle( Degree( touchEvent->multi.angle ) );
475 point.SetDeviceClass( deviceClass );
476 point.SetDeviceSubclass( deviceSubclass );
478 handler->SendEvent( point, touchEvent->timestamp );
481 return ECORE_CALLBACK_PASS_ON;
485 * Called when a touch motion is received.
487 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
489 Ecore_Event_Mouse_Move *touchEvent( (Ecore_Event_Mouse_Move*)event );
490 EventHandler* handler( (EventHandler*)data );
492 if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
494 Device::Class::Type deviceClass;
495 Device::Subclass::Type deviceSubclass;
497 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
498 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
500 Integration::Point point;
501 point.SetDeviceId( touchEvent->multi.device );
502 point.SetState( PointState::MOTION );
503 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
504 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
505 point.SetPressure( touchEvent->multi.pressure );
506 point.SetAngle( Degree( touchEvent->multi.angle ) );
507 point.SetDeviceClass( deviceClass );
508 point.SetDeviceSubclass( deviceSubclass );
510 handler->SendEvent( point, touchEvent->timestamp );
513 return ECORE_CALLBACK_PASS_ON;
517 * Called when a touch is canceled.
519 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
521 Ecore_Event_Mouse_Button *touchEvent( (Ecore_Event_Mouse_Button*)event );
522 EventHandler* handler( (EventHandler*)data );
524 if( touchEvent->window == (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
526 Integration::Point point;
527 point.SetDeviceId( touchEvent->multi.device );
528 point.SetState( PointState::INTERRUPTED );
529 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
530 handler->SendEvent( point, touchEvent->timestamp );
532 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventMouseButtonCancel\n" );
535 return ECORE_CALLBACK_PASS_ON;
539 * Called when a mouse wheel is received.
541 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
543 Ecore_Event_Mouse_Wheel *mouseWheelEvent( (Ecore_Event_Mouse_Wheel*)event );
545 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);
547 EventHandler* handler( (EventHandler*)data );
548 if ( mouseWheelEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
550 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp );
551 handler->SendWheelEvent( wheelEvent );
553 return ECORE_CALLBACK_PASS_ON;
556 /////////////////////////////////////////////////////////////////////////////////////////////////
558 /////////////////////////////////////////////////////////////////////////////////////////////////
561 * Called when a key down is received.
563 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
565 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyDown \n" );
567 EventHandler* handler( (EventHandler*)data );
568 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
569 bool eventHandled( false );
571 // If a device key then skip ecore_imf_context_filter_event.
572 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
574 Ecore_IMF_Context* imfContext = NULL;
575 Dali::ImfManager imfManager( ImfManager::Get() );
578 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
583 // We're consuming key down event so we have to pass to IMF so that it can parse it as well.
584 Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
585 ecoreKeyDownEvent.keyname = keyEvent->keyname;
586 ecoreKeyDownEvent.key = keyEvent->key;
587 ecoreKeyDownEvent.string = keyEvent->string;
588 ecoreKeyDownEvent.compose = keyEvent->compose;
589 ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
590 ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
591 ecoreKeyDownEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
592 ecoreKeyDownEvent.dev_name = "";
593 ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
594 ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
596 std::string checkDevice;
597 GetDeviceName( keyEvent, checkDevice );
599 // 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.
600 if( ( checkDevice == "ime" ) && ( ( !strncmp( keyEvent->keyname, "Left", 4 ) ) ||
601 ( !strncmp( keyEvent->keyname, "Right", 5 ) ) ||
602 ( !strncmp( keyEvent->keyname, "Up", 2 ) ) ||
603 ( !strncmp( keyEvent->keyname, "Down", 4 ) ) ) )
609 eventHandled = ecore_imf_context_filter_event( imfContext,
610 ECORE_IMF_EVENT_KEY_DOWN,
611 (Ecore_IMF_Event *) &ecoreKeyDownEvent );
614 // If the event has not been handled by IMF then check if we should reset our IMF context
617 if ( !strcmp( keyEvent->keyname, "Escape" ) ||
618 !strcmp( keyEvent->keyname, "Return" ) ||
619 !strcmp( keyEvent->keyname, "KP_Enter" ) )
621 ecore_imf_context_reset( imfContext );
627 // If the event wasn't handled then we should send a key event.
630 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
632 std::string keyName( keyEvent->keyname );
633 std::string keyString( "" );
634 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
635 keyCode = (keyCode == -1) ? 0 : keyCode;
636 int modifier( keyEvent->modifiers );
637 unsigned long time = keyEvent->timestamp;
638 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
639 keyCode = atoi(keyEvent->keyname + 8);
641 // Ensure key event string is not NULL as keys like SHIFT have a null string.
642 if ( keyEvent->string )
644 keyString = keyEvent->string;
647 std::string deviceName;
648 Device::Class::Type deviceClass;
649 Device::Subclass::Type deviceSubclass;
651 GetDeviceName( keyEvent, deviceName );
652 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
653 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
655 DALI_LOG_INFO( gImfLogging, Debug::Verbose, "EVENT EcoreEventKeyDown - >>EcoreEventKeyDown deviceName(%s) deviceClass(%d)\n", deviceName.c_str(), deviceClass );
657 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, deviceName, deviceClass, deviceSubclass );
658 handler->SendEvent( keyEvent );
662 return ECORE_CALLBACK_PASS_ON;
666 * Called when a key up is received.
668 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
670 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventKeyUp\n" );
672 EventHandler* handler( (EventHandler*)data );
673 Ecore_Event_Key *keyEvent( (Ecore_Event_Key*)event );
674 bool eventHandled( false );
676 // Device keys like Menu, home, back button must skip ecore_imf_context_filter_event.
677 if ( ! KeyLookup::IsDeviceButton( keyEvent->keyname ) )
679 Ecore_IMF_Context* imfContext = NULL;
680 Dali::ImfManager imfManager( ImfManager::Get() );
683 imfContext = ImfManager::GetImplementation( imfManager ).GetContext();
688 // We're consuming key up event so we have to pass to IMF so that it can parse it as well.
689 Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
690 ecoreKeyUpEvent.keyname = keyEvent->keyname;
691 ecoreKeyUpEvent.key = keyEvent->key;
692 ecoreKeyUpEvent.string = keyEvent->string;
693 ecoreKeyUpEvent.compose = keyEvent->compose;
694 ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
695 ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
696 ecoreKeyUpEvent.locks = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
697 ecoreKeyUpEvent.dev_name = "";
698 ecoreKeyUpEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
699 ecoreKeyUpEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
701 eventHandled = ecore_imf_context_filter_event( imfContext,
702 ECORE_IMF_EVENT_KEY_UP,
703 (Ecore_IMF_Event *) &ecoreKeyUpEvent );
707 // If the event wasn't handled then we should send a key event.
710 if ( keyEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
712 std::string keyName( keyEvent->keyname );
713 std::string keyString( "" );
714 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname);
715 keyCode = (keyCode == -1) ? 0 : keyCode;
716 int modifier( keyEvent->modifiers );
717 unsigned long time = keyEvent->timestamp;
718 if (!strncmp(keyEvent->keyname, "Keycode-", 8))
719 keyCode = atoi(keyEvent->keyname + 8);
721 // Ensure key event string is not NULL as keys like SHIFT have a null string.
722 if ( keyEvent->string )
724 keyString = keyEvent->string;
727 std::string deviceName;
728 Device::Class::Type deviceClass;
729 Device::Subclass::Type deviceSubclass;
731 GetDeviceName( keyEvent, deviceName );
732 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
733 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
735 Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, deviceName, deviceClass, deviceSubclass );
736 handler->SendEvent( keyEvent );
740 return ECORE_CALLBACK_PASS_ON;
743 /////////////////////////////////////////////////////////////////////////////////////////////////
745 /////////////////////////////////////////////////////////////////////////////////////////////////
748 * Called when the window gains focus.
750 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
752 Ecore_Wl_Event_Focus_In* focusInEvent( (Ecore_Wl_Event_Focus_In*)event );
753 EventHandler* handler( (EventHandler*)data );
755 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusIn \n" );
757 // If the window gains focus and we hid the keyboard then show it again.
758 if ( focusInEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
760 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventWindowFocusIn - >>WindowFocusGained \n" );
762 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
764 Dali::ImfManager imfManager( ImfManager::Get() );
767 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
768 if( imfManagerImpl.RestoreAfterFocusLost() )
770 imfManagerImpl.Activate();
774 Dali::Clipboard clipboard = Clipboard::Get();
775 clipboard.HideClipboard();
778 return ECORE_CALLBACK_PASS_ON;
782 * Called when the window loses focus.
784 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
786 Ecore_Wl_Event_Focus_Out* focusOutEvent( (Ecore_Wl_Event_Focus_Out*)event );
787 EventHandler* handler( (EventHandler*)data );
789 DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT >>EcoreEventWindowFocusOut \n" );
791 // If the window loses focus then hide the keyboard.
792 if ( focusOutEvent->win == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
794 if ( ImfManager::IsAvailable() /* Only get the ImfManager if it's available as we do not want to create it */ )
796 Dali::ImfManager imfManager( ImfManager::Get() );
799 ImfManager& imfManagerImpl( ImfManager::GetImplementation( imfManager ) );
800 if( imfManagerImpl.RestoreAfterFocusLost() )
802 imfManagerImpl.Deactivate();
807 // Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard
808 Dali::Clipboard clipboard = Clipboard::Get();
811 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
812 clipBoardImpl.HideClipboard(true);
816 return ECORE_CALLBACK_PASS_ON;
820 * Called when the window is damaged.
822 static Eina_Bool EcoreEventWindowDamaged(void *data, int type, void *event)
824 return ECORE_CALLBACK_PASS_ON;
828 * Called when the window properties are changed.
829 * We are only interested in the font change.
833 /////////////////////////////////////////////////////////////////////////////////////////////////
834 // Drag & Drop Callbacks
835 /////////////////////////////////////////////////////////////////////////////////////////////////
838 * Called when a dragged item enters our window's bounds.
839 * This is when items are dragged INTO our window.
841 static Eina_Bool EcoreEventDndEnter( void* data, int type, void* event )
843 DALI_LOG_INFO( gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndEnter\n" );
845 return ECORE_CALLBACK_PASS_ON;
849 * Called when a dragged item is moved within our window.
850 * This is when items are dragged INTO our window.
852 static Eina_Bool EcoreEventDndPosition( void* data, int type, void* event )
854 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndPosition\n" );
856 return ECORE_CALLBACK_PASS_ON;
860 * Called when a dragged item leaves our window's bounds.
861 * This is when items are dragged INTO our window.
863 static Eina_Bool EcoreEventDndLeave( void* data, int type, void* event )
865 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndLeave\n" );
867 return ECORE_CALLBACK_PASS_ON;
871 * Called when the dragged item is dropped within our window's bounds.
872 * This is when items are dragged INTO our window.
874 static Eina_Bool EcoreEventDndDrop( void* data, int type, void* event )
876 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndDrop\n" );
878 return ECORE_CALLBACK_PASS_ON;
882 * Called when a dragged item is moved from our window and the target window has done processing it.
883 * This is when items are dragged FROM our window.
885 static Eina_Bool EcoreEventDndFinished( void* data, int type, void* event )
887 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndFinished\n" );
888 return ECORE_CALLBACK_PASS_ON;
892 * Called when a dragged item is moved from our window and the target window has sent us a status.
893 * This is when items are dragged FROM our window.
895 static Eina_Bool EcoreEventDndStatus( void* data, int type, void* event )
897 DALI_LOG_INFO(gDragAndDropLogFilter, Debug::Concise, "EcoreEventDndStatus\n" );
898 return ECORE_CALLBACK_PASS_ON;
902 * Called when the client messages (i.e. the accessibility events) are received.
904 static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
906 return ECORE_CALLBACK_PASS_ON;
910 /////////////////////////////////////////////////////////////////////////////////////////////////
911 // ElDBus Accessibility Callbacks
912 /////////////////////////////////////////////////////////////////////////////////////////////////
914 #ifdef DALI_ELDBUS_AVAILABLE
915 // Callback for Ecore ElDBus accessibility events.
916 static void OnEcoreElDBusAccessibilityNotification( void *context EINA_UNUSED, const Eldbus_Message *message )
918 EventHandler* handler = static_cast< EventHandler* >( context );
919 // Ignore any accessibility events when paused.
920 if( handler->mPaused )
925 if( !handler->mAccessibilityAdaptor )
927 DALI_LOG_ERROR( "Invalid accessibility adaptor\n" );
931 AccessibilityAdaptor* accessibilityAdaptor( &AccessibilityAdaptor::GetImplementation( handler->mAccessibilityAdaptor ) );
932 if( !accessibilityAdaptor )
934 DALI_LOG_ERROR( "Cannot access accessibility adaptor\n" );
940 int state; // 0 - begin, 1 - ongoing, 2 - ended, 3 - aborted
943 // The string defines the arg-list's respective types.
944 if( !eldbus_message_arguments_get( message, "iiiiiiu", &gestureValue, &xS, &yS, &xE, &yE, &state, &eventTime ) )
946 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
949 DALI_LOG_INFO( gImfLogging, Debug::General, "Got gesture: Name: %d Args: %d,%d,%d,%d State: %d\n", gestureValue, xS, yS, xE, yE );
951 // Create a touch point object.
952 TouchPoint::State touchPointState( TouchPoint::Down );
955 touchPointState = TouchPoint::Down; // Mouse down.
957 else if( state == 1 )
959 touchPointState = TouchPoint::Motion; // Mouse move.
961 else if( state == 2 )
963 touchPointState = TouchPoint::Up; // Mouse up.
967 touchPointState = TouchPoint::Interrupted; // Error.
970 // Send touch event to accessibility adaptor.
971 TouchPoint point( 0, touchPointState, (float)xS, (float)yS );
973 // Perform actions based on received gestures.
974 // Note: This is seperated from the reading so we can have other input readers without changing the below code.
975 switch( gestureValue )
977 case 0: // OneFingerHover
980 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
983 case 1: // TwoFingersHover
985 // In accessibility mode, scroll action should be handled when the currently focused actor is contained in scrollable control
986 accessibilityAdaptor->HandleActionScrollEvent( point, GetCurrentMilliSeconds() );
989 case 2: // ThreeFingersHover
991 // Read from top item on screen continuously.
992 accessibilityAdaptor->HandleActionReadFromTopEvent();
995 case 3: // OneFingerFlickLeft
997 // Move to previous item.
998 accessibilityAdaptor->HandleActionReadPreviousEvent();
1001 case 4: // OneFingerFlickRight
1003 // Move to next item.
1004 accessibilityAdaptor->HandleActionReadNextEvent();
1007 case 5: // OneFingerFlickUp
1009 // Move to previous item.
1010 accessibilityAdaptor->HandleActionPreviousEvent();
1013 case 6: // OneFingerFlickDown
1015 // Move to next item.
1016 accessibilityAdaptor->HandleActionNextEvent();
1019 case 7: // TwoFingersFlickUp
1021 // Scroll up the list.
1022 accessibilityAdaptor->HandleActionScrollUpEvent();
1025 case 8: // TwoFingersFlickDown
1027 // Scroll down the list.
1028 accessibilityAdaptor->HandleActionScrollDownEvent();
1031 case 9: // TwoFingersFlickLeft
1033 // Scroll left to the previous page
1034 accessibilityAdaptor->HandleActionPageLeftEvent();
1037 case 10: // TwoFingersFlickRight
1039 // Scroll right to the next page
1040 accessibilityAdaptor->HandleActionPageRightEvent();
1043 case 11: // ThreeFingersFlickLeft
1048 case 12: // ThreeFingersFlickRight
1053 case 13: // ThreeFingersFlickUp
1058 case 14: // ThreeFingersFlickDown
1063 case 15: // OneFingerSingleTap
1066 accessibilityAdaptor->HandleActionReadEvent( (unsigned int)xS, (unsigned int)yS, true /* allow read again */ );
1069 case 16: // OneFingerDoubleTap
1071 // Activate selected item / active edit mode.
1072 accessibilityAdaptor->HandleActionActivateEvent();
1075 case 17: // OneFingerTripleTap
1078 accessibilityAdaptor->HandleActionZoomEvent();
1081 case 18: // TwoFingersSingleTap
1083 // Pause/Resume current speech
1084 accessibilityAdaptor->HandleActionReadPauseResumeEvent();
1087 case 19: // TwoFingersDoubleTap
1089 // Start/Stop current action
1090 accessibilityAdaptor->HandleActionStartStopEvent();
1093 case 20: // TwoFingersTripleTap
1095 // Read information from indicator
1096 accessibilityAdaptor->HandleActionReadIndicatorInformationEvent();
1099 case 21: // ThreeFingersSingleTap
1101 // Read from top item on screen continuously.
1102 accessibilityAdaptor->HandleActionReadFromTopEvent();
1105 case 22: // ThreeFingersDoubleTap
1107 // Read from next item continuously.
1108 accessibilityAdaptor->HandleActionReadFromNextEvent();
1111 case 23: // ThreeFingersTripleTap
1116 case 24: // OneFingerFlickLeftReturn
1118 // Scroll up to the previous page
1119 accessibilityAdaptor->HandleActionPageUpEvent();
1122 case 25: // OneFingerFlickRightReturn
1124 // Scroll down to the next page
1125 accessibilityAdaptor->HandleActionPageDownEvent();
1128 case 26: // OneFingerFlickUpReturn
1130 // Move to the first item on screen
1131 accessibilityAdaptor->HandleActionMoveToFirstEvent();
1134 case 27: // OneFingerFlickDownReturn
1136 // Move to the last item on screen
1137 accessibilityAdaptor->HandleActionMoveToLastEvent();
1140 case 28: // TwoFingersFlickLeftReturn
1145 case 29: // TwoFingersFlickRightReturn
1150 case 30: // TwoFingersFlickUpReturn
1155 case 31: // TwoFingersFlickDownReturn
1160 case 32: // ThreeFingersFlickLeftReturn
1165 case 33: // ThreeFingersFlickRightReturn
1170 case 34: // ThreeFingersFlickUpReturn
1175 case 35: // ThreeFingersFlickDownReturn
1183 void EcoreElDBusInitialisation( void *handle )
1185 Eldbus_Object *object;
1186 Eldbus_Proxy *manager;
1188 if( !( mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM) ) )
1190 DALI_LOG_ERROR( "Unable to get system bus\n" );
1193 object = eldbus_object_get( mSystemConnection, BUS, PATH );
1196 DALI_LOG_ERROR( "Getting object failed\n" );
1200 manager = eldbus_proxy_get( object, INTERFACE );
1203 DALI_LOG_ERROR( "Getting proxy failed\n" );
1207 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", OnEcoreElDBusAccessibilityNotification, handle ) )
1209 DALI_LOG_ERROR( "No signal handler returned\n" );
1212 #endif // DALI_ELDBUS_AVAILABLE
1215 * Called when the source window notifies us the content in clipboard is selected.
1217 static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
1219 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionClear\n" );
1220 return ECORE_CALLBACK_PASS_ON;
1224 * Called when the source window sends us about the selected content.
1225 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
1227 static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
1229 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventSelectionNotify\n" );
1230 return ECORE_CALLBACK_PASS_ON;
1234 * Called when the source window notifies us the content in clipboard is selected.
1236 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
1238 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataSend\n" );
1240 Dali::Clipboard clipboard = Clipboard::Get();
1243 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1244 clipBoardImpl.ExcuteBuffered( true, event );
1246 return ECORE_CALLBACK_PASS_ON;
1250 * Called when the source window sends us about the selected content.
1251 * For example, when item is selected in the clipboard.
1253 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
1255 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDataReceive\n" );
1257 EventHandler* handler( (EventHandler*)data );
1258 Dali::Clipboard clipboard = Clipboard::Get();
1259 char *selectionData = NULL;
1262 Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
1263 selectionData = clipBoardImpl.ExcuteBuffered( false, event );
1265 if ( selectionData && handler->mClipboardEventNotifier )
1267 ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( handler->mClipboardEventNotifier ) );
1268 std::string content( selectionData, strlen(selectionData) );
1270 clipboardEventNotifier.SetContent( content );
1271 clipboardEventNotifier.EmitContentSelectedSignal();
1273 return ECORE_CALLBACK_PASS_ON;
1277 * Called when rotate event is recevied
1279 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
1281 DALI_LOG_INFO( gSelectionEventLogFilter, Debug::Concise, "EcoreEventRotate\n" );
1283 EventHandler* handler( (EventHandler*)data );
1284 Ecore_Wl_Event_Window_Rotate* ev( (Ecore_Wl_Event_Window_Rotate*)event );
1286 if( ev->win != (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
1288 return ECORE_CALLBACK_PASS_ON;
1291 RotationEvent rotationEvent;
1292 rotationEvent.angle = ev->angle;
1293 rotationEvent.winResize = 0;
1295 if( ev->angle == 0 || ev->angle == 180 )
1297 rotationEvent.width = ev->w;
1298 rotationEvent.height = ev->h;
1302 rotationEvent.width = ev->h;
1303 rotationEvent.height = ev->w;
1306 handler->SendRotationPrepareEvent( rotationEvent );
1308 return ECORE_CALLBACK_PASS_ON;
1312 * Called when detent event is recevied
1314 static Eina_Bool EcoreEventDetent( void* data, int type, void* event )
1316 DALI_LOG_INFO(gSelectionEventLogFilter, Debug::Concise, "EcoreEventDetent\n" );
1317 EventHandler* handler( (EventHandler*)data );
1318 Ecore_Event_Detent_Rotate *e((Ecore_Event_Detent_Rotate *)event);
1319 int direction = (e->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
1320 int timeStamp = e->timestamp;
1322 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp );
1323 handler->SendWheelEvent( wheelEvent );
1324 return ECORE_CALLBACK_PASS_ON;
1327 /////////////////////////////////////////////////////////////////////////////////////////////////
1329 /////////////////////////////////////////////////////////////////////////////////////////////////
1331 * Called when a font name is changed.
1333 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
1335 EventHandler* handler = static_cast<EventHandler*>( data );
1336 handler->SendEvent( StyleChange::DEFAULT_FONT_CHANGE );
1340 * Called when a font size is changed.
1342 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
1344 EventHandler* handler = static_cast<EventHandler*>( data );
1345 handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1348 void ConvertTouchPosition( Integration::Point& point )
1350 Vector2 position = point.GetScreenPosition();
1351 Vector2 convertedPosition;
1353 switch( mRotationAngle )
1357 convertedPosition.x = mWindowWidth - position.y;
1358 convertedPosition.y = position.x;
1363 convertedPosition.x = mWindowWidth - position.x;
1364 convertedPosition.y = mWindowHeight - position.y;
1369 convertedPosition.x = position.y;
1370 convertedPosition.y = mWindowHeight - position.x;
1375 convertedPosition = position;
1380 point.SetScreenPosition( convertedPosition );
1384 EventHandler* mHandler;
1385 std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
1386 Ecore_Wl_Window* mWindow;
1390 #ifdef DALI_ELDBUS_AVAILABLE
1391 Eldbus_Connection* mSystemConnection;
1392 #endif // DALI_ELDBUS_AVAILABLE
1395 EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
1396 : mCoreEventInterface( coreEventInterface ),
1397 mGestureManager( gestureManager ),
1398 mStyleMonitor( StyleMonitor::Get() ),
1399 mDamageObserver( damageObserver ),
1400 mRotationObserver( NULL ),
1401 mDragAndDropDetector( dndDetector ),
1402 mAccessibilityAdaptor( AccessibilityAdaptor::Get() ),
1403 mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
1404 mClipboard( Clipboard::Get() ),
1408 Ecore_Wl_Window* window = 0;
1410 // this code only works with the Ecore RenderSurface so need to downcast
1411 ECore::WindowRenderSurface* ecoreSurface = dynamic_cast< ECore::WindowRenderSurface* >( surface );
1414 window = ecoreSurface->GetWlWindow();
1417 mImpl = new Impl(this, window);
1420 EventHandler::~EventHandler()
1427 mGestureManager.Stop();
1430 void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
1434 timeStamp = GetCurrentMilliSeconds();
1437 mImpl->ConvertTouchPosition( point );
1439 Integration::TouchEvent touchEvent;
1440 Integration::HoverEvent hoverEvent;
1441 Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
1442 if(type != Integration::TouchEventCombiner::DispatchNone )
1444 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);
1446 // First the touch and/or hover event & related gesture events are queued
1447 if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
1449 mCoreEventInterface.QueueCoreEvent( touchEvent );
1450 mGestureManager.SendEvent(touchEvent);
1453 if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
1455 mCoreEventInterface.QueueCoreEvent( hoverEvent );
1458 // Next the events are processed with a single call into Core
1459 mCoreEventInterface.ProcessCoreEvents();
1463 void EventHandler::SendEvent(Integration::KeyEvent& keyEvent)
1465 Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
1466 if ( physicalKeyboard )
1468 if ( ! KeyLookup::IsDeviceButton( keyEvent.keyName.c_str() ) )
1470 GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
1474 // Create send KeyEvent to Core.
1475 mCoreEventInterface.QueueCoreEvent( keyEvent );
1476 mCoreEventInterface.ProcessCoreEvents();
1479 void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
1481 // Create WheelEvent and send to Core.
1482 Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
1483 mCoreEventInterface.QueueCoreEvent( event );
1484 mCoreEventInterface.ProcessCoreEvents();
1487 void EventHandler::SendEvent( StyleChange::Type styleChange )
1489 DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
1490 GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
1493 void EventHandler::SendEvent( const DamageArea& area )
1495 mDamageObserver.OnDamaged( area );
1498 void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
1500 if( mRotationObserver != NULL )
1502 mImpl->mRotationAngle = event.angle;
1503 mImpl->mWindowWidth = event.width;
1504 mImpl->mWindowHeight = event.height;
1506 mRotationObserver->OnRotationPrepare( event );
1507 mRotationObserver->OnRotationRequest();
1511 void EventHandler::SendRotationRequestEvent( )
1513 // No need to separate event into prepare and request in wayland
1516 void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
1518 Integration::Point convertedPoint( point );
1519 SendEvent(convertedPoint, timeStamp);
1522 void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
1524 SendWheelEvent( wheelEvent );
1527 void EventHandler::FeedKeyEvent( KeyEvent& event )
1529 Integration::KeyEvent convertedEvent( event );
1530 SendEvent( convertedEvent );
1533 void EventHandler::FeedEvent( Integration::Event& event )
1535 mCoreEventInterface.QueueCoreEvent( event );
1536 mCoreEventInterface.ProcessCoreEvents();
1539 void EventHandler::Reset()
1543 // Any touch listeners should be told of the interruption.
1544 Integration::TouchEvent event;
1545 Integration::Point point;
1546 point.SetState( PointState::INTERRUPTED );
1547 event.AddPoint( point );
1549 // First the touch event & related gesture events are queued
1550 mCoreEventInterface.QueueCoreEvent( event );
1551 mGestureManager.SendEvent( event );
1553 // Next the events are processed with a single call into Core
1554 mCoreEventInterface.ProcessCoreEvents();
1557 void EventHandler::Pause()
1563 void EventHandler::Resume()
1569 void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
1571 mDragAndDropDetector = detector;
1574 void EventHandler::SetRotationObserver( RotationObserver* observer )
1576 mRotationObserver = observer;
1579 } // namespace Adaptor
1581 } // namespace Internal
1585 #pragma GCC diagnostic pop