+ mSupportedAuxiliaryHints.clear();
+ mAuxiliaryHints.clear();
+
+ if( mEglWindow != NULL )
+ {
+ wl_egl_window_destroy( mEglWindow );
+ mEglWindow = NULL;
+ }
+
+ if( mOwnSurface )
+ {
+ ecore_wl2_window_free( mEcoreWindow );
+
+ WindowSystem::Shutdown();
+ }
+}
+
+void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
+{
+ if( surface.Empty() == false )
+ {
+ // check we have a valid type
+ DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl2_Window *) ) && "Surface type is invalid" );
+
+ mEcoreWindow = AnyCast< Ecore_Wl2_Window* >( surface );
+ }
+ else
+ {
+ // we own the surface about to created
+ WindowSystem::Initialize();
+
+ mOwnSurface = true;
+ CreateWindow( positionSize );
+ }
+
+ mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
+
+ SetTransparency( isTransparent );
+
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
+
+ // Register Rotate event
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
+
+ // Register Configure event
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this ) );
+
+ // Register Touch events
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
+
+ // Register Mouse wheel events
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
+
+ // Register Detent event
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
+
+ // Register Key events
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
+
+ // Register Selection event - clipboard selection
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
+
+ // Register Vconf notify - font name and size
+ vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
+ vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
+
+ InitializeEcoreElDBus();
+
+ Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
+ mDisplay = ecore_wl2_display_get( display );
+
+ if( mDisplay )
+ {
+ wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
+ if( displayWrapper )
+ {
+ mEventQueue = wl_display_create_queue( mDisplay );
+ if( mEventQueue )
+ {
+ wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
+
+ wl_registry* registry = wl_display_get_registry( displayWrapper );
+ wl_registry_add_listener( registry, ®istryListener, this );
+ }
+
+ wl_proxy_wrapper_destroy( displayWrapper );
+ }
+ }
+
+ // get auxiliary hint
+ Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
+ if( hints )
+ {
+ Eina_List* l = NULL;
+ char* hint = NULL;
+
+ for( l = hints, ( hint = static_cast< char* >( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( hint = static_cast< char* >( eina_list_data_get(l) ) ) )
+ {
+ mSupportedAuxiliaryHints.push_back( hint );
+
+ DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
+ }
+ }
+}
+
+Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
+{
+ Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
+ Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+
+ if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ if( iconifyChangedEvent->iconified == EINA_TRUE )
+ {
+ mIconifyChangedSignal.Emit( true );
+ }
+ else
+ {
+ mIconifyChangedSignal.Emit( false );
+ }
+ handled = ECORE_CALLBACK_DONE;
+ }
+
+ return handled;
+}
+
+Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
+{
+ Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
+
+ if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
+
+ mFocusChangedSignal.Emit( true );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
+{
+ Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
+
+ if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
+
+ mFocusChangedSignal.Emit( false );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
+{
+ Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
+
+ if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
+ {
+ DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
+
+ mOutputTransformedSignal.Emit();
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
+{
+ Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
+
+ if( ignoreTransformEvent->win == mEcoreWindow )
+ {
+ DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
+
+ mOutputTransformedSignal.Emit();
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+void WindowBaseEcoreWl2::OnRotation( void* data, int type, void* event )
+{
+ Ecore_Wl2_Event_Window_Rotation* ev( static_cast< Ecore_Wl2_Event_Window_Rotation* >( event ) );
+
+ if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnRotation\n" );
+
+ RotationEvent rotationEvent;
+ rotationEvent.angle = ev->angle;
+ rotationEvent.winResize = 0;
+
+ if( ev->angle == 0 || ev->angle == 180 )
+ {
+ rotationEvent.width = ev->w;
+ rotationEvent.height = ev->h;
+ }
+ else
+ {
+ rotationEvent.width = ev->h;
+ rotationEvent.height = ev->w;
+ }
+
+ mRotationSignal.Emit( rotationEvent );
+ }
+}
+
+void WindowBaseEcoreWl2::OnConfiguration( void* data, int type, void* event )
+{
+ Ecore_Wl2_Event_Window_Configure* ev( static_cast< Ecore_Wl2_Event_Window_Configure* >( event ) );
+
+ if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ // Note: To comply with the wayland protocol, Dali should make an ack_configure
+ // by calling ecore_wl2_window_commit
+ ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
+ }
+}
+
+void WindowBaseEcoreWl2::OnMouseButtonDown( void* data, int type, void* event )
+{
+ Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+
+ if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ Device::Class::Type deviceClass;
+ Device::Subclass::Type deviceSubclass;
+
+ GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
+ GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+
+ PointState::Type state ( PointState::DOWN );
+
+ if( deviceClass != Device::Class::Type::MOUSE )
+ {
+ // Check if the buttons field is set and ensure it's the primary touch button.
+ // If this event was triggered by buttons other than the primary button (used for touch), then
+ // just send an interrupted event to Core.
+ if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
+ {
+ state = PointState::INTERRUPTED;
+ }
+ }
+
+ Integration::Point point;
+ point.SetDeviceId( touchEvent->multi.device );
+ point.SetState( state );
+ point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
+ point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
+ point.SetPressure( touchEvent->multi.pressure );
+ point.SetAngle( Degree( touchEvent->multi.angle ) );
+ point.SetDeviceClass( deviceClass );
+ point.SetDeviceSubclass( deviceSubclass );
+ point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
+
+ mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ }
+}
+
+void WindowBaseEcoreWl2::OnMouseButtonUp( void* data, int type, void* event )
+{
+ Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+
+ if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ Device::Class::Type deviceClass;
+ Device::Subclass::Type deviceSubclass;
+
+ GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
+ GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+
+ Integration::Point point;
+ point.SetDeviceId( touchEvent->multi.device );
+ point.SetState( PointState::UP );
+ point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
+ point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
+ point.SetPressure( touchEvent->multi.pressure );
+ point.SetAngle( Degree( touchEvent->multi.angle ) );
+ point.SetDeviceClass( deviceClass );
+ point.SetDeviceSubclass( deviceSubclass );
+ point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
+
+ mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ }
+}
+
+void WindowBaseEcoreWl2::OnMouseButtonMove( void* data, int type, void* event )
+{
+ Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
+
+ if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ Device::Class::Type deviceClass;
+ Device::Subclass::Type deviceSubclass;
+
+ GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
+ GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+
+ Integration::Point point;
+ point.SetDeviceId( touchEvent->multi.device );
+ point.SetState( PointState::MOTION );
+ point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
+ point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
+ point.SetPressure( touchEvent->multi.pressure );
+ point.SetAngle( Degree( touchEvent->multi.angle ) );
+ point.SetDeviceClass( deviceClass );
+ point.SetDeviceSubclass( deviceSubclass );
+
+ mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ }
+}
+
+void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event )
+{
+ Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+
+ if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ Integration::Point point;
+ point.SetDeviceId( touchEvent->multi.device );
+ point.SetState( PointState::INTERRUPTED );
+ point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
+
+ mTouchEventSignal.Emit( point, touchEvent->timestamp );
+
+ DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" );
+ }
+}
+
+void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
+{
+ Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
+
+ if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ {
+ DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
+
+ WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
+
+ mWheelEventSignal.Emit( wheelEvent );
+ }