X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fwindow-system%2Ftizen-wayland%2Fecore-wl%2Fwindow-base-ecore-wl.cpp;h=0eecbcc8d25f5fae755110083205de66f3431c81;hb=0e4caa74f44f5aa507610f16243b1e6aaa4421a8;hp=7a77b0111ed2c9ba41fe149231515890aa435221;hpb=44ac6b074a4d7d2f9474331a364e4629c0bce11a;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp index 7a77b01..0eecbcc 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +24,16 @@ // INTERNAL HEADERS #include -#include +#include +#include #include // EXTERNAL_HEADERS #include #include +#include +#include +#include namespace Dali { @@ -48,6 +52,153 @@ Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, fals #endif const uint32_t MAX_TIZEN_CLIENT_VERSION = 7; +const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1; + +const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced. + +// DBUS accessibility +const char* BUS = "org.enlightenment.wm-screen-reader"; +const char* INTERFACE = "org.tizen.GestureNavigation"; +const char* PATH = "/org/tizen/GestureNavigation"; + +/** + * Get the device name from the provided ecore key event + */ +void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result ) +{ + const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev ); + + if( ecoreDeviceName ) + { + result = ecoreDeviceName; + } +} + +/** + * Get the device class from the provided ecore event + */ +void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass ) +{ + switch( ecoreDeviceClass ) + { + case ECORE_DEVICE_CLASS_SEAT: + { + deviceClass = Device::Class::USER; + break; + } + case ECORE_DEVICE_CLASS_KEYBOARD: + { + deviceClass = Device::Class::KEYBOARD; + break; + } + case ECORE_DEVICE_CLASS_MOUSE: + { + deviceClass = Device::Class::MOUSE; + break; + } + case ECORE_DEVICE_CLASS_TOUCH: + { + deviceClass = Device::Class::TOUCH; + break; + } + case ECORE_DEVICE_CLASS_PEN: + { + deviceClass = Device::Class::PEN; + break; + } + case ECORE_DEVICE_CLASS_POINTER: + { + deviceClass = Device::Class::POINTER; + break; + } + case ECORE_DEVICE_CLASS_GAMEPAD: + { + deviceClass = Device::Class::GAMEPAD; + break; + } + default: + { + deviceClass = Device::Class::NONE; + break; + } + } +} + +void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass ) +{ + switch( ecoreDeviceSubclass ) + { + case ECORE_DEVICE_SUBCLASS_FINGER: + { + deviceSubclass = Device::Subclass::FINGER; + break; + } + case ECORE_DEVICE_SUBCLASS_FINGERNAIL: + { + deviceSubclass = Device::Subclass::FINGERNAIL; + break; + } + case ECORE_DEVICE_SUBCLASS_KNUCKLE: + { + deviceSubclass = Device::Subclass::KNUCKLE; + break; + } + case ECORE_DEVICE_SUBCLASS_PALM: + { + deviceSubclass = Device::Subclass::PALM; + break; + } + case ECORE_DEVICE_SUBCLASS_HAND_SIZE: + { + deviceSubclass = Device::Subclass::HAND_SIDE; + break; + } + case ECORE_DEVICE_SUBCLASS_HAND_FLAT: + { + deviceSubclass = Device::Subclass::HAND_FLAT; + break; + } + case ECORE_DEVICE_SUBCLASS_PEN_TIP: + { + deviceSubclass = Device::Subclass::PEN_TIP; + break; + } + case ECORE_DEVICE_SUBCLASS_TRACKPAD: + { + deviceSubclass = Device::Subclass::TRACKPAD; + break; + } + case ECORE_DEVICE_SUBCLASS_TRACKPOINT: + { + deviceSubclass = Device::Subclass::TRACKPOINT; + break; + } + case ECORE_DEVICE_SUBCLASS_TRACKBALL: + { + deviceSubclass = Device::Subclass::TRACKBALL; + break; + } + case ECORE_DEVICE_SUBCLASS_REMOCON: + { + deviceSubclass = Device::Subclass::REMOCON; + break; + } + case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD: + { + deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD; + break; + } + default: + { + deviceSubclass = Device::Subclass::NONE; + break; + } + } +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Window Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// /// Called when the window iconify state is changed. static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event ) @@ -109,6 +260,206 @@ static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* ev return ECORE_CALLBACK_PASS_ON; } +/** + * Called when rotate event is recevied. + */ +static Eina_Bool EcoreEventRotate( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnRotation( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Touch Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when a touch down is received. + */ +static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnMouseButtonDown( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +/** + * Called when a touch up is received. + */ +static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnMouseButtonUp( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +/** + * Called when a touch motion is received. + */ +static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnMouseButtonMove( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +/** + * Called when a touch is canceled. + */ +static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnMouseButtonCancel( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +/** + * Called when a mouse wheel is received. + */ +static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnMouseWheel( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +/** + * Called when a detent rotation event is recevied. + */ +static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnDetentRotation( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Key Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when a key down is received. + */ +static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnKeyDown( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +/** + * Called when a key up is received. + */ +static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnKeyUp( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Selection Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when the source window notifies us the content in clipboard is selected. + */ +static Eina_Bool EcoreEventDataSend( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnDataSend( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +/** +* Called when the source window sends us about the selected content. +* For example, when item is selected in the clipboard. +*/ +static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnDataReceive( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Font Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when a font name is changed. + */ +static void VconfNotifyFontNameChanged( keynode_t* node, void* data ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnFontNameChanged(); + } +} + +/** + * Called when a font size is changed. + */ +static void VconfNotifyFontSizeChanged( keynode_t* node, void* data ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); + if( windowBase ) + { + windowBase->OnFontSizeChanged(); + } +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// ElDBus Accessibility Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef DALI_ELDBUS_AVAILABLE +// Callback for Ecore ElDBus accessibility events. +static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message ) +{ + WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( context ); + if( windowBase ) + { + windowBase->OnEcoreElDBusAccessibilityNotification( context, message ); + } +} +#endif // DALI_ELDBUS_AVAILABLE + static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version ) { WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data ); @@ -213,11 +564,11 @@ const struct tizen_display_policy_listener tizenDisplayPolicyListener = } // unnamed namespace -WindowBaseEcoreWl::WindowBaseEcoreWl( Window* window, WindowRenderSurface* windowRenderSurface ) +WindowBaseEcoreWl::WindowBaseEcoreWl( Dali::PositionSize positionSize, Any surface, bool isTransparent ) : mEcoreEventHandler(), - mWindow( window ), - mWindowSurface( NULL ), mEcoreWindow( NULL ), + mWlSurface( NULL ), + mEglWindow( NULL ), mDisplay( NULL ), mEventQueue( NULL ), mTizenPolicy( NULL ), @@ -232,13 +583,31 @@ WindowBaseEcoreWl::WindowBaseEcoreWl( Window* window, WindowRenderSurface* windo mScreenOffModeChangeDone( true ), mBrightness( 0 ), mBrightnessChangeState( 0 ), - mBrightnessChangeDone( true ) + mBrightnessChangeDone( true ), + mOwnSurface( false ), + mWindowRotationAngle( 0 ), + mScreenRotationAngle( 0 ), + mSupportedPreProtation( 0 ) +#ifdef DALI_ELDBUS_AVAILABLE + , mSystemConnection( NULL ) +#endif { - mWindowSurface = dynamic_cast< WindowRenderSurfaceEcoreWl* >( windowRenderSurface ); + Initialize( positionSize, surface, isTransparent ); } WindowBaseEcoreWl::~WindowBaseEcoreWl() { +#ifdef DALI_ELDBUS_AVAILABLE + // Close down ElDBus connections. + if( mSystemConnection ) + { + eldbus_connection_unref( mSystemConnection ); + } +#endif // DALI_ELDBUS_AVAILABLE + + vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged ); + vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged ); + for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter ) { ecore_event_handler_del( *iter ); @@ -250,141 +619,494 @@ WindowBaseEcoreWl::~WindowBaseEcoreWl() wl_event_queue_destroy( mEventQueue ); } - mSupportedAuxiliaryHints.clear(); - mAuxiliaryHints.clear(); + mSupportedAuxiliaryHints.clear(); + mAuxiliaryHints.clear(); + + if( mEglWindow != NULL ) + { + wl_egl_window_destroy( mEglWindow ); + mEglWindow = NULL; + } + + if( mOwnSurface ) + { + ecore_wl_window_free( mEcoreWindow ); + + WindowSystem::Shutdown(); + } +} + +void WindowBaseEcoreWl::Initialize( PositionSize positionSize, Any surface, bool isTransparent ) +{ + if( surface.Empty() == false ) + { + // check we have a valid type + DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl_Window *) ) && "Surface type is invalid" ); + + mEcoreWindow = AnyCast< Ecore_Wl_Window* >( surface ); + } + else + { + // we own the surface about to created + WindowSystem::Initialize(); + + mOwnSurface = true; + CreateWindow( positionSize ); + } + + mWlSurface = ecore_wl_window_surface_create( mEcoreWindow ); + + SetTransparency( isTransparent ); + + mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) ); + mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) ); + mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) ); + mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) ); + mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) ); + + // Register Rotate event + mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, 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_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) ); + mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_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(); + + mDisplay = ecore_wl_display_get(); + + 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_wl_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, "WindowBaseEcoreWl::Initialize: %s\n", hint ); + } + } +} + +Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event ) +{ + Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) ); + Eina_Bool handled( ECORE_CALLBACK_PASS_ON ); + + if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) ) + { + if( iconifyChangedEvent->iconified == EINA_TRUE ) + { + mIconifyChangedSignal.Emit( true ); + } + else + { + mIconifyChangedSignal.Emit( false ); + } + handled = ECORE_CALLBACK_DONE; + } + + return handled; +} + +Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event ) +{ + Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) ); + + if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" ); + + mFocusChangedSignal.Emit( true ); + } + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event ) +{ + Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) ); + + if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" ); + + mFocusChangedSignal.Emit( false ); + } + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event ) +{ + Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) ); + + if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow ); + + mOutputTransformedSignal.Emit(); + } + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event ) +{ + Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_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 WindowBaseEcoreWl::OnRotation( void* data, int type, void* event ) +{ + Ecore_Wl_Event_Window_Rotate* ev( static_cast< Ecore_Wl_Event_Window_Rotate* >( event ) ); + + if( ev->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::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 WindowBaseEcoreWl::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_wl_window_id_get( mEcoreWindow ) ) ) + { + PointState::Type state ( PointState::DOWN ); + + // 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; + } + + 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( 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 ); + + mTouchEventSignal.Emit( point, touchEvent->timestamp ); + } +} + +void WindowBaseEcoreWl::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_wl_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 ); + + mTouchEventSignal.Emit( point, touchEvent->timestamp ); + } +} + +void WindowBaseEcoreWl::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_wl_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 WindowBaseEcoreWl::Initialize() +void WindowBaseEcoreWl::OnMouseButtonCancel( void* data, int type, void* event ) { - if( !mWindowSurface ) + Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event ); + + if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) { - DALI_ASSERT_ALWAYS( "Invalid window surface" ); - } + Integration::Point point; + point.SetDeviceId( touchEvent->multi.device ); + point.SetState( PointState::INTERRUPTED ); + point.SetScreenPosition( Vector2( 0.0f, 0.0f ) ); - mEcoreWindow = mWindowSurface->GetWlWindow(); - DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no EcoreWl window" ); + mTouchEventSignal.Emit( point, touchEvent->timestamp ); - mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) ); - mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) ); - mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) ); - mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this) ); - mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this) ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" ); + } +} - mDisplay = ecore_wl_display_get(); +void WindowBaseEcoreWl::OnMouseWheel( void* data, int type, void* event ) +{ + Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event ); - if( mDisplay ) + if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) { - 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 ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z ); - wl_registry* registry = wl_display_get_registry( displayWrapper ); - wl_registry_add_listener( registry, ®istryListener, this ); - } + WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp ); - wl_proxy_wrapper_destroy( displayWrapper ); - } + mWheelEventSignal.Emit( wheelEvent ); } +} - // get auxiliary hint - Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEcoreWindow ); - if( hints ) - { - Eina_List* l = NULL; - char* hint = NULL; +void WindowBaseEcoreWl::OnDetentRotation( void* data, int type, void* event ) +{ + Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event ); - 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::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" ); - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint ); - } - } + int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1; + int timeStamp = detentEvent->timestamp; + + WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2( 0.0f, 0.0f ), direction, timeStamp ); + + mWheelEventSignal.Emit( wheelEvent ); } -Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event ) +void WindowBaseEcoreWl::OnKeyDown( void* data, int type, void* event ) { - Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) ); - Eina_Bool handled( ECORE_CALLBACK_PASS_ON ); + Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event ); - if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) ) + if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) { - if( iconifyChangedEvent->iconified == EINA_TRUE ) + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" ); + + std::string keyName( keyEvent->keyname ); + std::string logicalKey( "" ); + std::string keyString( "" ); + std::string compose( "" ); + + // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string. + if( keyEvent->compose ) { - mWindow->OnIconifyChanged( true ); + compose = keyEvent->compose; } - else + + // Ensure key symbol is not NULL as keys like SHIFT have a null string. + if( keyEvent->key ) { - mWindow->OnIconifyChanged( false ); + logicalKey = keyEvent->key; } - handled = ECORE_CALLBACK_DONE; - } - return handled; -} + int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname ); + keyCode = ( keyCode == -1 ) ? 0 : keyCode; + int modifier( keyEvent->modifiers ); + unsigned long time = keyEvent->timestamp; + if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) ) + { + keyCode = atoi( keyEvent->keyname + 8 ); + } -Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event ) -{ - Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) ); + // Ensure key event string is not NULL as keys like SHIFT have a null string. + if( keyEvent->string ) + { + keyString = keyEvent->string; + } - if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) - { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" ); + std::string deviceName; + Device::Class::Type deviceClass; + Device::Subclass::Type deviceSubclass; - mWindow->OnFocusChanged( true ); - } + GetDeviceName( keyEvent, deviceName ); + GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass ); + GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass ); - return ECORE_CALLBACK_PASS_ON; + Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, deviceName, deviceClass, deviceSubclass ); + + mKeyEventSignal.Emit( keyEvent ); + } } -Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event ) +void WindowBaseEcoreWl::OnKeyUp( void* data, int type, void* event ) { - Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) ); + Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event ); - if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) + if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) ) { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" ); + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" ); - mWindow->OnFocusChanged( false ); - } + std::string keyName( keyEvent->keyname ); + std::string logicalKey( "" ); + std::string keyString( "" ); + std::string compose( "" ); - return ECORE_CALLBACK_PASS_ON; -} + // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string. + if( keyEvent->compose ) + { + compose = keyEvent->compose; + } -Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event ) -{ - Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) ); + // Ensure key symbol is not NULL as keys like SHIFT have a null string. + if( keyEvent->key ) + { + logicalKey = keyEvent->key; + } - if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) ) - { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow ); + int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname ); + keyCode = ( keyCode == -1 ) ? 0 : keyCode; + int modifier( keyEvent->modifiers ); + unsigned long time = keyEvent->timestamp; + if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) ) + { + keyCode = atoi( keyEvent->keyname + 8 ); + } + + // Ensure key event string is not NULL as keys like SHIFT have a null string. + if( keyEvent->string ) + { + keyString = keyEvent->string; + } - mWindowSurface->OutputTransformed(); + std::string deviceName; + Device::Class::Type deviceClass; + Device::Subclass::Type deviceSubclass; - mWindow->OnOutputTransformed(); + GetDeviceName( keyEvent, deviceName ); + GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass ); + GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass ); + + Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, deviceName, deviceClass, deviceSubclass ); + + mKeyEventSignal.Emit( keyEvent ); } +} - return ECORE_CALLBACK_PASS_ON; +void WindowBaseEcoreWl::OnDataSend( void* data, int type, void* event ) +{ + mSelectionDataSendSignal.Emit( event ); } -Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event ) +void WindowBaseEcoreWl::OnDataReceive( void* data, int type, void* event ) { - Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) ); + mSelectionDataReceivedSignal.Emit( event ); +} - if( ignoreTransformEvent->win == mEcoreWindow ) - { - DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow ); +void WindowBaseEcoreWl::OnFontNameChanged() +{ + mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE ); +} + +void WindowBaseEcoreWl::OnFontSizeChanged() +{ + mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE ); +} - mWindowSurface->OutputTransformed(); +void WindowBaseEcoreWl::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message ) +{ +#ifdef DALI_ELDBUS_AVAILABLE + AccessibilityInfo info; - mWindow->OnOutputTransformed(); + // The string defines the arg-list's respective types. + if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) ) + { + DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" ); } - return ECORE_CALLBACK_PASS_ON; + mAccessibilitySignal.Emit( info ); +#endif } void WindowBaseEcoreWl::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version ) @@ -452,70 +1174,175 @@ void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone( void* data, struct ti DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state ); } -void WindowBaseEcoreWl::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) +Any WindowBaseEcoreWl::GetNativeWindow() +{ + return mEcoreWindow; +} + +int WindowBaseEcoreWl::GetNativeWindowId() +{ + return ecore_wl_window_id_get( mEcoreWindow ); +} + +EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow( int width, int height ) +{ + mEglWindow = wl_egl_window_create( mWlSurface, width, height ); + + return static_cast< EGLNativeWindowType >( mEglWindow ); +} + +void WindowBaseEcoreWl::DestroyEglWindow() +{ + if( mEglWindow != NULL ) + { + wl_egl_window_destroy( mEglWindow ); + mEglWindow = NULL; + } +} + +void WindowBaseEcoreWl::SetEglWindowRotation( int angle ) { - DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode ); + wl_egl_window_rotation rotation; - if( visibleMode == Dali::Window::VISIBLE ) + switch( angle ) { - // when the indicator is visible, set proper mode for indicator server according to bg mode - if( opacityMode == Dali::Window::OPAQUE ) + case 0: { - ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_OPAQUE ); + rotation = ROTATION_0; + break; } - else if( opacityMode == Dali::Window::TRANSLUCENT ) + case 90: { - ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_TRANSLUCENT ); + rotation = ROTATION_270; + break; } - else if( opacityMode == Dali::Window::TRANSPARENT ) + case 180: { - ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_OPAQUE ); + rotation = ROTATION_180; + break; + } + case 270: + { + rotation = ROTATION_90; + break; + } + default: + { + rotation = ROTATION_0; + break; } } - else - { - // when the indicator is not visible, set TRANSPARENT mode for indicator server - ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_TRANSPARENT); // it means hidden indicator - } + + wl_egl_window_set_rotation( mEglWindow, rotation ); } -void WindowBaseEcoreWl::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) +void WindowBaseEcoreWl::SetEglWindowBufferTransform( int angle ) { - if( isShow ) - { - ecore_wl_window_indicator_state_set( mEcoreWindow, ECORE_WL_INDICATOR_STATE_ON ); - } - else + wl_output_transform bufferTransform; + + switch( angle ) { - ecore_wl_window_indicator_state_set( mEcoreWindow, ECORE_WL_INDICATOR_STATE_OFF ); + case 0: + { + bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL; + break; + } + case 90: + { + bufferTransform = WL_OUTPUT_TRANSFORM_90; + break; + } + case 180: + { + bufferTransform = WL_OUTPUT_TRANSFORM_180; + break; + } + case 270: + { + bufferTransform = WL_OUTPUT_TRANSFORM_270; + break; + } + default: + { + bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL; + break; + } } + + wl_egl_window_set_buffer_transform( mEglWindow, bufferTransform ); } -void WindowBaseEcoreWl::IndicatorTypeChanged( IndicatorInterface::Type type ) +void WindowBaseEcoreWl::SetEglWindowTransform( int angle ) { -#if defined(DALI_PROFILE_MOBILE) - switch( type ) + wl_output_transform windowTransform; + + switch( angle ) { - case IndicatorInterface::INDICATOR_TYPE_1: + case 0: + { + windowTransform = WL_OUTPUT_TRANSFORM_NORMAL; + break; + } + case 90: + { + windowTransform = WL_OUTPUT_TRANSFORM_90; + break; + } + case 180: { - ecore_wl_indicator_visible_type_set( mEcoreWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN ); + windowTransform = WL_OUTPUT_TRANSFORM_180; break; } - case IndicatorInterface::INDICATOR_TYPE_2: + case 270: { - ecore_wl_indicator_visible_type_set( mEcoreWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_HIDDEN ); + windowTransform = WL_OUTPUT_TRANSFORM_270; break; } - case IndicatorInterface::INDICATOR_TYPE_UNKNOWN: default: { + windowTransform = WL_OUTPUT_TRANSFORM_NORMAL; break; } } -#endif //MOBILE + + wl_egl_window_set_window_transform( mEglWindow, windowTransform ); +} + +void WindowBaseEcoreWl::ResizeEglWindow( PositionSize positionSize ) +{ + wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y ); +} + +bool WindowBaseEcoreWl::IsEglWindowRotationSupported() +{ + // Check capability + wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) ); + if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) + { + mSupportedPreProtation = true; + return true; + } + mSupportedPreProtation = false; + return false; +} + +void WindowBaseEcoreWl::Move( PositionSize positionSize ) +{ + ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y ); +} + +void WindowBaseEcoreWl::Resize( PositionSize positionSize ) +{ + ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height ); } -void WindowBaseEcoreWl::SetClass( std::string name, std::string className ) +void WindowBaseEcoreWl::MoveResize( PositionSize positionSize ) +{ + ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y ); + ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height ); +} + +void WindowBaseEcoreWl::SetClass( const std::string& name, const std::string& className ) { ecore_wl_window_title_set( mEcoreWindow, name.c_str() ); ecore_wl_window_class_name_set( mEcoreWindow, className.c_str() ); @@ -1223,6 +2050,140 @@ bool WindowBaseEcoreWl::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dal return true; } +void WindowBaseEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) +{ + // calculate DPI + float xres, yres; + + // 1 inch = 25.4 millimeters + xres = ecore_wl_dpi_get(); + yres = ecore_wl_dpi_get(); + + dpiHorizontal = int( xres + 0.5f ); // rounding + dpiVertical = int( yres + 0.5f ); +} + +int WindowBaseEcoreWl::GetOrientation() const +{ + int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360; + if( mSupportedPreProtation ) + { + orientation = 0; + } + return orientation; +} + +int WindowBaseEcoreWl::GetScreenRotationAngle() +{ + int transform = 0; + + if( ecore_wl_window_ignore_output_transform_get( mEcoreWindow ) ) + { + transform = 0; + } + else + { + transform = ecore_wl_output_transform_get( ecore_wl_window_output_find( mEcoreWindow ) ); + } + + mScreenRotationAngle = transform * 90; + return mScreenRotationAngle; +} + +void WindowBaseEcoreWl::SetWindowRotationAngle( int degree ) +{ + mWindowRotationAngle = degree; + ecore_wl_window_rotation_set( mEcoreWindow, degree ); +} + +int WindowBaseEcoreWl::GetWindowRotationAngle() +{ + return mWindowRotationAngle; +} + +void WindowBaseEcoreWl::WindowRotationCompleted( int degree, int width, int height ) +{ + ecore_wl_window_rotation_change_done_send( mEcoreWindow ); +} + +void WindowBaseEcoreWl::SetTransparency( bool transparent ) +{ + ecore_wl_window_alpha_set( mEcoreWindow, transparent ); +} + +void WindowBaseEcoreWl::InitializeEcoreElDBus() +{ +#ifdef DALI_ELDBUS_AVAILABLE + Eldbus_Object* object; + Eldbus_Proxy* manager; + + if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) ) + { + DALI_LOG_ERROR( "Unable to get system bus\n" ); + } + + object = eldbus_object_get( mSystemConnection, BUS, PATH ); + if( !object ) + { + DALI_LOG_ERROR( "Getting object failed\n" ); + return; + } + + manager = eldbus_proxy_get( object, INTERFACE ); + if( !manager ) + { + DALI_LOG_ERROR( "Getting proxy failed\n" ); + return; + } + + if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) ) + { + DALI_LOG_ERROR( "No signal handler returned\n" ); + } +#endif +} + +void WindowBaseEcoreWl::CreateWindow( PositionSize positionSize ) +{ + mEcoreWindow = ecore_wl_window_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW ); + + if ( mEcoreWindow == 0 ) + { + DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" ); + } +} + +void WindowBaseEcoreWl::SetParent( Any parent ) +{ + Ecore_Wl_Window* mEcoreParent; + if( parent.Empty() == false ) + { + // check we have a valid type + DALI_ASSERT_ALWAYS( ( parent.GetType() == typeid (Ecore_Wl_Window *) ) && "Parent's surface type is invalid" ); + mEcoreParent = AnyCast< Ecore_Wl_Window* >( parent ); + } + else + { + mEcoreParent = NULL; + } + ecore_wl_window_parent_set( mEcoreWindow, mEcoreParent ); +} + +bool WindowBaseEcoreWl::IsMatchedWindow( Any window ) +{ + bool ret = false; + if ( window.Empty() == false ) + { + // check we have a valid type + DALI_ASSERT_ALWAYS( ( window.GetType() == typeid (Ecore_Wl_Window *) ) && "Window's surface type is invalid" ); + if ( AnyCast< Ecore_Wl_Window* >( window ) == mEcoreWindow ) + { + ret = true; + } + } + return ret; +} + } // namespace Adaptor } // namespace Internal