From 2573f2349456ef31c0df63d5f9cefeff5eb8b99f Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Thu, 24 May 2018 19:41:26 +0900 Subject: [PATCH] Support Ecore-Wayland2 Change-Id: I4974e5d0e37d083a82c2e5f63c446bba8b7b85aa --- build/tizen/adaptor/Makefile.am | 25 + build/tizen/adaptor/configure.ac | 16 +- dali/internal/adaptor/tizen/adaptor-impl-tizen.cpp | 18 +- .../tizen-wayland/clipboard-impl-ecore-wl.cpp | 28 +- .../system/tizen/widget-application-impl-tizen.cpp | 6 + dali/internal/window-system/common/window-impl.cpp | 8 +- dali/internal/window-system/file.list | 7 + .../display-connection-impl-ecore-wl.cpp | 14 +- .../ecore-wl2/render-surface-factory-ecore-wl2.cpp | 61 + .../ecore-wl2/render-surface-factory-ecore-wl2.h | 44 + .../ecore-wl2/window-base-ecore-wl2.cpp | 2236 ++++++++++++++++++++ .../ecore-wl2/window-base-ecore-wl2.h | 509 +++++ .../ecore-wl2/window-factory-ecore-wl2.cpp | 52 + .../ecore-wl2/window-factory-ecore-wl2.h | 42 + .../ecore-wl2/window-system-ecore-wl2.cpp | 63 + .../native-render-surface-ecore-wl.cpp | 10 + packaging/dali-adaptor.spec | 16 + 17 files changed, 3142 insertions(+), 13 deletions(-) create mode 100644 dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.cpp create mode 100644 dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.h create mode 100644 dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp create mode 100644 dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h create mode 100644 dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.cpp create mode 100644 dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.h create mode 100644 dali/internal/window-system/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp diff --git a/build/tizen/adaptor/Makefile.am b/build/tizen/adaptor/Makefile.am index aee5843..a6f050c 100644 --- a/build/tizen/adaptor/Makefile.am +++ b/build/tizen/adaptor/Makefile.am @@ -123,8 +123,13 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(static_libraries_glyphy_src_files) \ $(static_libraries_libunibreak_src_files) +if ECORE_WAYLAND2 +LIBDALI_ADAPTOR_LA_SOURCES += \ + $(adaptor_window_system_ecore_wl2_src_files) +else LIBDALI_ADAPTOR_LA_SOURCES += \ $(adaptor_window_system_ecore_wl_src_files) +endif if ENABLE_NETWORK_LOGGING LIBDALI_ADAPTOR_LA_SOURCES += \ @@ -179,8 +184,13 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(static_libraries_glyphy_src_files) \ $(static_libraries_libunibreak_src_files) +if ECORE_WAYLAND2 +LIBDALI_ADAPTOR_LA_SOURCES += \ + $(adaptor_window_system_ecore_wl2_src_files) +else LIBDALI_ADAPTOR_LA_SOURCES += \ $(adaptor_window_system_ecore_wl_src_files) +endif if ENABLE_NETWORK_LOGGING LIBDALI_ADAPTOR_LA_SOURCES += \ @@ -234,8 +244,13 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(static_libraries_glyphy_src_files) \ $(static_libraries_libunibreak_src_files) +if ECORE_WAYLAND2 +LIBDALI_ADAPTOR_LA_SOURCES += \ + $(adaptor_window_system_ecore_wl2_src_files) +else LIBDALI_ADAPTOR_LA_SOURCES += \ $(adaptor_window_system_ecore_wl_src_files) +endif if ENABLE_NETWORK_LOGGING LIBDALI_ADAPTOR_LA_SOURCES += \ @@ -288,8 +303,13 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(static_libraries_glyphy_src_files) \ $(static_libraries_libunibreak_src_files) +if ECORE_WAYLAND2 +LIBDALI_ADAPTOR_LA_SOURCES += \ + $(adaptor_window_system_ecore_wl2_src_files) +else LIBDALI_ADAPTOR_LA_SOURCES += \ $(adaptor_window_system_ecore_wl_src_files) +endif if ENABLE_NETWORK_LOGGING LIBDALI_ADAPTOR_LA_SOURCES += \ @@ -345,8 +365,13 @@ LIBDALI_ADAPTOR_LA_SOURCES = \ $(static_libraries_glyphy_src_files) \ $(static_libraries_libunibreak_src_files) +if ECORE_WAYLAND2 +LIBDALI_ADAPTOR_LA_SOURCES += \ + $(adaptor_window_system_ecore_wl2_src_files) +else LIBDALI_ADAPTOR_LA_SOURCES += \ $(adaptor_window_system_ecore_wl_src_files) +endif if ENABLE_NETWORK_LOGGING LIBDALI_ADAPTOR_LA_SOURCES += \ diff --git a/build/tizen/adaptor/configure.ac b/build/tizen/adaptor/configure.ac index 6cff84b..19ad826 100644 --- a/build/tizen/adaptor/configure.ac +++ b/build/tizen/adaptor/configure.ac @@ -180,6 +180,11 @@ AC_ARG_ENABLE(wayland, enable_wayland=yes, enable_wayland=no) +AC_ARG_ENABLE(ecore_wayland2, + [ --enable-ecore-wayland2 Build on Ecore Wayland2], + enable_ecore_wayland2=yes, + enable_ecore_wayland2=no) + AC_ARG_ENABLE([cxx03_abi], [AC_HELP_STRING([--enable-cxx03-abi], [Specify abi for the build])], @@ -201,6 +206,7 @@ AM_CONDITIONAL([TV_PROFILE], [test x$enable_profile = xTV]) AM_CONDITIONAL([IVI_PROFILE], [test x$enable_profile = xIVI]) AM_CONDITIONAL([UBUNTU_PROFILE], [test x$enable_profile = xUBUNTU]) AM_CONDITIONAL([WAYLAND], [test x$enable_wayland = xyes]) +AM_CONDITIONAL([ECORE_WAYLAND2], [test x$enable_ecore_wayland2 = xyes]) AM_CONDITIONAL([USE_APPFW], [test x$enable_appfw = xyes]) AM_CONDITIONAL([USE_APPFW_EFL_BASE], [test x$enable_tizen_major_version = x3]) AM_CONDITIONAL([ENABLE_CXX03_ABI], [test x$enable_cxx03_abi = xyes]) @@ -298,9 +304,12 @@ fi # Using EFL api's for WAYLAND AND X11 to run on ecore mainloop if test "x$enable_wayland" = "xyes"; then -PKG_CHECK_MODULES(WAYLAND, [ecore-wayland egl wayland-egl wayland-client >= 1.2.0 xkbcommon libtbm], - [DALI_USE_ECORE_WAYLAND=1], - [DALI_USE_ECORE_WAYLAND=0]) + +if test "x$enable_ecore_wayland2" = "xyes"; then +PKG_CHECK_MODULES(WAYLAND, [ecore-wl2 egl wayland-egl wayland-client >= 1.2.0 xkbcommon libtbm]) +else +PKG_CHECK_MODULES(WAYLAND, [ecore-wayland egl wayland-egl wayland-client >= 1.2.0 xkbcommon libtbm]) +fi else PKG_CHECK_MODULES(ECORE_X, [ecore-x], @@ -318,7 +327,6 @@ if test "x$enable_profile" != "xCOMMON"; then PKG_CHECK_MODULES(WAYLAND_EXTENSION, xdg-shell-client text-client input-method-client) fi fi -AM_CONDITIONAL([USE_ECORE_WAYLAND], [test "$DALI_USE_ECORE_WAYLAND" -eq 1]) if test x$DALI_DATA_RW_DIR != x; then dataReadWriteDir=$DALI_DATA_RW_DIR diff --git a/dali/internal/adaptor/tizen/adaptor-impl-tizen.cpp b/dali/internal/adaptor/tizen/adaptor-impl-tizen.cpp index c81f12b..a6c2397 100644 --- a/dali/internal/adaptor/tizen/adaptor-impl-tizen.cpp +++ b/dali/internal/adaptor/tizen/adaptor-impl-tizen.cpp @@ -20,11 +20,18 @@ // EXTERNAL INCLUDES #include +#include + #ifdef APPCORE_WATCH_AVAILABLE #include #endif + +#ifdef ECORE_WAYLAND2 +#include +#else #include -#include +#endif + namespace Dali { @@ -105,8 +112,13 @@ void Adaptor::SurfaceInitialized() // Use strdup() in app_get_id(), so need to free memory if( appId ) { - Ecore_Wl_Window* ecoreWlWindow = AnyCast( mNativeWindow ); - screen_connector_provider_remote_enable(appId, ecore_wl_window_surface_get(ecoreWlWindow)); +#ifdef ECORE_WAYLAND2 + Ecore_Wl2_Window* ecoreWlWindow = AnyCast< Ecore_Wl2_Window* >( mNativeWindow ); + screen_connector_provider_remote_enable( appId, ecore_wl2_window_surface_get( ecoreWlWindow ) ); +#else + Ecore_Wl_Window* ecoreWlWindow = AnyCast< Ecore_Wl_Window* >( mNativeWindow ); + screen_connector_provider_remote_enable( appId, ecore_wl_window_surface_get( ecoreWlWindow ) ); +#endif free( appId ); } #endif diff --git a/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp b/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp index 821a730..77b48de 100644 --- a/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp +++ b/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp @@ -23,7 +23,13 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wold-style-cast" #include + +#ifdef ECORE_WAYLAND2 +#include +#else #include +#endif + #include #include #include @@ -103,21 +109,37 @@ struct Clipboard::Impl // ELM_SEL_TYPE_CLIPBOARD - To distinguish clipboard selection in cbhm types[++i] = "CLIPBOARD_END"; - ecore_wl_dnd_selection_set(ecore_wl_input_get(), types); + +#ifdef ECORE_WAYLAND2 + Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get( ecore_wl2_connected_display_get( NULL ) ); + ecore_wl2_dnd_selection_set( input, types ); +#else + ecore_wl_dnd_selection_set( ecore_wl_input_get(), types ); +#endif } void RequestItem() { +#ifdef ECORE_WAYLAND2 + Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get( ecore_wl2_connected_display_get( NULL ) ); + ecore_wl2_dnd_selection_get( input ); +#else const char *types[10] = {0, }; int i = -1; types[++i] = "text/plain;charset=utf-8"; ecore_wl_dnd_selection_get(ecore_wl_input_get(), *types); +#endif } char *ExcuteSend( void *event ) { +#ifdef ECORE_WAYLAND2 + Ecore_Wl2_Event_Data_Source_Send *ev = (Ecore_Wl2_Event_Data_Source_Send *)event; +#else Ecore_Wl_Event_Data_Source_Send *ev = (Ecore_Wl_Event_Data_Source_Send *)event; +#endif + int len_buf = mSendBuffer.length(); int len_remained = len_buf; int len_written = 0, ret; @@ -137,7 +159,11 @@ struct Clipboard::Impl char *ExcuteReceive( void *event ) { +#ifdef ECORE_WAYLAND2 + Ecore_Wl2_Event_Selection_Data_Ready *ev = (Ecore_Wl2_Event_Selection_Data_Ready *)event; +#else Ecore_Wl_Event_Selection_Data_Ready *ev = (Ecore_Wl_Event_Selection_Data_Ready *)event; +#endif return (char *)ev->data; } diff --git a/dali/internal/system/tizen/widget-application-impl-tizen.cpp b/dali/internal/system/tizen/widget-application-impl-tizen.cpp index 9464f42..b12f417 100644 --- a/dali/internal/system/tizen/widget-application-impl-tizen.cpp +++ b/dali/internal/system/tizen/widget-application-impl-tizen.cpp @@ -51,7 +51,13 @@ int OnInstanceInit(widget_base_instance_h instanceHandle, bundle *content, int w Dali::Window window = application->GetWindow(); window.ShowIndicator(Dali::Window::INVISIBLE); Any nativeHandle = window.GetNativeHandle(); + +#ifdef ECORE_WAYLAND2 + Ecore_Wl2_Window * wlWindow = AnyCast( nativeHandle ); +#else Ecore_Wl_Window * wlWindow = AnyCast( nativeHandle ); +#endif + widget_base_context_window_bind( instanceHandle, id, wlWindow ); window.SetSize( Dali::Window::WindowSize( w, h ) ); diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index 62adc5a..3c385ef 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -61,7 +61,7 @@ Window* Window::New( const PositionSize& positionSize, const std::string& name, Window::Window() : mSurface( NULL ), mWindowBase(), - mIndicatorVisible( Dali::Window::VISIBLE ), + mIndicatorVisible( Dali::Window::INVISIBLE ), // TODO: Enable this after indicator implementation based on tizen 5. mIndicatorIsShown( false ), mShowRotatedIndicatorOnClose( false ), mStarted( false ), @@ -176,7 +176,8 @@ WindowRenderSurface* Window::GetSurface() void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode ) { - mIndicatorVisible = visibleMode; + // TODO: Enable this after indicator implementation based on tizen 5. +// mIndicatorVisible = visibleMode; mWindowBase->ShowIndicator( mIndicatorVisible, mIndicatorOpacityMode ); @@ -195,7 +196,8 @@ void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode void Window::SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode ) { - mIndicatorVisible = mode; + // TODO: Enable this after indicator implementation based on tizen 5. +// mIndicatorVisible = mode; } void Window::RotateIndicator( Dali::Window::WindowOrientation orientation ) diff --git a/dali/internal/window-system/file.list b/dali/internal/window-system/file.list index 4a61900..738a6f3 100644 --- a/dali/internal/window-system/file.list +++ b/dali/internal/window-system/file.list @@ -26,6 +26,13 @@ adaptor_window_system_ecore_wl_src_files=\ ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/window-factory-ecore-wl.cpp \ ${adaptor_window_system_dir}/tizen-wayland/ecore-wl/window-system-ecore-wl.cpp +# module: window-system, backend: ecore-wl2 +adaptor_window_system_ecore_wl2_src_files=\ + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.cpp \ + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp \ + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.cpp \ + ${adaptor_window_system_dir}/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp + # module: window-system, backend: ubuntu-x11 adaptor_window_system_ubuntu_x11_src_files=\ ${adaptor_window_system_dir}/ubuntu-x11/display-connection-factory-x.cpp \ diff --git a/dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.cpp index b4d102f..ca46418 100755 --- a/dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -19,9 +19,14 @@ #include // EXTERNAL_HEADERS -#include #include +#ifdef ECORE_WAYLAND2 +#include +#else +#include +#endif + namespace Dali { @@ -84,7 +89,12 @@ void DisplayConnectionEcoreWl::SetSurfaceType( RenderSurface::Type type ) } else { +#ifdef ECORE_WAYLAND2 + Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL ); + mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl2_display_get( display ) ); +#else mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl_display_get() ); +#endif } } diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.cpp new file mode 100644 index 0000000..e0069a7 --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL HEADERS +#include +#include +#include +#include + +// EXTERNAL INCLUDES +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +std::unique_ptr< WindowRenderSurface > RenderSurfaceFactoryEcoreWl2::CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +{ + return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent ); +} + +std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryEcoreWl2::CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +{ + return std::unique_ptr< PixmapRenderSurface >( nullptr ); +} + +std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreWl2::CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent ) +{ + return Utils::MakeUnique< NativeRenderSurfaceEcoreWl >( positionSize, isTransparent ); +} + +// this should be created from somewhere +std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory() +{ + // returns Window factory + return Utils::MakeUnique< RenderSurfaceFactoryEcoreWl2 >(); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.h new file mode 100644 index 0000000..fbb4eff --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.h @@ -0,0 +1,44 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_RENDER_SURFACE_FACTORY_ECORE_WL2_H +#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_RENDER_SURFACE_FACTORY_ECORE_WL2_H + +/* + * Copyright (c) 2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +class RenderSurfaceFactoryEcoreWl2 : public RenderSurfaceFactory +{ +public: + std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override; + + std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override; + + std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) override; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_RENDER_SURFACE_FACTORY_ECORE_WL2_H diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp new file mode 100644 index 0000000..a4306c7 --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp @@ -0,0 +1,2236 @@ +/* + * Copyright (c) 2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// Ecore is littered with C style cast +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" + +// CLASS HEADER +#include + +// INTERNAL HEADERS +#include +#include +#include +#include + +// EXTERNAL_HEADERS +#include +#include +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace +{ + +#if defined(DEBUG_ENABLED) +Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" ); +#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; + } +#ifdef OVER_TIZEN_VERSION_4 + case ECORE_DEVICE_SUBCLASS_REMOCON: + { + deviceSubclass = Device::Subclass::REMOCON; + break; + } + case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD: + { + deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD; + break; + } +#endif + 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + return windowBase->OnIconifyStateChanged( data, type, event ); + } + + return ECORE_CALLBACK_PASS_ON; +} + +/// Called when the window gains focus +static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + return windowBase->OnFocusIn( data, type, event ); + } + + return ECORE_CALLBACK_PASS_ON; +} + +/// Called when the window loses focus +static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + return windowBase->OnFocusOut( data, type, event ); + } + + return ECORE_CALLBACK_PASS_ON; +} + +/// Called when the output is transformed +static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + return windowBase->OnOutputTransform( data, type, event ); + } + + return ECORE_CALLBACK_PASS_ON; +} + +/// Called when the output transform should be ignored +static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + return windowBase->OnIgnoreOutputTransform( data, type, event ); + } + + return ECORE_CALLBACK_PASS_ON; +} + +/** + * Called when rotate event is recevied. + */ +static Eina_Bool EcoreEventRotate( void* data, int type, void* event ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + windowBase->OnDataReceive( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Indicator Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +#if defined (DALI_PROFILE_MOBILE) + /** + * Called when the Ecore indicator event is received. + */ + static Eina_Bool EcoreEventIndicator( void* data, int type, void* event ) + { + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + windowBase->OnIndicatorFlicked( data, type, event ); + } + return ECORE_CALLBACK_PASS_ON; + } +#endif // DALI_PROFILE_MOBILE + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Font Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when a font name is changed. + */ +static void VconfNotifyFontNameChanged( keynode_t* node, void* data ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + windowBase->OnFontNameChanged(); + } +} + +/** + * Called when a font size is changed. + */ +static void VconfNotifyFontSizeChanged( keynode_t* node, void* data ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + windowBase->RegistryGlobalCallback( data, registry, name, interface, version ); + } +} + +static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + windowBase->RegistryGlobalCallbackRemove( data, registry, id ); + } +} + +static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant ) +{ +} + +static void TizenPolicyConformantArea( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h ) +{ +} + +static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state ); + } +} + +static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId ) +{ +} + +static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state ); + } +} + +static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force ) +{ +} + +static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints ) +{ +} + +static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id ) +{ +} + +static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options ) +{ +} + +static void TizenPolicyConformantRegion( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial ) +{ +} + +static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state ) +{ + WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data ); + if( windowBase ) + { + windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state ); + } +} + +const struct wl_registry_listener registryListener = +{ + RegistryGlobalCallback, + RegistryGlobalCallbackRemove +}; + +const struct tizen_policy_listener tizenPolicyListener = +{ + TizenPolicyConformant, + TizenPolicyConformantArea, + TizenPolicyNotificationChangeDone, + TizenPolicyTransientForDone, + TizenPolicyScreenModeChangeDone, + TizenPolicyIconifyStateChanged, + TizenPolicySupportedAuxiliaryHints, + TizenPolicyAllowedAuxiliaryHint, + TizenPolicyAuxiliaryMessage, + TizenPolicyConformantRegion +}; + +const struct tizen_display_policy_listener tizenDisplayPolicyListener = +{ + DisplayPolicyBrightnessChangeDone +}; + +} // unnamed namespace + +WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +: mEcoreEventHandler(), + mEcoreWindow( NULL ), + mWlSurface( NULL ), + mEglWindow( NULL ), + mDisplay( NULL ), + mEventQueue( NULL ), + mTizenPolicy( NULL ), + mTizenDisplayPolicy( NULL ), + mSupportedAuxiliaryHints(), + mAuxiliaryHints(), + mNotificationLevel( -1 ), + mNotificationChangeState( 0 ), + mNotificationLevelChangeDone( true ), + mScreenOffMode( 0 ), + mScreenOffModeChangeState( 0 ), + mScreenOffModeChangeDone( true ), + mBrightness( 0 ), + mBrightnessChangeState( 0 ), + mBrightnessChangeDone( true ), + mOwnSurface( false ) +#ifdef DALI_ELDBUS_AVAILABLE + , mSystemConnection( NULL ) +#endif +{ + Initialize( positionSize, surface, isTransparent ); +} + +WindowBaseEcoreWl2::~WindowBaseEcoreWl2() +{ +#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 ); + } + mEcoreEventHandler.Clear(); + + if( mEventQueue ) + { + wl_event_queue_destroy( mEventQueue ); + } + + 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 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 ) ); + +#if defined (DALI_PROFILE_MOBILE) + // Register indicator event + mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_INDICATOR_FLICK, EcoreEventIndicator, this ) ); +#endif + + // 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, "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 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 ) ) ) + { + 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 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 ); + + 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, "WindowBaseEcoreWl::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, "WindowBaseEcoreWl::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 ); + } +} + +void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event ) +{ + Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event ); + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" ); + + 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 ); +} + +void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event ) +{ + Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event ); + + if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" ); + + std::string keyName( keyEvent->keyname ); + 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 ) + { + compose = keyEvent->compose; + } + + 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; + } + + std::string deviceName; + Device::Class::Type deviceClass; + Device::Subclass::Type deviceSubclass; + + GetDeviceName( keyEvent, deviceName ); + GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass ); + GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass ); + + Integration::KeyEvent keyEvent( keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, deviceName, deviceClass, deviceSubclass ); + + mKeyEventSignal.Emit( keyEvent ); + } +} + +void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event ) +{ + Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event ); + + if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" ); + + std::string keyName( keyEvent->keyname ); + 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 ) + { + compose = keyEvent->compose; + } + + 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; + } + + std::string deviceName; + Device::Class::Type deviceClass; + Device::Subclass::Type deviceSubclass; + + GetDeviceName( keyEvent, deviceName ); + GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass ); + GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass ); + + Integration::KeyEvent keyEvent( keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, deviceName, deviceClass, deviceSubclass ); + + mKeyEventSignal.Emit( keyEvent ); + } +} + +void WindowBaseEcoreWl2::OnDataSend( void* data, int type, void* event ) +{ + mSelectionDataSendSignal.Emit( event ); +} + +void WindowBaseEcoreWl2::OnDataReceive( void* data, int type, void* event ) +{ + mSelectionDataReceivedSignal.Emit( event ); +} + +void WindowBaseEcoreWl2::OnIndicatorFlicked( void* data, int type, void* event ) +{ + mIndicatorFlickedSignal.Emit(); +} + +void WindowBaseEcoreWl2::OnFontNameChanged() +{ + mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE ); +} + +void WindowBaseEcoreWl2::OnFontSizeChanged() +{ + mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE ); +} + +void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message ) +{ +#ifdef DALI_ELDBUS_AVAILABLE + AccessibilityInfo info; + + // 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" ); + } + + mAccessibilitySignal.Emit( info ); +#endif +} + +void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version ) +{ + if( strcmp( interface, tizen_policy_interface.name ) == 0 ) + { + uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION ); + + mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) ); + if( !mTizenPolicy ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" ); + return; + } + + tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data ); + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" ); + } + else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 ) + { + mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) ); + if( !mTizenDisplayPolicy ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" ); + return; + } + + tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data ); + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" ); + } +} + +void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id ) +{ + mTizenPolicy = NULL; + mTizenDisplayPolicy = NULL; +} + +void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state ) +{ + mNotificationLevel = level; + mNotificationChangeState = state; + mNotificationLevelChangeDone = true; + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state ); +} + +void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state ) +{ + mScreenOffMode = mode; + mScreenOffModeChangeState = state; + mScreenOffModeChangeDone = true; + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state ); +} + +void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state ) +{ + mBrightness = brightness; + mBrightnessChangeState = state; + mBrightnessChangeDone = true; + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state ); +} + +Any WindowBaseEcoreWl2::GetNativeWindow() +{ + return mEcoreWindow; +} + +int WindowBaseEcoreWl2::GetNativeWindowId() +{ + return ecore_wl2_window_id_get( mEcoreWindow ); +} + +EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow( int width, int height ) +{ + mEglWindow = wl_egl_window_create( mWlSurface, width, height ); + + return static_cast< EGLNativeWindowType >( mEglWindow ); +} + +void WindowBaseEcoreWl2::DestroyEglWindow() +{ + if( mEglWindow != NULL ) + { + wl_egl_window_destroy( mEglWindow ); + mEglWindow = NULL; + } +} + +void WindowBaseEcoreWl2::SetEglWindowRotation( int angle ) +{ + wl_egl_window_rotation rotation; + + switch( angle ) + { + case 0: + { + rotation = ROTATION_0; + break; + } + case 90: + { + rotation = ROTATION_270; + break; + } + case 180: + { + rotation = ROTATION_180; + break; + } + case 270: + { + rotation = ROTATION_90; + break; + } + default: + { + rotation = ROTATION_0; + break; + } + } + + wl_egl_window_set_rotation( mEglWindow, rotation ); +} + +void WindowBaseEcoreWl2::SetEglWindowBufferTransform( int angle ) +{ + wl_output_transform bufferTransform; + + switch( angle ) + { + 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 WindowBaseEcoreWl2::SetEglWindowTransform( int angle ) +{ + wl_output_transform windowTransform; + + switch( angle ) + { + case 0: + { + windowTransform = WL_OUTPUT_TRANSFORM_NORMAL; + break; + } + case 90: + { + windowTransform = WL_OUTPUT_TRANSFORM_90; + break; + } + case 180: + { + windowTransform = WL_OUTPUT_TRANSFORM_180; + break; + } + case 270: + { + windowTransform = WL_OUTPUT_TRANSFORM_270; + break; + } + default: + { + windowTransform = WL_OUTPUT_TRANSFORM_NORMAL; + break; + } + } + + wl_egl_window_set_window_transform( mEglWindow, windowTransform ); +} + +void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize ) +{ + wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y ); +} + +bool WindowBaseEcoreWl2::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 ) + { + return true; + } + + return false; +} + +void WindowBaseEcoreWl2::Move( PositionSize positionSize ) +{ + ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height ); +} + +void WindowBaseEcoreWl2::Resize( PositionSize positionSize ) +{ + ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height ); +} + +void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize ) +{ + ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height ); +} + +void WindowBaseEcoreWl2::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) +{ + DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode ); + + if( visibleMode == Dali::Window::VISIBLE ) + { + // when the indicator is visible, set proper mode for indicator server according to bg mode + if( opacityMode == Dali::Window::OPAQUE ) + { + ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_OPAQUE ); + } + else if( opacityMode == Dali::Window::TRANSLUCENT ) + { + ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_TRANSLUCENT ); + } + else if( opacityMode == Dali::Window::TRANSPARENT ) + { + ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_OPAQUE ); + } + } + else + { + // when the indicator is not visible, set TRANSPARENT mode for indicator server + ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_TRANSPARENT); // it means hidden indicator + } +} + +void WindowBaseEcoreWl2::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) +{ + if( isShow ) + { + ecore_wl2_window_indicator_state_set( mEcoreWindow, ECORE_WL2_INDICATOR_STATE_ON ); + } + else + { + ecore_wl2_window_indicator_state_set( mEcoreWindow, ECORE_WL2_INDICATOR_STATE_OFF ); + } +} + +void WindowBaseEcoreWl2::IndicatorTypeChanged( IndicatorInterface::Type type ) +{ +#if defined(DALI_PROFILE_MOBILE) + switch( type ) + { + case IndicatorInterface::INDICATOR_TYPE_1: + { + ecore_wl2_indicator_visible_type_set( mEcoreWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN ); + break; + } + case IndicatorInterface::INDICATOR_TYPE_2: + { + ecore_wl2_indicator_visible_type_set( mEcoreWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_HIDDEN ); + break; + } + case IndicatorInterface::INDICATOR_TYPE_UNKNOWN: + default: + { + break; + } + } +#endif //MOBILE +} + +void WindowBaseEcoreWl2::SetClass( const std::string& name, const std::string& className ) +{ + ecore_wl2_window_title_set( mEcoreWindow, name.c_str() ); + ecore_wl2_window_class_set( mEcoreWindow, className.c_str() ); +} + +void WindowBaseEcoreWl2::Raise() +{ + // Use ecore_wl2_window_activate to prevent the window shown without rendering + ecore_wl2_window_activate( mEcoreWindow ); +} + +void WindowBaseEcoreWl2::Lower() +{ + ecore_wl2_window_lower( mEcoreWindow ); +} + +void WindowBaseEcoreWl2::Activate() +{ + ecore_wl2_window_activate( mEcoreWindow ); +} + +void WindowBaseEcoreWl2::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) +{ + int rotations[4] = { 0 }; + for( std::size_t i = 0; i < orientations.size(); ++i ) + { + rotations[i] = static_cast< int >( orientations[i] ); + } + ecore_wl2_window_available_rotations_set( mEcoreWindow, rotations, orientations.size() ); +} + +void WindowBaseEcoreWl2::SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) +{ + ecore_wl2_window_preferred_rotation_set( mEcoreWindow, orientation ); +} + +void WindowBaseEcoreWl2::SetAcceptFocus( bool accept ) +{ + ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept ); +} + +void WindowBaseEcoreWl2::Show() +{ + ecore_wl2_window_show( mEcoreWindow ); +} + +void WindowBaseEcoreWl2::Hide() +{ + ecore_wl2_window_hide( mEcoreWindow ); +} + +unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const +{ + return mSupportedAuxiliaryHints.size(); +} + +std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const +{ + if( index >= GetSupportedAuxiliaryHintCount() ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index ); + } + + return mSupportedAuxiliaryHints[index]; +} + +unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value ) +{ + bool supported = false; + + // Check if the hint is suppported + for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter ) + { + if( *iter == hint ) + { + supported = true; + break; + } + } + + if( !supported ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() ); + return 0; + } + + // Check if the hint is already added + for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ ) + { + if( mAuxiliaryHints[i].first == hint ) + { + // Just change the value + mAuxiliaryHints[i].second = value; + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 ); + + return i + 1; // id is index + 1 + } + } + + // Add the hint + mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) ); + + unsigned int id = mAuxiliaryHints.size(); + + ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() ); + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id ); + + return id; +} + +bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id ) +{ + if( id == 0 || id > mAuxiliaryHints.size() ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id ); + return false; + } + + mAuxiliaryHints[id - 1].second = std::string(); + + ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) ); + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() ); + + return true; +} + +bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value ) +{ + if( id == 0 || id > mAuxiliaryHints.size() ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id ); + return false; + } + + mAuxiliaryHints[id - 1].second = value; + + ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() ); + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() ); + + return true; +} + +std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const +{ + if( id == 0 || id > mAuxiliaryHints.size() ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id ); + return std::string(); + } + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() ); + + return mAuxiliaryHints[id - 1].second; +} + +unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const +{ + for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ ) + { + if( mAuxiliaryHints[i].first == hint ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 ); + return i + 1; + } + } + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() ); + + return 0; +} + +void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion ) +{ + ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height ); +} + +void WindowBaseEcoreWl2::SetType( Dali::Window::Type type ) +{ + Ecore_Wl2_Window_Type windowType; + + switch( type ) + { + case Dali::Window::NORMAL: + { + windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL; + break; + } + case Dali::Window::NOTIFICATION: + { + windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION; + break; + } + case Dali::Window::UTILITY: + { + windowType = ECORE_WL2_WINDOW_TYPE_UTILITY; + break; + } + case Dali::Window::DIALOG: + { + windowType = ECORE_WL2_WINDOW_TYPE_DIALOG; + break; + } + default: + { + windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL; + break; + } + } + + ecore_wl2_window_type_set( mEcoreWindow, windowType ); +} + +bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) +{ + while( !mTizenPolicy ) + { + wl_display_dispatch_queue( mDisplay, mEventQueue ); + } + + int notificationLevel; + + switch( level ) + { + case Dali::Window::NotificationLevel::NONE: + { + notificationLevel = TIZEN_POLICY_LEVEL_NONE; + break; + } + case Dali::Window::NotificationLevel::BASE: + { + notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT; + break; + } + case Dali::Window::NotificationLevel::MEDIUM: + { + notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM; + break; + } + case Dali::Window::NotificationLevel::HIGH: + { + notificationLevel = TIZEN_POLICY_LEVEL_HIGH; + break; + } + case Dali::Window::NotificationLevel::TOP: + { + notificationLevel = TIZEN_POLICY_LEVEL_TOP; + break; + } + default: + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level ); + notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT; + break; + } + } + + mNotificationLevelChangeDone = false; + mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE; + + tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel ); + + int count = 0; + + while( !mNotificationLevelChangeDone && count < 3 ) + { + ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) ); + wl_display_dispatch_queue( mDisplay, mEventQueue ); + count++; + } + + if( !mNotificationLevelChangeDone ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState ); + return false; + } + else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level ); + return false; + } + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel ); + + return true; +} + +Dali::Window::NotificationLevel::Type WindowBaseEcoreWl2::GetNotificationLevel() const +{ + while( !mTizenPolicy ) + { + wl_display_dispatch_queue( mDisplay, mEventQueue ); + } + + int count = 0; + + while( !mNotificationLevelChangeDone && count < 3 ) + { + ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) ); + wl_display_dispatch_queue( mDisplay, mEventQueue ); + count++; + } + + if( !mNotificationLevelChangeDone ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState ); + return Dali::Window::NotificationLevel::NONE; + } + + Dali::Window::NotificationLevel::Type level; + + switch( mNotificationLevel ) + { + case TIZEN_POLICY_LEVEL_NONE: + { + level = Dali::Window::NotificationLevel::NONE; + break; + } + case TIZEN_POLICY_LEVEL_DEFAULT: + { + level = Dali::Window::NotificationLevel::BASE; + break; + } + case TIZEN_POLICY_LEVEL_MEDIUM: + { + level = Dali::Window::NotificationLevel::MEDIUM; + break; + } + case TIZEN_POLICY_LEVEL_HIGH: + { + level = Dali::Window::NotificationLevel::HIGH; + break; + } + case TIZEN_POLICY_LEVEL_TOP: + { + level = Dali::Window::NotificationLevel::TOP; + break; + } + default: + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel ); + level = Dali::Window::NotificationLevel::NONE; + break; + } + } + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel ); + + return level; +} + +void WindowBaseEcoreWl2::SetOpaqueState( bool opaque ) +{ + while( !mTizenPolicy ) + { + wl_display_dispatch_queue( mDisplay, mEventQueue ); + } + + tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) ); +} + +bool WindowBaseEcoreWl2::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) +{ + while( !mTizenPolicy ) + { + wl_display_dispatch_queue( mDisplay, mEventQueue ); + } + + mScreenOffModeChangeDone = false; + mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE; + + unsigned int mode = 0; + + switch( screenOffMode ) + { + case Dali::Window::ScreenOffMode::TIMEOUT: + { + mode = 0; + break; + } + case Dali::Window::ScreenOffMode::NEVER: + { + mode = 1; + break; + } + } + + tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode ); + + int count = 0; + + while( !mScreenOffModeChangeDone && count < 3 ) + { + ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) ); + wl_display_dispatch_queue( mDisplay, mEventQueue ); + count++; + } + + if( !mScreenOffModeChangeDone ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState ); + return false; + } + else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode ); + return false; + } + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode ); + + return true; +} + +Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl2::GetScreenOffMode() const +{ + while( !mTizenPolicy ) + { + wl_display_dispatch_queue( mDisplay, mEventQueue ); + } + + int count = 0; + + while( !mScreenOffModeChangeDone && count < 3 ) + { + ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) ); + wl_display_dispatch_queue( mDisplay, mEventQueue ); + count++; + } + + if( !mScreenOffModeChangeDone ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState ); + return Dali::Window::ScreenOffMode::TIMEOUT; + } + + Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT; + + switch( mScreenOffMode ) + { + case 0: + { + screenMode = Dali::Window::ScreenOffMode::TIMEOUT; + break; + } + case 1: + { + screenMode = Dali::Window::ScreenOffMode::NEVER; + break; + } + } + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode ); + + return screenMode; +} + +bool WindowBaseEcoreWl2::SetBrightness( int brightness ) +{ + while( !mTizenDisplayPolicy ) + { + wl_display_dispatch_queue( mDisplay, mEventQueue ); + } + + mBrightnessChangeDone = false; + mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE; + + tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness ); + + int count = 0; + + while( !mBrightnessChangeDone && count < 3 ) + { + ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) ); + wl_display_dispatch_queue( mDisplay, mEventQueue ); + count++; + } + + if( !mBrightnessChangeDone ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState ); + return false; + } + else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness ); + return false; + } + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness ); + + return true; +} + +int WindowBaseEcoreWl2::GetBrightness() const +{ + while( !mTizenDisplayPolicy ) + { + wl_display_dispatch_queue( mDisplay, mEventQueue ); + } + + int count = 0; + + while( !mBrightnessChangeDone && count < 3 ) + { + ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) ); + wl_display_dispatch_queue( mDisplay, mEventQueue ); + count++; + } + + if( !mBrightnessChangeDone ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState ); + return 0; + } + + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness ); + + return mBrightness; +} + +bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) +{ + Ecore_Wl2_Window_Keygrab_Mode mode; + + switch( grabMode ) + { + case KeyGrab::TOPMOST: + { + mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST; + break; + } + case KeyGrab::SHARED: + { + mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED; + break; + } + case KeyGrab::OVERRIDE_EXCLUSIVE: + { + mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE; + break; + } + case KeyGrab::EXCLUSIVE: + { + mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE; + break; + } + default: + { + return false; + } + } + + return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode ); +} + +bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key ) +{ + return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 ); +} + +bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) +{ + int keyCount = key.Count(); + int keyGrabModeCount = grabMode.Count(); + + if( keyCount != keyGrabModeCount || keyCount == 0 ) + { + return false; + } + + eina_init(); + + Eina_List* keyList = NULL; + Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount]; + + for( int index = 0; index < keyCount; ++index ) + { + info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) ); + + switch( grabMode[index] ) + { + case KeyGrab::TOPMOST: + { + info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST; + break; + } + case KeyGrab::SHARED: + { + info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED; + break; + } + case KeyGrab::OVERRIDE_EXCLUSIVE: + { + info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE; + break; + } + case KeyGrab::EXCLUSIVE: + { + info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE; + break; + } + default: + { + info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN; + break; + } + } + + keyList = eina_list_append( keyList, &info ); + } + + Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList ); + + result.Resize( keyCount, true ); + + Eina_List* l = NULL; + Eina_List* m = NULL; + void* listData = NULL; + void* data = NULL; + if( grabList != NULL ) + { + EINA_LIST_FOREACH( grabList, m, data ) + { + int index = 0; + EINA_LIST_FOREACH( keyList, l, listData ) + { + if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL ) + { + DALI_LOG_ERROR( "input key list has null data!" ); + break; + } + + if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 ) + { + result[index] = false; + } + ++index; + } + } + } + + delete [] info; + + eina_list_free( keyList ); + eina_list_free( grabList ); + eina_shutdown(); + + return true; +} + +bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) +{ + int keyCount = key.Count(); + if( keyCount == 0 ) + { + return false; + } + + eina_init(); + + Eina_List* keyList = NULL; + Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount]; + + for( int index = 0; index < keyCount; ++index ) + { + info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) ); + keyList = eina_list_append( keyList, &info ); + } + + Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList ); + + result.Resize( keyCount, true ); + + Eina_List* l = NULL; + Eina_List* m = NULL; + void *listData = NULL; + void *data = NULL; + + if( ungrabList != NULL ) + { + EINA_LIST_FOREACH( ungrabList, m, data ) + { + int index = 0; + EINA_LIST_FOREACH( keyList, l, listData ) + { + if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 ) + { + result[index] = false; + } + ++index; + } + } + } + + delete [] info; + + eina_list_free( keyList ); + eina_list_free( ungrabList ); + eina_shutdown(); + + return true; +} + +void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) +{ + // calculate DPI + float xres, yres; + + Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mEcoreWindow ); + + // 1 inch = 25.4 millimeters + xres = ecore_wl2_output_dpi_get( output ); + yres = ecore_wl2_output_dpi_get( output ); + + dpiHorizontal = int( xres + 0.5f ); // rounding + dpiVertical = int( yres + 0.5f ); +} + +void WindowBaseEcoreWl2::SetViewMode( ViewMode viewMode ) +{ +} + +int WindowBaseEcoreWl2::GetScreenRotationAngle() +{ + int transform = 0; + + if( ecore_wl2_window_ignore_output_transform_get( mEcoreWindow ) ) + { + transform = 0; + } + else + { + transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mEcoreWindow ) ); + } + + return transform * 90; +} + +void WindowBaseEcoreWl2::SetWindowRotationAngle( int degree ) +{ + ecore_wl2_window_rotation_set( mEcoreWindow, degree ); +} + +void WindowBaseEcoreWl2::WindowRotationCompleted( int degree, int width, int height ) +{ + ecore_wl2_window_rotation_change_done_send( mEcoreWindow, degree, width, height ); +} + +void WindowBaseEcoreWl2::SetTransparency( bool transparent ) +{ + ecore_wl2_window_alpha_set( mEcoreWindow, transparent ); +} + +void WindowBaseEcoreWl2::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 WindowBaseEcoreWl2::CreateWindow( PositionSize positionSize ) +{ + Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL ); + if( !display ) + { + DALI_ASSERT_ALWAYS( 0 && "Failed to get display" ); + } + + mEcoreWindow = ecore_wl2_window_new( display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height ); + + if ( mEcoreWindow == 0 ) + { + DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" ); + } + + // Set default type + ecore_wl2_window_type_set( mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL ); +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#pragma GCC diagnostic pop diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h new file mode 100644 index 0000000..246bd3a --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h @@ -0,0 +1,509 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H +#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H + +/* + * Copyright (c) 2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include + +// EXTERNAL HEADERS +#include +#include +#include +#include + +#ifdef DALI_ELDBUS_AVAILABLE +#include +#endif + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +class WindowRenderSurface; +class WindowRenderSurfaceEcoreWl2; + +/** + * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation. + */ +class WindowBaseEcoreWl2 : public WindowBase +{ +public: + + /** + * @brief Constructor + */ + WindowBaseEcoreWl2( PositionSize positionSize, Any surface, bool isTransparent ); + + /** + * @brief Destructor + */ + virtual ~WindowBaseEcoreWl2(); + +public: + + /** + * @brief Called when the window iconify state is changed. + */ + Eina_Bool OnIconifyStateChanged( void* data, int type, void* event ); + + /** + * @brief Called when the window gains focus. + */ + Eina_Bool OnFocusIn( void* data, int type, void* event ); + + /** + * @brief Called when the window loses focus. + */ + Eina_Bool OnFocusOut( void* data, int type, void* event ); + + /** + * @brief Called when the output is transformed. + */ + Eina_Bool OnOutputTransform( void* data, int type, void* event ); + + /** + * @brief Called when the output transform should be ignored. + */ + Eina_Bool OnIgnoreOutputTransform( void* data, int type, void* event ); + + /** + * @brief Called when a rotation event is recevied. + */ + void OnRotation( void* data, int type, void* event ); + + /** + * @brief Called when a touch down is received. + */ + void OnMouseButtonDown( void* data, int type, void* event ); + + /** + * @brief Called when a touch up is received. + */ + void OnMouseButtonUp( void* data, int type, void* event ); + + /** + * @brief Called when a touch motion is received. + */ + void OnMouseButtonMove( void* data, int type, void* event ); + + /** + * @brief Called when a touch is canceled. + */ + void OnMouseButtonCancel( void* data, int type, void* event ); + + /** + * @brief Called when a mouse wheel is received. + */ + void OnMouseWheel( void* data, int type, void* event ); + + /** + * @brief Called when a detent rotation event is recevied. + */ + void OnDetentRotation( void* data, int type, void* event ); + + /** + * @brief Called when a key down is received. + */ + void OnKeyDown( void* data, int type, void* event ); + + /** + * @brief Called when a key up is received. + */ + void OnKeyUp( void* data, int type, void* event ); + + /** + * @brief Called when the source window notifies us the content in clipboard is selected. + */ + void OnDataSend( void* data, int type, void* event ); + + /** + * @brief Called when the source window sends us about the selected content. + */ + void OnDataReceive( void* data, int type, void* event ); + + /** + * @brief Called when the indicator event is received. + */ + void OnIndicatorFlicked( void* data, int type, void* event ); + + /** + * @brief Called when a font name is changed. + */ + void OnFontNameChanged(); + + /** + * @brief Called when a font size is changed. + */ + void OnFontSizeChanged(); + +#ifdef DALI_ELDBUS_AVAILABLE + /** + * @brief Called when Ecore ElDBus accessibility event is received. + */ + void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message ); +#endif + + /** + * @brief RegistryGlobalCallback + */ + void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version ); + + /** + * @brief RegistryGlobalCallbackRemove + */ + void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id ); + + /** + * @brief TizenPolicyNotificationChangeDone + */ + void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state ); + + /** + * @brief TizenPolicyScreenModeChangeDone + */ + void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state ); + + /** + * @brief DisplayPolicyBrightnessChangeDone + */ + void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state ); + +public: + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow() + */ + virtual Any GetNativeWindow() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId() + */ + virtual int GetNativeWindowId() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow() + */ + virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow() + */ + virtual void DestroyEglWindow() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation() + */ + virtual void SetEglWindowRotation( int angle ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform() + */ + virtual void SetEglWindowBufferTransform( int angle ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform() + */ + virtual void SetEglWindowTransform( int angle ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow() + */ + virtual void ResizeEglWindow( PositionSize positionSize ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported() + */ + virtual bool IsEglWindowRotationSupported() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Move() + */ + virtual void Move( PositionSize positionSize ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Resize() + */ + virtual void Resize( PositionSize positionSize ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize() + */ + virtual void MoveResize( PositionSize positionSize ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::ShowIndicator() + */ + virtual void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetIndicatorProperties() + */ + virtual void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::IndicatorTypeChanged() + */ + virtual void IndicatorTypeChanged( IndicatorInterface::Type type ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() + */ + virtual void SetClass( const std::string& name, const std::string& className ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Raise() + */ + virtual void Raise() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Lower() + */ + virtual void Lower() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Activate() + */ + virtual void Activate() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableOrientations() + */ + virtual void SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredOrientation() + */ + virtual void SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus() + */ + virtual void SetAcceptFocus( bool accept ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Show() + */ + virtual void Show() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Hide() + */ + virtual void Hide() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount() + */ + virtual unsigned int GetSupportedAuxiliaryHintCount() const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint() + */ + virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint() + */ + virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint() + */ + virtual bool RemoveAuxiliaryHint( unsigned int id ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue() + */ + virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue() + */ + virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId() + */ + virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion() + */ + virtual void SetInputRegion( const Rect< int >& inputRegion ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetType() + */ + virtual void SetType( Dali::Window::Type type ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel() + */ + virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel() + */ + virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState() + */ + virtual void SetOpaqueState( bool opaque ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode() + */ + virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode() + */ + virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness() + */ + virtual bool SetBrightness( int brightness ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness() + */ + virtual int GetBrightness() const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey() + */ + virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey() + */ + virtual bool UngrabKey( Dali::KEY key ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList() + */ + virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList() + */ + virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi() + */ + virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetViewMode() + */ + virtual void SetViewMode( ViewMode viewMode ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle() + */ + virtual int GetScreenRotationAngle() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle() + */ + virtual void SetWindowRotationAngle( int degree ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted() + */ + virtual void WindowRotationCompleted( int degree, int width, int height ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency() + */ + virtual void SetTransparency( bool transparent ) override; + +private: + + /** + * Second stage initialization + */ + void Initialize( PositionSize positionSize, Any surface, bool isTransparent ); + + /** + * Initialize Ecore ElDBus + */ + void InitializeEcoreElDBus(); + + /** + * @brief Create window + */ + void CreateWindow( PositionSize positionSize ); + +protected: + + // Undefined + WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete; + + // Undefined + WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete; + +private: + + typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints; + + Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler; + + Ecore_Wl2_Window* mEcoreWindow; + wl_surface* mWlSurface; + wl_egl_window* mEglWindow; + wl_display* mDisplay; + wl_event_queue* mEventQueue; + tizen_policy* mTizenPolicy; + tizen_display_policy* mTizenDisplayPolicy; + + std::vector< std::string > mSupportedAuxiliaryHints; + AuxiliaryHints mAuxiliaryHints; + + int mNotificationLevel; + uint32_t mNotificationChangeState; + bool mNotificationLevelChangeDone; + + int mScreenOffMode; + uint32_t mScreenOffModeChangeState; + bool mScreenOffModeChangeDone; + + int mBrightness; + uint32_t mBrightnessChangeState; + bool mBrightnessChangeDone; + + bool mOwnSurface; + +#ifdef DALI_ELDBUS_AVAILABLE + Eldbus_Connection* mSystemConnection; +#endif // DALI_ELDBUS_AVAILABLE +}; + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.cpp new file mode 100644 index 0000000..585de90 --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL HEADERS +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +std::unique_ptr< WindowBase > WindowFactoryEcoreWl2::CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +{ + return Utils::MakeUnique< WindowBaseEcoreWl2 >( positionSize, surface, isTransparent ); +} + +std::unique_ptr< IndicatorInterface > WindowFactoryEcoreWl2::CreateIndicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, IndicatorInterface::Observer* observer ) +{ + return Utils::MakeUnique< IndicatorEcoreWl >( adaptor, orientation, observer ); +} + +// this should be created from Window impl +std::unique_ptr< WindowFactory > GetWindowFactory() +{ + // returns Window factory + return Utils::MakeUnique< WindowFactoryEcoreWl2 >(); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.h b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.h new file mode 100644 index 0000000..6810242 --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.h @@ -0,0 +1,42 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_FACTORY_ECORE_WL2_H +#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_FACTORY_ECORE_WL2_H + +/* + * Copyright (c) 2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +class WindowFactoryEcoreWl2 : public WindowFactory +{ +public: + std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) override; + + std::unique_ptr< IndicatorInterface > CreateIndicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, IndicatorInterface::Observer* observer ) override; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_FACTORY_ECORE_WL2_H diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp new file mode 100644 index 0000000..5ccf6cd --- /dev/null +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-system-ecore-wl2.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL HEADERS +#include + +// EXTERNAL_HEADERS +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace WindowSystem +{ + +void Initialize() +{ + ecore_wl2_init(); +} + +void Shutdown() +{ + ecore_wl2_shutdown(); +} + +void GetScreenSize( int& width, int& height ) +{ + Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL ); + if( display ) + { + ecore_wl2_display_screen_size_get( display, &width, &height ); + } +} + +} // namespace WindowSystem + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#pragma GCC diagnostic pop diff --git a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp index c3fb051..8722ceb 100644 --- a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp @@ -22,7 +22,11 @@ #include #include +#ifdef ECORE_WAYLAND2 +#include +#else #include +#endif #include #include @@ -113,8 +117,14 @@ void NativeRenderSurfaceEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned i float xres, yres; // 1 inch = 25.4 millimeters +#ifdef ECORE_WAYLAND2 + // TODO: Application should set dpi value in wayland2 + xres = 96; + yres = 96; +#else xres = ecore_wl_dpi_get(); yres = ecore_wl_dpi_get(); +#endif dpiHorizontal = int( xres + 0.5f ); // rounding dpiVertical = int( yres + 0.5f ); diff --git a/packaging/dali-adaptor.spec b/packaging/dali-adaptor.spec index 94795fa..882b63c 100644 --- a/packaging/dali-adaptor.spec +++ b/packaging/dali-adaptor.spec @@ -96,7 +96,11 @@ BuildRequires: wayland-devel BuildRequires: wayland-extension-client-devel # dali-adaptor uses ecore mainloop +%if 0%{?tizen_version_major} >= 5 +BuildRequires: pkgconfig(ecore-wl2) +%else BuildRequires: pkgconfig(ecore-wayland) +%endif # dali-adaptor needs tbm_surface in tizen 3.0 wayland BuildRequires: pkgconfig(libtbm) @@ -426,6 +430,18 @@ CXXFLAGS+=" -D_ARCH_ARM_ -lgcc" CFLAGS+=" -DWAYLAND" CXXFLAGS+=" -DWAYLAND" configure_flags="--enable-wayland" + +# Need Ecore-Wayland2 when Tizen version is 5.x or greater +%if 0%{?tizen_version_major} >= 5 +CFLAGS+=" -DECORE_WAYLAND2 -DEFL_BETA_API_SUPPORT" +CXXFLAGS+=" -DECORE_WAYLAND2 -DEFL_BETA_API_SUPPORT" +configure_flags+=" --enable-ecore-wayland2" +%endif +%endif + +# Use this conditional when Tizen version is 5.x or greater +%if 0%{?tizen_version_major} >= 5 +CXXFLAGS+=" -DOVER_TIZEN_VERSION_5" %endif # Use this conditional when Tizen version is 4.x or greater -- 2.7.4