# wayland
-adaptor_wayland_tizen_internal_src_files = \
+adaptor_ecore_wayland_tizen_internal_src_files = \
$(adaptor_ecore_wayland_dir)/clipboard-impl-ecore-wl.cpp \
$(adaptor_ecore_wayland_dir)/display-connection-impl-ecore-wl.cpp \
$(adaptor_ecore_wayland_dir)/event-handler-ecore-wl.cpp \
$(adaptor_ecore_wayland_dir)/window-impl-ecore-wl.cpp \
$(adaptor_ecore_wayland_dir)/window-render-surface-ecore-wl.cpp
-adaptor_wayland_tizen_common_internal_default_profile_src_files = \
+adaptor_ecore_wayland_tizen_common_internal_default_profile_src_files = \
$(adaptor_ecore_wayland_dir)/render-surface-factory-ecore-wl.cpp \
$(adaptor_ecore_wayland_dir)/system-settings-ecore-wl.cpp
--- /dev/null
+# libuv
+adaptor_tizen_framework_libuv_src_files = $(adaptor_libuv_dir)/framework-libuv.cpp
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "framework.h"
+
+// EXTERNAL INCLUDES
+#include <uv.h>
+
+
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <callback-manager.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+
+/**
+ * Impl to hide LibUV data members
+ */
+struct Framework::Impl
+{
+ // Constructor
+
+ Impl(void* data)
+ : mAbortCallBack( NULL ),
+ mCallbackManager( NULL )
+ {
+ mCallbackManager = CallbackManager::New();
+ mMainLoop = new uv_loop_t;
+ uv_loop_init( mMainLoop );
+
+ }
+
+ ~Impl()
+ {
+ delete mAbortCallBack;
+
+ // we're quiting the main loop so
+ // mCallbackManager->RemoveAllCallBacks() does not need to be called
+ // to delete our abort handler
+ delete mCallbackManager;
+
+ delete mMainLoop;
+ }
+
+ void Run()
+ {
+ uv_run( mMainLoop , UV_RUN_DEFAULT);
+
+ uv_loop_close( mMainLoop );
+
+ }
+
+ void Quit()
+ {
+ uv_stop( mMainLoop );
+ }
+
+ // Data
+
+ CallbackBase* mAbortCallBack;
+ CallbackManager *mCallbackManager;
+ uv_loop_t* mMainLoop;
+
+
+private:
+ // Undefined
+ Impl( const Impl& impl );
+
+ // Undefined
+ Impl& operator=( const Impl& impl );
+};
+
+Framework::Framework( Framework::Observer& observer, int *argc, char ***argv )
+: mObserver(observer),
+ mInitialised(false),
+ mRunning(false),
+ mArgc(argc),
+ mArgv(argv),
+ mBundleName(""),
+ mBundleId(""),
+ mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
+ mImpl(NULL)
+{
+
+ mImpl = new Impl(this);
+}
+
+Framework::~Framework()
+{
+ if (mRunning)
+ {
+ Quit();
+ }
+
+ delete mImpl;
+}
+
+void Framework::Run()
+{
+ mRunning = true;
+
+ mImpl->Run();
+
+
+ mRunning = false;
+}
+
+void Framework::Quit()
+{
+ mImpl->Quit();
+}
+
+bool Framework::IsMainLoopRunning()
+{
+ return mRunning;
+}
+
+void Framework::AddAbortCallback( CallbackBase* callback )
+{
+ mImpl->mAbortCallBack = callback;
+}
+
+std::string Framework::GetBundleName() const
+{
+ return mBundleName;
+}
+
+void Framework::SetBundleName(const std::string& name)
+{
+}
+
+std::string Framework::GetBundleId() const
+{
+ return "";
+}
+
+void Framework::SetBundleId(const std::string& id)
+{
+}
+
+void Framework::AbortCallback( )
+{
+ // if an abort call back has been installed run it.
+ if (mImpl->mAbortCallBack)
+ {
+ CallbackBase::Execute( *mImpl->mAbortCallBack );
+ }
+ else
+ {
+ Quit();
+ }
+}
+
+bool Framework::AppStatusHandler(int type, void *bundleData)
+{
+ return true;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
#include <adaptor-impl.h>
// EXTERNAL INCLUDES
-#ifndef TIZEN_SDK_2_2_COMPATIBILITY
+#ifdef USE_APPFW
#include <app.h>
#endif
void Adaptor::GetDataStoragePath( std::string& path)
{
-#ifdef TIZEN_SDK_2_2_COMPATIBILITY
- path = "";
-#else
+#ifdef USE_APPFW
char *pathInt = app_get_data_path();
if ( pathInt )
{
path = "";
}
#endif
+
}
} // namespace Adaptor
adaptor_tizen_internal_src_files = \
$(adaptor_tizen_dir)/adaptor-impl-tizen.cpp \
- $(adaptor_tizen_dir)/framework-tizen.cpp \
$(adaptor_tizen_dir)/vsync-monitor-tizen.cpp \
$(adaptor_tizen_dir)/tilt-sensor-impl-tizen.cpp \
$(adaptor_tizen_dir)/tts-player-impl-tizen.cpp
# common to tizen platforms except not for mobile
adaptor_tizen_internal_non_mobile_src_files = \
$(adaptor_tizen_dir)/accessibility-adaptor-impl-tizen.cpp
+
+
+adaptor_tizen_framework_efl_src_files = $(adaptor_tizen_dir)/framework-tizen.cpp
# tv profile internal files
adaptor_common_internal_tv_profile_src_files = \
- $(adaptor_tv_dir)/tv-render-surface-factory.cpp \
$(adaptor_tv_dir)/tv-system-settings.cpp \
$(adaptor_tv_dir)/tv-color-controller-impl.cpp
+++ /dev/null
-/*
- * Copyright (c) 2014 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 <pixmap-render-surface.h>
-
-namespace Dali
-{
-
-namespace ECore
-{
-
-DALI_EXPORT_API PixmapRenderSurface* CreatePixmapSurface(
- PositionSize positionSize,
- Any surface,
- const std::string& name,
- bool isTransparent )
-{
- return new PixmapRenderSurface( positionSize, surface, name, isTransparent );
-}
-
-} // namespace ECoreX
-
-} // namespace Dali
-
-
-
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
*
*/
-// EXTERNAL INCLUDES
-#include <system_settings.h>
-#include <Elementary.h>
-
-// INTERNAL INCLUDES
-#include <system-settings.h>
namespace Dali
{
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "clipboard-impl.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <singleton-service-impl.h>
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Clipboard
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+BaseHandle Create()
+{
+ BaseHandle handle( Clipboard::Get() );
+
+ return handle;
+}
+TypeRegistration CLIPBOARD_TYPE( typeid(Dali::Clipboard), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
+
+} // unnamed namespace
+
+Clipboard::~Clipboard()
+{
+}
+
+Dali::Clipboard Clipboard::Get()
+{
+ Dali::Clipboard clipboard;
+
+ Dali::SingletonService service( SingletonService::Get() );
+ if ( service )
+ {
+ // Check whether the singleton is already created
+ Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
+ if(handle)
+ {
+ // If so, downcast the handle
+ clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return clipboard;
+}
+bool Clipboard::SetItem(const std::string &itemData )
+{
+ return true;
+}
+
+/*
+ * Get string at given index of clipboard
+ */
+std::string Clipboard::GetItem( unsigned int index ) // change string to a Dali::Text object.
+{
+ return "not supported";
+}
+
+/*
+ * Get number of items in clipboard
+ */
+unsigned int Clipboard::NumberOfItems()
+{
+ return -1;
+}
+
+/**
+ * Show clipboard window
+ * Function to send message to show the Clipboard (cbhm) as no direct API available
+ * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
+ */
+void Clipboard::ShowClipboard()
+{
+}
+
+void Clipboard::HideClipboard()
+{
+}
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "display-connection-impl.h"
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+DisplayConnection* DisplayConnection::New()
+{
+ return new DisplayConnection();
+}
+
+DisplayConnection::DisplayConnection()
+: mDisplay(NULL)
+{
+}
+
+DisplayConnection::~DisplayConnection()
+{
+
+}
+
+Any DisplayConnection::GetDisplay()
+{
+ return Any(mDisplay);
+}
+
+void DisplayConnection::ConsumeEvents()
+{
+}
+
+bool DisplayConnection::InitializeEgl(EglInterface& egl)
+{
+ return true;
+}
+
+void DisplayConnection::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
+{
+ // calculate DPI
+ float xres, yres;
+
+ // 1 inch = 25.4 millimeters
+ xres = 72;// hardcoded for now, @todo use wl_output interface to calculate display dpi
+ yres = 72;// hardcoded for now
+
+ dpiHorizontal = int(xres + 0.5f); // rounding
+ dpiVertical = int(yres + 0.5f);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_WAYLAND_DIPLAY_CONNECTION_H__
+#define __DALI_INTERNAL_WAYLAND_DIPLAY_CONNECTION_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <wayland-egl.h>
+#include <wl-types.h>
+
+// INTERNAL INCLUDES
+#include <base/display-connection.h>
+#include <dali/public-api/object/base-object.h>
+#include <gl/egl-implementation.h>
+
+namespace Dali
+{
+
+class RenderSurface;
+class DisplayConnection;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * DisplayConnection implementation
+ */
+class DisplayConnection : public Dali::BaseObject
+{
+public:
+
+ /**
+ * @brief Default constructor
+ */
+ DisplayConnection();
+
+ /**
+ * @brief Create an initialized DisplayConnection.
+ *
+ * @return A handle to a newly allocated DisplayConnection resource.
+ */
+ static DisplayConnection* New();
+
+public:
+
+ /**
+ * @copydoc Dali::DisplayConnection::GetDisplay
+ */
+ Any GetDisplay();
+
+ /**
+ * @copydoc Dali::DisplayConnection::GetDpi
+ */
+ static void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical);
+
+ /**
+ * @copydoc Dali::DisplayConnection::ConsumeEvents
+ */
+ void ConsumeEvents();
+
+ /**
+ * @copydoc Dali::DisplayConnection::InitializeEgl
+ */
+ bool InitializeEgl(EglInterface& egl);
+
+public:
+
+ /**
+ * Destructor
+ */
+ virtual ~DisplayConnection();
+
+protected:
+
+ // Undefined
+ DisplayConnection(const DisplayConnection&);
+
+ // Undefined
+ DisplayConnection& operator=(const DisplayConnection& rhs);
+
+private:
+ WlDisplay* mDisplay; ///< Wayland-display for rendering
+};
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_WAYLAND_DIPLAY_CONNECTION_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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 <events/event-handler.h>
+
+// EXTERNAL INCLUDES
+#include <cstring>
+
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/touch-point.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/events/wheel-event.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/hover-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
+
+
+// INTERNAL INCLUDES
+#include <render-surface/render-surface-wl.h>
+#include <events/gesture-manager.h>
+#include <key-impl.h>
+#include <clipboard.h>
+#include <physical-keyboard-impl.h>
+#include <style-monitor-impl.h>
+#include <base/core-event-interface.h>
+#include <base/interfaces/window-event-interface.h>
+
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+struct EventHandler::Impl : public WindowEventInterface
+{
+ // Construction & Destruction
+
+ /**
+ * Constructor
+ */
+ Impl( EventHandler* handler )
+ : mHandler( handler ),
+ mPaused( false )
+ {
+ }
+ /**
+ * Destructor
+ */
+ ~Impl()
+ {
+ }
+ // @todo Consider allowing the EventHandler class to inherit from WindowEventInterface directly
+ virtual void TouchEvent( Dali::TouchPoint& point, unsigned long timeStamp )
+ {
+ mHandler->SendEvent( point, timeStamp );
+ }
+ virtual void KeyEvent( Dali::KeyEvent& keyEvent )
+ {
+ mHandler->SendEvent( keyEvent );
+ }
+ virtual void WheelEvent( Dali::WheelEvent& wheelEvent )
+ {
+ mHandler->SendWheelEvent( wheelEvent );
+ }
+ virtual void DamageEvent( Rect<int>& damageArea )
+ {
+ mHandler->SendEvent( damageArea );
+ }
+ virtual void WindowFocusOut( )
+ {
+ // used to do some work with ime
+ }
+ virtual void WindowFocusIn()
+ {
+ // used to do some work with ime
+ }
+ // Data
+ EventHandler* mHandler;
+ bool mPaused;
+};
+
+/**
+ * @TODO the event handler code seems to be common across all adaptors, could do with moving into common
+ *
+ */
+EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEventInterface, GestureManager& gestureManager, DamageObserver& damageObserver, DragAndDropDetectorPtr dndDetector )
+: mCoreEventInterface(coreEventInterface),
+ mGestureManager( gestureManager ),
+ mStyleMonitor( StyleMonitor::Get() ),
+ mDamageObserver( damageObserver ),
+ mRotationObserver( NULL ),
+ mDragAndDropDetector( dndDetector ),
+ mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
+ mClipboard( Dali::Clipboard::Get()),
+ mImpl( NULL )
+{
+
+
+ // this code only works with the wayland RenderSurface so need to downcast
+ Wayland::RenderSurface* waylandSurface = dynamic_cast< Wayland::RenderSurface* >( surface );
+
+ mImpl = new Impl(this );
+
+ waylandSurface->AssignWindowEventInterface( mImpl );
+}
+
+EventHandler::~EventHandler()
+{
+ if(mImpl)
+ {
+ delete mImpl;
+ }
+
+ mGestureManager.Stop();
+}
+
+void EventHandler::SendEvent(TouchPoint& point, unsigned long timeStamp)
+{
+
+ Integration::TouchEvent touchEvent;
+ Integration::HoverEvent hoverEvent;
+ Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
+ if(type != Integration::TouchEventCombiner::DispatchNone )
+ {
+ DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.deviceId, point.state, point.local.x, point.local.y);
+
+ // First the touch and/or hover event & related gesture events are queued
+ if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
+ {
+ mCoreEventInterface.QueueCoreEvent( touchEvent );
+ mGestureManager.SendEvent(touchEvent);
+ }
+
+ if(type == Integration::TouchEventCombiner::DispatchHover || type == Integration::TouchEventCombiner::DispatchBoth)
+ {
+ mCoreEventInterface.QueueCoreEvent( hoverEvent );
+ }
+
+ // Next the events are processed with a single call into Core
+ mCoreEventInterface.ProcessCoreEvents();
+ }
+}
+
+void EventHandler::SendEvent(KeyEvent& keyEvent)
+{
+ Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
+ if ( physicalKeyboard )
+ {
+ if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ) )
+ {
+ GetImplementation( physicalKeyboard ).KeyReceived( keyEvent.time > 1 );
+ }
+ }
+
+ // Create KeyEvent and send to Core.
+ Integration::KeyEvent event(keyEvent.keyPressedName, keyEvent.keyPressed, keyEvent.keyCode,
+ keyEvent.keyModifier, keyEvent.time, static_cast<Integration::KeyEvent::State>(keyEvent.state));
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::SendWheelEvent( WheelEvent& wheelEvent )
+{
+ // Create WheelEvent and send to Core.
+ Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp );
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::SendEvent( StyleChange::Type styleChange )
+{
+ DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
+ GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
+}
+
+void EventHandler::SendEvent( const DamageArea& area )
+{
+ mDamageObserver.OnDamaged( area );
+}
+
+void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
+{
+ if( mRotationObserver != NULL )
+ {
+ mRotationObserver->OnRotationPrepare( event );
+ }
+}
+
+void EventHandler::SendRotationRequestEvent( )
+{
+ if( mRotationObserver != NULL )
+ {
+ mRotationObserver->OnRotationRequest( );
+ }
+}
+
+void EventHandler::FeedTouchPoint( TouchPoint& point, int timeStamp)
+{
+ SendEvent(point, timeStamp);
+}
+
+void EventHandler::FeedWheelEvent( WheelEvent& wheelEvent )
+{
+ SendWheelEvent( wheelEvent );
+}
+
+void EventHandler::FeedKeyEvent( KeyEvent& event )
+{
+ SendEvent( event );
+}
+
+void EventHandler::FeedEvent( Integration::Event& event )
+{
+ mCoreEventInterface.QueueCoreEvent( event );
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::Reset()
+{
+ mCombiner.Reset();
+
+ // Any touch listeners should be told of the interruption.
+ Integration::TouchEvent event;
+ TouchPoint point(0, TouchPoint::Interrupted, 0, 0);
+ event.AddPoint( point );
+
+ // First the touch event & related gesture events are queued
+ mCoreEventInterface.QueueCoreEvent( event );
+ mGestureManager.SendEvent( event );
+
+ // Next the events are processed with a single call into Core
+ mCoreEventInterface.ProcessCoreEvents();
+}
+
+void EventHandler::Pause()
+{
+ mPaused = true;
+ Reset();
+}
+
+void EventHandler::Resume()
+{
+ mPaused = false;
+ Reset();
+}
+
+void EventHandler::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
+{
+ mDragAndDropDetector = detector;
+}
+
+void EventHandler::SetRotationObserver( RotationObserver* observer )
+{
+ mRotationObserver = observer;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+# wayland
+
+adaptor_wayland_tizen_internal_src_files = \
+ $(adaptor_wayland_dir)/wayland-window.cpp \
+ $(adaptor_wayland_dir)/window-impl-wl.cpp \
+ $(adaptor_wayland_dir)/display-connection-impl-wl.cpp \
+ $(adaptor_wayland_dir)/wayland-manager.cpp \
+ $(adaptor_wayland_dir)/input-manager.cpp \
+ $(adaptor_wayland_dir)/event-handler-wl.cpp \
+ $(adaptor_wayland_dir)/input/input-listeners.cpp \
+ $(adaptor_wayland_dir)/input/seat.cpp \
+ $(adaptor_wayland_dir)/input/key-mapping-wl.cpp \
+ $(adaptor_wayland_dir)/render-surface/render-surface-wl.cpp \
+ $(adaptor_wayland_dir)/clipboard/clipboard-impl-wl.cpp \
+ $(adaptor_wayland_dir)/imf/imf-manager-impl-wl.cpp \
+ $(adaptor_wayland_dir)/native-image/native-image-source-impl-wl.cpp
--- /dev/null
+/*
+ * Copyright (c) 2015 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 <imf-manager-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <singleton-service-impl.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+BaseHandle Create()
+{
+ return ImfManager::Get();
+}
+
+TypeRegistration IMF_MANAGER_TYPE( typeid(Dali::ImfManager), typeid(Dali::BaseHandle), Create );
+
+} // unnamed namespace
+
+bool ImfManager::IsAvailable()
+{
+ return false;
+}
+
+Dali::ImfManager ImfManager::Get()
+{
+ // Return empty handle as not supported
+ return Dali::ImfManager();
+}
+
+ImfManager::~ImfManager()
+{
+}
+
+void ImfManager::ConnectCallbacks()
+{
+}
+
+void ImfManager::DisconnectCallbacks()
+{
+}
+
+void ImfManager::Activate()
+{
+}
+
+void ImfManager::Deactivate()
+{
+}
+
+void ImfManager::Reset()
+{
+}
+
+void* ImfManager::GetContext()
+{
+ return NULL;
+}
+
+bool ImfManager::RestoreAfterFocusLost() const
+{
+ return false;
+}
+
+void ImfManager::SetRestoreAfterFocusLost( bool toggle )
+{
+}
+
+void ImfManager::NotifyCursorPosition()
+{
+}
+unsigned int ImfManager::GetCursorPosition() const
+{
+ return 0;
+}
+
+void ImfManager::SetCursorPosition( unsigned int cursorPosition )
+{
+}
+
+void ImfManager::SetSurroundingText( const std::string& text )
+{
+}
+
+const std::string& ImfManager::GetSurroundingText() const
+{
+ static std::string dummyString("");
+ return dummyString;
+}
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_IMF_MANAGER_WL_H
+#define __DALI_INTERNAL_IMF_MANAGER_WL_H
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+#include <dali/public-api/object/base-object.h>
+#include <dali/integration-api/events/key-event-integ.h>
+
+// INTERNAL INCLUDES
+#include <imf-manager.h>
+
+namespace Dali
+{
+
+class RenderSurface;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class ImfManager : public Dali::BaseObject
+{
+public:
+ typedef Dali::ImfManager::ImfManagerSignalType ImfManagerSignalType;
+ typedef Dali::ImfManager::ImfEventSignalType ImfEventSignalType;
+
+public:
+
+ /**
+ * Check whether the ImfManager is available.
+ * @return true if available, false otherwise
+ */
+ static bool IsAvailable();
+
+ /**
+ * Get the IMF manager instance, it creates the instance if it has not already been created.
+ * Internally, a check should be made using IsAvailable() before this is called as we do not want
+ * to create an instance if not needed by applications.
+ * @see IsAvailable()
+ */
+ static Dali::ImfManager Get();
+
+ /**
+ * Connect Callbacks required for IMF.
+ * If you don't connect imf callbacks, you can't get the key events.
+ * The events are PreeditChanged, Commit and DeleteSurrounding.
+ */
+ void ConnectCallbacks();
+
+ /**
+ * Disconnect Callbacks attached to imf context.
+ */
+ void DisconnectCallbacks();
+
+ /**
+ * @copydoc Dali::ImfManager::Activate()
+ */
+ void Activate();
+
+ /**
+ * @copydoc Dali::ImfManager::Deactivate()
+ */
+ void Deactivate();
+
+ /**
+ * @copydoc Dali::ImfManager::Reset()
+ */
+ void Reset();
+
+ /**
+ * @copydoc Dali::ImfManager::GetContext()
+ */
+ void* GetContext();
+
+ /**
+ * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
+ */
+ bool RestoreAfterFocusLost() const;
+
+ /**
+ * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
+ */
+ void SetRestoreAfterFocusLost( bool toggle );
+
+
+ // Cursor related
+ /**
+ * @copydoc Dali::ImfManager::NotifyCursorPosition()
+ */
+ void NotifyCursorPosition();
+
+ /**
+ * @copydoc Dali::ImfManager::SetCursorPosition()
+ */
+ void SetCursorPosition( unsigned int cursorPosition );
+
+ /**
+ * @copydoc Dali::ImfManager::GetCursorPosition()
+ */
+ unsigned int GetCursorPosition() const;
+
+ /**
+ * @copydoc Dali::ImfManager::SetSurroundingText()
+ */
+ void SetSurroundingText( const std::string& text );
+
+ /**
+ * @copydoc Dali::ImfManager::GetSurroundingText()
+ */
+ const std::string& GetSurroundingText() const;
+
+public: // Signals
+
+ /**
+ * @copydoc Dali::ImfManager::ActivatedSignal()
+ */
+ ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
+
+ /**
+ * @copydoc Dali::ImfManager::EventReceivedSignal()
+ */
+ ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
+
+protected:
+
+ /**
+ * Destructor.
+ */
+ virtual ~ImfManager();
+
+
+private:
+
+ ImfManagerSignalType mActivatedSignal;
+ ImfEventSignalType mEventSignal;
+
+ // Undefined
+ ImfManager( const ImfManager& );
+ ImfManager& operator=( ImfManager& );
+
+private:
+
+public:
+
+inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
+{
+ DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
+
+ BaseObject& handle = imfManager.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::ImfManager&>(handle);
+}
+
+inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
+{
+ DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
+
+ const BaseObject& handle = imfManager.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::ImfManager&>(handle);
+}
+
+};
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_IMF_MANAGER_WL_H
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "input-manager.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+const unsigned int POINTER_DEVICE_ID = 2;
+const unsigned int TOUCH_DEVICE_ID = 3;
+
+} // unnamed namespace
+
+InputManager::InputManager()
+:mWindowEventInterface( NULL )
+{
+
+}
+InputManager::~InputManager()
+{
+ for( Dali::Vector< Seat* >::Iterator iter = mSeats.Begin(); iter != mSeats.End() ; ++iter )
+ {
+ delete (*iter);
+ }
+ mSeats.Clear();
+}
+
+void InputManager::AssignWindowEventInterface( WindowEventInterface* eventInterface)
+{
+ mWindowEventInterface = eventInterface;
+}
+
+
+void InputManager::PointerEnter( Seat* seat, unsigned int serial, WlSurface* surface, float x, float y )
+{
+ if( mWindowEventInterface )
+ {
+ mWindowEventInterface->WindowFocusIn();
+ }
+}
+
+void InputManager::PointerLeave( Seat* seat, unsigned int serial, WlSurface* surface )
+{
+ if( mWindowEventInterface )
+ {
+ mWindowEventInterface->WindowFocusOut();
+ }
+
+}
+
+void InputManager::PointerMotion( Seat* seat, unsigned int timestamp, float x, float y )
+{
+ if( mWindowEventInterface )
+ {
+ TouchPoint point ( POINTER_DEVICE_ID, TouchPoint::Motion, x , y);
+ mWindowEventInterface->TouchEvent( point, timestamp );
+ }
+}
+
+void InputManager::PointerButton( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state )
+{
+ // think about handling multiple pointer button states, if DALi starts to support them
+ if( mWindowEventInterface )
+ {
+ const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
+
+ TouchPoint point ( POINTER_DEVICE_ID, TouchPoint::Up, pointer.x, pointer.y );
+ if( state == 1)
+ {
+ point.state = TouchPoint::Down;
+ }
+ mWindowEventInterface->TouchEvent( point, timestamp );
+ }
+}
+
+void InputManager::PointerAxis( Seat* seat, unsigned int timestamp, unsigned int axis, float value )
+{
+
+ if( mWindowEventInterface )
+ {
+ WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL,
+ axis,
+ static_cast< int >( seat->GetDepressedKeyboardModifiers() ),
+ seat->GetLastPointerPosition(),
+ value,
+ timestamp );
+
+ mWindowEventInterface->WheelEvent( wheelEvent );
+ }
+}
+
+void InputManager::KeyboardKeymap( Seat* seat, unsigned int format, int fd, unsigned int size )
+{
+ seat->KeyboardKeymap( format, fd, size );
+}
+
+void InputManager::KeyFocusEnter( Seat* seat, unsigned int serial, WlSurface* surface, WlArray* keys )
+{
+ // ignore for now
+}
+
+void InputManager::KeyFocusLeave( Seat* seat, unsigned int serial, WlSurface* surface )
+{
+ // ignore for now
+}
+
+void InputManager::KeyEvent( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state )
+{
+ Dali::KeyEvent keyEvent = seat->GetDALiKeyEvent( serial, timestamp, keycode, state );
+
+ mWindowEventInterface->KeyEvent( keyEvent);
+
+}
+
+
+void InputManager::KeyModifiers( Seat* seat,
+ unsigned int serial,
+ unsigned int depressed,
+ unsigned int latched,
+ unsigned int locked,
+ unsigned int group )
+{
+ seat->SetDepressedKeyboardModifiers( depressed );
+}
+
+void InputManager::KeyRepeatInfo( Seat* seat, int32_t rate, int32_t delay)
+{
+ if(( rate >= 0 ) && ( delay >= 0))
+ {
+ seat->SetKeyRepeatInfo( static_cast< unsigned int >( rate) , static_cast< unsigned int >(delay ));
+ }
+}
+
+void InputManager::TouchDown( Seat* seat, unsigned int serial, unsigned int timestamp, WlSurface* surface, int touchId, float x, float y)
+{
+ // think about handling multiple pointer button states, if DALi starts to support them
+ if( mWindowEventInterface )
+ {
+ const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
+
+ TouchPoint point ( touchId, TouchPoint::Down, pointer.x, pointer.y );
+ mWindowEventInterface->TouchEvent( point, timestamp );
+ }
+}
+
+
+void InputManager::TouchUp( Seat* seat, unsigned int serial, unsigned int timestamp, int touchId )
+{
+ if( mWindowEventInterface )
+ {
+ const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
+
+ TouchPoint point ( touchId, TouchPoint::Up, pointer.x, pointer.y );
+ mWindowEventInterface->TouchEvent( point, timestamp );
+ }
+}
+
+void InputManager::TouchMotion( Seat* seat, unsigned int timestamp, int touchId, float x, float y )
+{
+ if( mWindowEventInterface )
+ {
+ const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
+
+ TouchPoint point ( touchId, TouchPoint::Motion, pointer.x, pointer.y );
+ mWindowEventInterface->TouchEvent( point, timestamp );
+ }
+}
+
+void InputManager::TouchFrame( Seat* seat )
+{
+ // un-used
+}
+
+void InputManager::TouchCancel( Seat* seat )
+{
+ if( mWindowEventInterface )
+ {
+ const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
+
+ // it looks like DALi just checks the first touch point for interruption
+ // so touchId can be zero
+ TouchPoint point ( 0, TouchPoint::Interrupted, pointer.x, pointer.y );
+ mWindowEventInterface->TouchEvent( point, 0 );
+ }
+}
+
+Seat* InputManager::GetSeat( const WlKeyboard* keyboard )
+{
+ for( Dali::Vector< Seat *>::Iterator iter = mSeats.Begin(); iter != mSeats.End() ; ++iter )
+ {
+ if( (*iter)->GetKeyboardInterface() == keyboard )
+ {
+ return (*iter);
+ }
+ }
+ return NULL;
+}
+
+Seat* InputManager::GetSeat( const WlPointer* pointer )
+{
+ for( Dali::Vector< Seat *>::Iterator iter = mSeats.Begin(); iter != mSeats.End() ; ++iter )
+ {
+ if( (*iter)->GetPointerInterface() == pointer )
+ {
+ return (*iter);
+ }
+ }
+ return NULL;
+}
+
+Seat* InputManager::GetSeat( const WlTouch* touch )
+{
+ for( Dali::Vector< Seat* >::Iterator iter = mSeats.Begin(); iter != mSeats.End() ; ++iter )
+ {
+ if( (*iter)->GetTouchInterface() == touch )
+ {
+ return (*iter);
+ }
+ }
+ return NULL;
+}
+
+Seat* InputManager::GetSeat( const WlSeat* seat)
+{
+ for( Dali::Vector< Seat* >::Iterator iter = mSeats.Begin(); iter != mSeats.End() ; ++iter )
+ {
+ if( (*iter)->GetSeatInterface() == seat )
+ {
+ return (*iter);
+ }
+ }
+ return NULL;
+}
+
+void InputManager::AddSeat( Seat* seat )
+{
+ mSeats.PushBack( seat );
+}
+
+
+}
+}
+}
--- /dev/null
+#ifndef __DALI_WAYLAND_INPUT_H__
+#define __DALI_WAYLAND_INPUT_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/events/key-event.h>
+
+// INTERNAL INCLUDES
+#include <base/interfaces/window-event-interface.h>
+#include <wl-types.h>
+#include <input/input-interface.h>
+#include <input/seat.h>
+
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+/**
+ * @brief Listens to Wayland input events.
+ * Translates the wayland events into DALi events and forwards them to a WindowEventInterface
+ */
+class InputManager : public InputInterface
+{
+
+public:
+
+
+ /**
+ * @brief Constructor
+ */
+ InputManager();
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~InputManager();
+
+ /**
+ * @brief Assign the window event interface
+ * @param[in] eventInterface event interface
+ */
+ void AssignWindowEventInterface( WindowEventInterface* eventInterface);
+
+
+protected: //InputInterface, pointer events
+
+ /**
+ * @copydoc InputInterface::PointerEnter
+ */
+ virtual void PointerEnter( Seat* seat, unsigned int serial, WlSurface* surface, float x, float y );
+
+ /**
+ * @copydoc InputInterface::PointerLeave
+ */
+ virtual void PointerLeave( Seat* seat, unsigned int serial, WlSurface* surface );
+
+ /**
+ * @copydoc InputInterface::PointerMotion
+ */
+ virtual void PointerMotion( Seat* seat, unsigned int timestamp, float x, float y );
+
+ /**
+ * @copydoc InputInterface::PointerButton
+ */
+ virtual void PointerButton( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state );
+
+ /**
+ * @copydoc InputInterface::PointerAxis
+ */
+ virtual void PointerAxis( Seat* seat, unsigned int timestamp, unsigned int axis, float value );
+
+
+protected: //InputInterface, keyboard events
+
+ /**
+ * @copydoc InputInterface::KeyboardKeymap
+ */
+ virtual void KeyboardKeymap( Seat* seat, unsigned int format, int fd, unsigned int size );
+
+ /**
+ * @copydoc InputInterface::KeyFocusEnter
+ */
+ virtual void KeyFocusEnter( Seat* seat, unsigned int serial, WlSurface* surface, WlArray* keys );
+
+ /**
+ * @copydoc InputInterface::KeyFocusLeave
+ */
+ virtual void KeyFocusLeave( Seat* seat, unsigned int serial, WlSurface* surface );
+
+ /**
+ * @copydoc InputInterface::KeyEvent
+ */
+ virtual void KeyEvent( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state );
+
+ /**
+ * @copydoc InputInterface::KeyModifiers
+ */
+ virtual void KeyModifiers( Seat* seat,
+ unsigned int serial,
+ unsigned int depressed,
+ unsigned int latched,
+ unsigned int locked,
+ unsigned int group );
+
+ /**
+ * @copydoc InputInterface::KeyRepeatInfo
+ */
+ virtual void KeyRepeatInfo( Seat* seat, int32_t rate, int32_t delay);
+
+protected: //InputInterface, touch events
+
+ /**
+ * @copydoc InputInterface::TouchDown
+ */
+ virtual void TouchDown( Seat* seat, unsigned int serial, unsigned int timestamp, WlSurface* surface, int touchId, float x, float y);
+
+ /**
+ * @copydoc InputInterface::TouchUp
+ */
+ virtual void TouchUp( Seat* seat, unsigned int serial, unsigned int timestamp, int touchId );
+
+ /**
+ * @copydoc InputInterface::TouchMotion
+ */
+ virtual void TouchMotion( Seat* seat, unsigned int timestamp, int touchId, float x, float y );
+
+ /**
+ * @copydoc InputInterface::TouchFrame
+ */
+ virtual void TouchFrame( Seat* seat );
+
+ /**
+ * @copydoc InputInterface::TouchCancel
+ */
+ virtual void TouchCancel( Seat* seat );
+
+
+protected: //InputInterface Helper functions
+
+ /**
+ * @copydoc InputInterface::GetSeat( const WlKeyboard* keyboard )
+ */
+ virtual Seat* GetSeat( const WlKeyboard* keyboard );
+
+ /**
+ * @copydoc InputInterface::GetSeat( const WlPointer* pointer )
+ */
+ virtual Seat* GetSeat( const WlPointer* pointer );
+
+ /**
+ * @copydoc InputInterface::GetSeat( const WlTouch* touch )
+ */
+ virtual Seat* GetSeat( const WlTouch* touch );
+
+ /**
+ * @copydoc InputInterface::GetSeat( const WlSeat* seat )
+ */
+ virtual Seat* GetSeat( const WlSeat* seat );
+
+public:
+
+ /**
+ * @brief Add a new seat ( collection of input devices)
+ * @param[in] wlRegistry
+ * @param[in] seatName seat name / id
+ * @param[in] version interface version
+ */
+ void AddSeat( Seat* seat );
+
+
+private:
+
+ Dali::Vector< Seat* > mSeats;
+ WindowEventInterface* mWindowEventInterface;
+
+};
+
+} // Internal
+} // Adaptor
+} // Dali
+
+#endif //__DALI_WAYLAND_INPUT_H__
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_INPUT_INTERFACE_H__
+#define __DALI_INTERNAL_ADAPTOR_INPUT_INTERFACE_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <wl-types.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class Seat;
+
+/**
+ * @brief interface used by the Wayland input listeners to signal an event.
+ *
+ * The events that come from keyboard, pointer and touch devices are from a specific seat.
+ * A single seat can have multiple keyboards, pointers and touch devices connected to it.
+ *
+ * For example you can have a car with 4 seats each with their own touch screen that
+ * are run by a central device with multi-display output.
+ *
+ * Some input events have serial numbers and time stamps.
+ *
+ * Serial numbers description from Wayland documentation:
+ * "To avoid race conditions, input events that are likely to trigger further requests
+ * (such as button presses, key events, pointer motions) carry serial numbers, and requests such as
+ * wl_surface.set_popup require that the serial number of the triggering event is specified."
+ *
+ * Time stamps description from Wayland documentation:
+ * "Input events also carry timestamps with millisecond granularity.
+ * Their base is undefined, so they can't be compared against system time
+ * (as obtained with clock_gettime or gettimeofday). They can be compared
+ * with each other though, and for instance be used to identify sequences
+ * of button presses as double or triple clicks."
+ */
+class InputInterface
+{
+
+public: // Pointer events. See wl_pointer_listener in wayland-client-protocol.h for more information.
+
+ /**
+ * @brief Called when a seat's pointer has entered a surface
+ *
+ * When focus enters a surface, the pointer image is
+ * undefined and a client should respond to this event by setting
+ * an appropriate pointer image with the set_cursor request.
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] surface surface
+ * @param[in] x x coordinate in surface-relative coordinates ( not screen )
+ * @param[in] y y coordinate in surface-relative coordinates ( not screen )
+ */
+ virtual void PointerEnter( Seat* seat, unsigned int serial, WlSurface* surface, float x, float y) = 0;
+
+ /**
+ * @brief Called when a seat's pointer leaves a surface
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] surface surface
+ *
+ * The leave notification is sent before the enter notification for
+ * the new focus.
+ */
+ virtual void PointerLeave( Seat* seat, unsigned int serial, WlSurface* surface ) = 0;
+
+ /**
+ * @brief pointer motion event
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] timestamp timestamp with millisecond granularity
+ * @param[in] x x coordinate in surface-relative coordinates ( not screen )
+ * @param[in] y y coordinate in surface-relative coordinates ( not screen )
+ *
+ */
+ virtual void PointerMotion( Seat* seat, unsigned int timestamp, float x, float y ) = 0;
+
+ /**
+ * @brief pointer click and release events
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] timestamp timestamp with millisecond granularity
+ * @param[in] button pointer button pressed
+ * @param[in] state button state ( 1 = down, 0 = up)
+ *
+ * The location of the click is given by the last motion or enter
+ * event.
+ */
+ virtual void PointerButton( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int button, unsigned int state ) = 0;
+
+ /**
+ * @brief Pointer scroll and other axis notifications.
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] timestamp timestamp with millisecond granularity
+ * @param[in] axis pointer axis
+ * @param[in] value length of a vector along the specified axis in a coordinate space identical to those of motion event
+ */
+ virtual void PointerAxis( Seat* seat, unsigned int timestamp, unsigned int axis, float value ) = 0;
+
+public: // Key events. See wl_keyboard_listener in wayland-client-protocol.h for more information.
+
+ /**
+ * @brief keyboard mapping
+ * Provides a file descriptor which can be memory-mapped to a keyboard mapping description
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] format see wl_keyboard_keymap_format
+ * @param[in] fd file descriptor
+ * @param[in] size size of the memory mapped region in bytes
+ */
+ virtual void KeyboardKeymap( Seat* seat, unsigned int format, int fd, unsigned int size ) = 0;
+
+ /**
+ * @brief The seat's keyboard focus has entered a surface
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] surface surface
+ * @param[in] keys the currently pressed keys
+ */
+ virtual void KeyFocusEnter( Seat* seat, unsigned int serial, WlSurface* surface, WlArray* keys ) = 0;
+
+ /**
+ * @brief The seat's keyboard focus has left a surface
+ *
+ * The leave notification is sent before the enter notification for the new focus.
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] surface surface
+ */
+ virtual void KeyFocusLeave( Seat* seat, unsigned int serial, WlSurface* surface ) = 0;
+
+ /**
+ * @brief Key has been pressed or released
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] timestamp timestamp
+ * @param[in] keycode raw hardware key code
+ * @param[in] state
+ */
+ virtual void KeyEvent( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state) = 0;
+
+ /**
+ * @brief Key modifier state has changed
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] depressed modifiers depressed
+ * @param[in] latched modifiers latched
+ * @param[in] locked modifiers locked
+ * @param[in[ group group
+ */
+ virtual void KeyModifiers( Seat* seat,
+ unsigned int serial,
+ unsigned int depressed,
+ unsigned int latched,
+ unsigned int locked,
+ unsigned int group) = 0;
+
+
+ /**
+ * @brief Key repeat rate and delay.
+ *
+ * Informs DALi of the keyboard's repeat rate and delay.
+ *
+ * Event sent when wl_keyboard object created, before any key events
+ * If rate == zero, repeating is disabled
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] rate rate of repeating keys in characters per second
+ * @param[in] delay delay in milliseconds since key down until repeating starts
+ */
+ virtual void KeyRepeatInfo( Seat* seat, int32_t rate, int32_t delay) = 0;
+
+
+public: // touch events. See wl_touch_listener in wayland-client-protocol.h for more information.
+
+ /**
+ * @brief Touch down event on a surface.
+ *
+ * Future events from this touch point will have the same id which is valid
+ * until a touch up event.
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] timestamp timestamp
+ * @param[in] surface surface
+ * @param[in] touchId unique touch id valid until touch is released
+ * @param[in] x coordinate in surface-relative coordinates
+ * @param[in[ y coordinate in surface-relative coordinates
+ */
+ virtual void TouchDown( Seat* seat, unsigned int serial, unsigned int timestamp, WlSurface* surface, int touchId, float x, float y) = 0;
+
+ /**
+ * @brief Touch up event on a surface.
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] timestamp timestamp with millisecond granularity
+ * @param[in] touchId unique touch id valid until touch is released ( can be re-used for future events)
+ */
+ virtual void TouchUp( Seat* seat, unsigned int serial, unsigned int timestamp, int touchId ) = 0;
+
+ /**
+ * @brief Touch Motion event on a surface.
+ * Events relating to the same touch point can be identified by the touchId
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] timestamp timestamp with millisecond granularity
+ * @param[in] touchId unique touch id valid until touch is released ( then can be re-used)
+ * @param[in] x coordinate in surface-relative coordinates
+ * @param[in[ y coordinate in surface-relative coordinates
+ */
+ virtual void TouchMotion( Seat* seat, unsigned int timestamp, int touchId, float x, float y ) = 0;
+
+ /**
+ * @brief end of touch frame event
+ * Unsure what this means.
+ * @param[in] seat the seat that produced the event
+ */
+ virtual void TouchFrame( Seat* seat ) = 0;
+
+ /**
+ * @brief Cancel current touch session
+ * If Wayland Compositor decides current touch stream is a global
+ * gesture we have to cancel any touch / gesture detection.
+ *
+ * Touch cancellation applies to all touch points currently active on
+ * our surface. TouchPoint::Interrupted will be sent to dali-core
+ *
+ * @param[in] seat the seat that produced the event
+ */
+ virtual void TouchCancel( Seat* seat ) = 0;
+
+public: // Helper functions used to find the seat associated with the keyboard/pointer/touch device
+
+ /**
+ * @brief get the seat that contains the keyboard interface
+ * @param[in] keyboard wayland keyboard interface
+ * @return the seat the keyboard belongs to
+ */
+ virtual Seat* GetSeat( const WlKeyboard* keyboard ) = 0;
+
+ /**
+ * @brief get the seat that contains the pointer interface
+ * @param[in] pointer wayland pointer interface
+ * @return the seat the pointer belongs to
+ */
+ virtual Seat* GetSeat( const WlPointer* pointer ) = 0;
+
+ /**
+ * @brief get the seat that contains the touch interface
+ * @param[in] touch wayland touch interface
+ * @return the seat the touch device belongs to
+ */
+ virtual Seat* GetSeat( const WlTouch* touch ) = 0;
+
+ /**
+ * @brief get the seat that contains the wayland seat interface
+ * @param[in] seat wayland seat interface
+ * @return the seat the touch device belongs to
+ */
+ virtual Seat* GetSeat( const WlSeat* seat ) = 0;
+
+protected:
+
+ /**
+ * @brief Constructor
+ */
+ InputInterface()
+ {
+ }
+
+ /**
+ * @brief destructor
+ */
+ virtual ~InputInterface()
+ {
+ }
+
+ // Undefined copy constructor.
+ InputInterface( const InputInterface& );
+
+ // Undefined assignment operator.
+ InputInterface& operator=( const InputInterface& );
+};
+
+
+
+} // Internal
+} // Adaptor
+} // Dali
+
+#endif //__DALI_INTERNAL_ADAPTOR_INPUT_INTERFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "input-listeners.h"
+
+// EXTERNAL INCLUDES
+#include <cctype>
+#include <stdio.h>
+
+// INTERNAL INCLUDES
+#include "input-interface.h"
+#include "seat.h"
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+/************
+ *
+ * Pointer events callbacks. See wl_pointer_listener in wayland-client-protocol.h for a description
+ *
+ ************/
+void PointerEnter( void* data,
+ WlPointer* pointer,
+ unsigned int serial,
+ WlSurface* surface,
+ wl_fixed_t surfaceX,
+ wl_fixed_t surfaceY)
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( pointer );
+
+ float x = static_cast<float>( wl_fixed_to_double(surfaceX) );
+ float y = static_cast<float>( wl_fixed_to_double(surfaceY) );
+
+ seat->SetPointerPosition( Vector2(x, y) ); // record last pointer position
+
+ input->PointerEnter( seat, serial, surface, x, y );
+}
+
+void PointerLeave( void* data,
+ WlPointer* pointer,
+ unsigned int serial,
+ WlSurface* surface )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( pointer );
+
+ input->PointerLeave( seat, serial, surface );
+}
+
+void PointerMotion( void* data,
+ WlPointer* pointer,
+ unsigned int timestamp,
+ wl_fixed_t surfaceX,
+ wl_fixed_t surfaceY )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( pointer );
+
+ float x = static_cast<float>( wl_fixed_to_double( surfaceX) );
+ float y = static_cast<float>( wl_fixed_to_double( surfaceY) );
+
+ seat->SetPointerPosition( Vector2(x, y) ); // record last pointer position
+
+ input->PointerMotion( seat, timestamp, x, y );
+}
+
+void PointerButton( void* data,
+ WlPointer* pointer,
+ unsigned int serial,
+ unsigned int timestamp,
+ unsigned int button,
+ unsigned int state )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( pointer );
+
+ input->PointerButton( seat, serial, timestamp, button, state );
+
+}
+
+void PointerAxis( void* data,
+ WlPointer* pointer,
+ unsigned int timestamp,
+ unsigned int axis,
+ wl_fixed_t value )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( pointer );
+
+ float length = static_cast<float>( wl_fixed_to_double( value ) );
+
+ input->PointerAxis( seat, timestamp, axis, length);
+}
+
+/************
+ *
+ * Key event callbacks. See wl_keyboard_listener wayland-client-protocol.h for a description
+ *
+ ************/
+void KeyboardKeymap( void* data,
+ WlKeyboard* keyboard,
+ unsigned int format,
+ int fd,
+ unsigned int size )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( keyboard );
+
+ input->KeyboardKeymap( seat, format, fd, size );
+
+}
+
+void KeyFocusEnter( void* data,
+ WlKeyboard* keyboard,
+ unsigned int serial,
+ WlSurface* surface,
+ WlArray* keys )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( keyboard );
+
+ input->KeyFocusEnter( seat, serial, surface, keys );
+}
+
+void KeyFocusLeave( void* data,
+ WlKeyboard* keyboard,
+ unsigned int serial,
+ WlSurface* surface )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( keyboard );
+
+ input->KeyFocusLeave( seat, serial, surface );
+}
+
+void KeyEvent( void* data,
+ WlKeyboard* keyboard,
+ unsigned int serial,
+ unsigned int timestamp,
+ unsigned int keycode,
+ unsigned int state)
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( keyboard );
+
+ input->KeyEvent( seat, serial, timestamp, keycode, state );
+}
+
+void KeyModifiers( void* data, WlKeyboard* keyboard,
+ unsigned int serial,
+ unsigned int depressed,
+ unsigned int latched,
+ unsigned int locked,
+ unsigned int group)
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( keyboard );
+
+ input->KeyModifiers( seat, serial, depressed, latched, locked, group );
+
+
+}
+
+void KeyRepeatInfo( void* data,
+ WlKeyboard* keyboard,
+ int32_t rate,
+ int32_t delay)
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( keyboard );
+
+ input->KeyRepeatInfo( seat, rate, delay );
+
+}
+
+/************
+ *
+ * Touch event callbacks See wl_touch_listener wayland-client-protocol.h for a description
+ *
+ ************/
+void TouchDown( void* data,
+ WlTouch* touch,
+ unsigned int serial,
+ unsigned int timestamp,
+ WlSurface* surface,
+ int touchId,
+ wl_fixed_t surfaceX,
+ wl_fixed_t surfaceY)
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( touch );
+
+ float x = static_cast<float>( wl_fixed_to_double( surfaceX) );
+ float y = static_cast<float>( wl_fixed_to_double( surfaceY) );
+
+
+ input->TouchDown( seat, serial, timestamp, surface, touchId, x, y );
+}
+
+void TouchUp( void* data,
+ WlTouch* touch,
+ unsigned int serial,
+ unsigned int timestamp,
+ int touchId )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( touch );
+
+ input->TouchUp( seat, serial, timestamp, touchId );
+}
+
+void TouchMotion( void* data,
+ WlTouch* touch,
+ unsigned int timestamp,
+ int touchId,
+ wl_fixed_t surfaceX,
+ wl_fixed_t surfaceY)
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( touch );
+
+ float x = static_cast<float>( wl_fixed_to_double( surfaceX) );
+ float y = static_cast<float>( wl_fixed_to_double( surfaceY) );
+
+ input->TouchMotion( seat, timestamp, touchId, x, y );
+}
+
+void TouchFrame( void* data, WlTouch* touch )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( touch );
+
+ input->TouchFrame( seat );
+}
+
+void TouchCancel( void* data, WlTouch* touch )
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( touch );
+
+ input->TouchCancel( seat );
+}
+
+/**
+ * pointer listener interface ( wl_pointer_listener )
+ */
+const WlPointerListener PointerListener =
+{
+ PointerEnter,
+ PointerLeave,
+ PointerMotion,
+ PointerButton,
+ PointerAxis,
+};
+
+/**
+ * Keyboard listener interface ( wl_keyboard_listener )
+ */
+const WlKeyboardListener KeyboardListener =
+{
+ KeyboardKeymap,
+ KeyFocusEnter,
+ KeyFocusLeave,
+ KeyEvent,
+ KeyModifiers,
+ KeyRepeatInfo
+};
+
+/**
+ * Touch listener interface ( wl_touch_listener )
+ */
+const WlTouchListener TouchListener =
+{
+ TouchDown,
+ TouchUp,
+ TouchMotion,
+ TouchFrame,
+ TouchCancel
+};
+
+/**
+ * @brief emitted whenever a seat gains or loses the pointer, keyboard or touch capabilities.
+ * @param[in] data user data
+ * @param[in] seatInterface seat interface
+ * @param[in] caps enum containing the complete set of capabilities this seat has.
+ */
+void SeatHandleCapabilities( void* data, WlSeat* seatInterface, unsigned int caps)
+{
+
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( seatInterface );
+
+
+ // go through either adding or removing pointer/keyboard/touch interfaces
+ // most devices are hot plug so this function may be called many times
+ // a single keyboard/ pointer / touch interface handles multiple devices
+ // e.g. if you plug in 2 mouses, you will still only get a single pointer_interface
+
+ if( caps & WL_SEAT_CAPABILITY_POINTER )
+ {
+ // at least one pointer available
+ seat->SetPointerInterface( Seat::INTERFACE_AVAILABLE );
+ }
+ else
+ {
+ // all pointer devices removed, or never connected
+ seat->SetPointerInterface( Seat::INTERFACE_NOT_AVAILABLE );
+ }
+
+ if( caps & WL_SEAT_CAPABILITY_KEYBOARD )
+ {
+ // at least one keyboard available
+ seat->SetKeyboardInterface( Seat::INTERFACE_AVAILABLE );
+ }
+ else
+ {
+ // all keyboard devices removed, or never connected
+ seat->SetKeyboardInterface( Seat::INTERFACE_NOT_AVAILABLE );
+ }
+
+ if( caps & WL_SEAT_CAPABILITY_TOUCH )
+ {
+ // new touch device found
+ seat->SetTouchInterface( Seat::INTERFACE_AVAILABLE );
+ }
+ else
+ {
+ // all touch devices removed, or never connected
+ seat->SetTouchInterface( Seat::INTERFACE_NOT_AVAILABLE );
+ }
+
+}
+
+void SeatName(void* data, WlSeat* seatInterface, const char* name)
+{
+ InputInterface* input = static_cast< InputInterface* >( data );
+ Seat* seat = input->GetSeat( seatInterface );
+ seat->SetName( name );
+}
+
+const WlSeatListener SeatListener =
+{
+ SeatHandleCapabilities, //emitted whenever a seat gains or loses the pointer, keyboard or touch capabilities.
+ SeatName, // used to help identify seat in multi-seat configurations
+};
+
+} // unnamed namespace
+
+
+namespace Wayland
+{
+
+const WlSeatListener* GetSeatListener()
+{
+ return &SeatListener;
+}
+
+const WlPointerListener* GetPointerListener()
+{
+ return &PointerListener;
+}
+
+const WlTouchListener* GetTouchListener()
+{
+ return &TouchListener;
+}
+
+const WlKeyboardListener* GetKeyboardListener()
+{
+ return &KeyboardListener;
+}
+
+}
+}
+}
+}
--- /dev/null
+#ifndef __DALI_WAYLAND_INPUT_LISTENERS_H__
+#define __DALI_WAYLAND_INPUT_LISTENERS_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <wl-types.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace Wayland
+{
+/**
+ * Functions for getting wayland listener objects as defined in wayland-client-protocol.h
+ * The listen objects contain C callbacks, which currently expect the user data-field
+ * to be a DALi InputInterface pointer.
+ *
+ * E.g. if setting the keyboard listener
+ *
+ * wl_keyboard_add_listener( keyboard, &Wayland::GetKeyboardListener(), &InputInterface );
+ *
+ */
+
+
+/**
+ * @brief Listens for keyboard / touch / pointer interfaces being enabled /disabled on a seat.
+ * @return seat listener
+ */
+const WlSeatListener* GetSeatListener();
+
+/**
+ * @brief returns a pointer to the callbacks used to listen to pointer events
+ * @return pointer listener
+ */
+const WlPointerListener* GetPointerListener();
+
+/**
+ * @brief returns a pointer to the callbacks used to listen to touch events
+ * @return touch listener
+ */
+const WlTouchListener* GetTouchListener();
+
+/**
+ * @brief returns a pointer to the callbacks used to listen to keyboard events
+ * @return keyboard listener
+ */
+const WlKeyboardListener* GetKeyboardListener();
+
+} // Wayland
+} // Internal
+} // Adaptor
+} // Dali
+
+#endif //__DALI_WAYLAND_INPUT_LISTENERS_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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 <key-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace KeyLookup
+{
+
+// matches a DALI_KEY enum, to a key name
+KeyLookup KeyLookupTable[]=
+{
+ // more than one key name can be assigned to a single dali-key code
+ // e.g. "Menu" and "XF86Menu" are both assigned to DALI_KEY_MENU
+
+ { "Escape", DALI_KEY_ESCAPE, false },
+ { "Menu", DALI_KEY_MENU, false },
+
+ // Now literal strings are used as key names instead of defined symbols in utilX,
+ // since these definition in utilX.h is deprecated
+ { "XF86Camera", DALI_KEY_CAMERA, false },
+ { "XF86Camera_Full", DALI_KEY_CONFIG, false },
+ { "XF86PowerOff", DALI_KEY_POWER, true },
+ { "XF86Standby", DALI_KEY_PAUSE, false },
+ { "Cancel", DALI_KEY_CANCEL, false },
+ { "XF86AudioPlay", DALI_KEY_PLAY_CD, false },
+ { "XF86AudioStop", DALI_KEY_STOP_CD, false },
+ { "XF86AudioPause", DALI_KEY_PAUSE_CD, false },
+ { "XF86AudioNext", DALI_KEY_NEXT_SONG, false },
+ { "XF86AudioPrev", DALI_KEY_PREVIOUS_SONG, false },
+ { "XF86AudioRewind", DALI_KEY_REWIND, false },
+ { "XF86AudioForward", DALI_KEY_FASTFORWARD, false },
+ { "XF86AudioMedia", DALI_KEY_MEDIA, false },
+ { "XF86AudioPlayPause", DALI_KEY_PLAY_PAUSE, false },
+ { "XF86AudioMute", DALI_KEY_MUTE, false },
+ { "XF86Menu", DALI_KEY_MENU, true },
+ { "XF86Home", DALI_KEY_HOME, true },
+ { "XF86Back", DALI_KEY_BACK, true },
+ { "XF86HomePage", DALI_KEY_HOMEPAGE, false },
+ { "XF86WWW", DALI_KEY_WEBPAGE, false },
+ { "XF86Mail", DALI_KEY_MAIL, false },
+ { "XF86ScreenSaver", DALI_KEY_SCREENSAVER, false },
+ { "XF86MonBrightnessUp", DALI_KEY_BRIGHTNESS_UP, false },
+ { "XF86MonBrightnessDown", DALI_KEY_BRIGHTNESS_DOWN, false },
+ { "XF86SoftKBD", DALI_KEY_SOFT_KBD, false },
+ { "XF86QuickPanel", DALI_KEY_QUICK_PANEL, false },
+ { "XF86TaskPane", DALI_KEY_TASK_SWITCH, false },
+ { "XF86Apps", DALI_KEY_APPS, false },
+ { "XF86Search", DALI_KEY_SEARCH, false },
+ { "XF86Voice", DALI_KEY_VOICE, false },
+ { "Hangul", DALI_KEY_LANGUAGE, false },
+ { "XF86AudioRaiseVolume", DALI_KEY_VOLUME_UP, true },
+ { "XF86AudioLowerVolume", DALI_KEY_VOLUME_DOWN, true },
+
+ { "BackSpace", DALI_KEY_BACKSPACE, false },
+ { "Left", DALI_KEY_CURSOR_LEFT, false },
+ { "Right", DALI_KEY_CURSOR_RIGHT, false },
+ { "Shift_L", DALI_KEY_SHIFT_LEFT, false },
+ { "Shift_R", DALI_KEY_SHIFT_RIGHT, false }
+};
+
+const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
+
+} // namespace KeyLookup
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "seat.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <cctype>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <cstring>
+
+// INTERNAL INCLUDES
+#include "input-listeners.h"
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+const unsigned int DEFAULT_KEY_REPEAT_RATE = 25;
+const unsigned int DEFAULT_KEY_REPEAT_DELAY = 400;
+}
+
+Seat::Seat( InputInterface* inputInterface, WlSeat* seatInterface )
+:mPointer( NULL ),
+ mKeyboard( NULL ),
+ mTouch( NULL ),
+ mWaylandSeat( seatInterface ),
+ mInputInterface( inputInterface ),
+ mPointerPosition( 0, 0),
+ mDepressedKeyboardModifiers(0),
+ mKeyRepeatRate( DEFAULT_KEY_REPEAT_RATE ),
+ mKeyRepeatDelay( DEFAULT_KEY_REPEAT_DELAY )
+{
+}
+
+Seat::~Seat()
+{
+ DestroyPointerInterface();
+ DestroyTouchInterface();
+ DestroyKeyboardInterface();
+}
+
+void Seat::SetPointerInterface( InterfaceStatus status )
+{
+ if( status == INTERFACE_AVAILABLE )
+ {
+ if( ! mPointer )
+ {
+ WlPointer* pointerInterface = wl_seat_get_pointer( mWaylandSeat );
+
+ // store the interface and add an event listener
+ wl_pointer_add_listener( pointerInterface, Wayland::GetPointerListener(), mInputInterface );
+
+ mPointer = pointerInterface;
+ }
+ }
+ else
+ {
+ DestroyPointerInterface();
+ }
+}
+
+void Seat::SetTouchInterface( InterfaceStatus status )
+{
+ if( status == INTERFACE_AVAILABLE )
+ {
+ // check if it's configured already
+ if( ! mTouch )
+ {
+ WlTouch* touchInterface = wl_seat_get_touch( mWaylandSeat );
+
+ wl_touch_add_listener( touchInterface, Wayland::GetTouchListener(), mInputInterface );
+
+ // store the interface and add an event listener
+ mTouch = touchInterface;
+ }
+ }
+ else
+ {
+ DestroyTouchInterface();
+ }
+
+}
+
+void Seat::SetKeyboardInterface( InterfaceStatus status )
+{
+ if( status == INTERFACE_AVAILABLE )
+ {
+ // check if it's configured already
+ if( ! mKeyboard )
+ {
+ WlKeyboard* keyboardInterface = wl_seat_get_keyboard( mWaylandSeat );
+
+ wl_keyboard_add_listener( keyboardInterface, Wayland::GetKeyboardListener(), mInputInterface );
+
+ // store the interface and add an event listener
+ mKeyboard = keyboardInterface;
+ }
+ }
+ else
+ {
+ DestroyKeyboardInterface();
+ }
+}
+
+WlPointer* Seat::GetPointerInterface()
+{
+ return mPointer;
+}
+
+WlTouch* Seat::GetTouchInterface()
+{
+ return mTouch;
+}
+
+WlKeyboard* Seat::GetKeyboardInterface()
+{
+ return mKeyboard;
+}
+
+WlSeat* Seat::GetSeatInterface()
+{
+ return mWaylandSeat;
+}
+
+void Seat::DestroyPointerInterface()
+{
+ if( mPointer )
+ {
+ wl_pointer_destroy( mPointer );
+ mPointer = NULL;
+ }
+}
+
+void Seat::DestroyTouchInterface()
+{
+ if( mTouch )
+ {
+ wl_touch_destroy( mTouch );
+ mTouch = NULL;
+ }
+}
+
+void Seat::DestroyKeyboardInterface()
+{
+ if( mKeyboard )
+ {
+ wl_keyboard_destroy( mKeyboard );
+ mKeyboard = NULL;
+ }
+}
+
+void Seat::SetName( const char* name )
+{
+ mName = std::string( mName );
+}
+const std::string& Seat::GetName() const
+{
+ return mName;
+}
+
+const Dali::Vector2& Seat::GetLastPointerPosition() const
+{
+ return mPointerPosition;
+}
+
+void Seat::SetPointerPosition( Dali::Vector2 position)
+{
+ mPointerPosition = position;
+}
+
+void Seat::KeyboardKeymap( unsigned int format, int fd, unsigned int size )
+{
+
+ if(!mXkbData.mContext )
+ {
+ mXkbData.mContext = xkb_context_new( XKB_CONTEXT_NO_FLAGS );
+ }
+
+ // current formats defined in wayland-client-protocol.h
+ // WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP =0, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1=1
+
+ if( format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1 )
+ {
+ DALI_LOG_ERROR("expected WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1");
+ close(fd);
+ return;
+ }
+
+ // memory map the shared region between us and XKB
+ char* map = static_cast<char*> (mmap( NULL, size, PROT_READ, MAP_SHARED, fd, 0));
+ if( map == MAP_FAILED)
+ {
+ DALI_LOG_ERROR("mmap xkb failed");
+ close(fd);
+ return;
+ }
+
+ mXkbData.mKeymap = xkb_map_new_from_string(mXkbData.mContext, map, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
+
+ munmap(map, size);
+ close(fd);
+
+ if (! mXkbData.mKeymap )
+ {
+ DALI_LOG_ERROR(" xkb_map_new_from_string failed");
+ return;
+ }
+
+ mXkbData.mState = xkb_state_new( mXkbData.mKeymap );
+
+ if( ! mXkbData.mState )
+ {
+ xkb_map_unref(mXkbData.mKeymap );
+ mXkbData.mKeymap = NULL;
+ return;
+ }
+
+ // store the bit which each mod will set when calling xkb_state_serialize_mods
+ mXkbData.mControlMask = 1 << xkb_map_mod_get_index( mXkbData.mKeymap, XKB_MOD_NAME_CTRL);
+ mXkbData.mAltMask = 1 << xkb_map_mod_get_index( mXkbData.mKeymap, XKB_MOD_NAME_ALT);
+ mXkbData.mShiftMask = 1 << xkb_map_mod_get_index( mXkbData.mKeymap, XKB_MOD_NAME_SHIFT);
+
+}
+
+Dali::KeyEvent Seat::GetDALiKeyEvent( unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state )
+{
+ unsigned int code( 0 );
+ unsigned int symbolCount( 0 );
+ const xkb_keysym_t* symbols( NULL );
+ xkb_keysym_t symbol = XKB_KEY_NoSymbol;
+ char key[256] = { 0 };
+ char keyName[256] = { 0 };
+
+ // X11 historically has a min keycode of 8 instead of 1, XKB follow this
+ code = keycode + 8;
+
+ //get the key symbols
+ symbolCount = xkb_key_get_syms( mXkbData.mState, code, &symbols);
+
+ if( symbolCount == 1)
+ {
+ symbol = symbols[0];
+ }
+ else
+
+ // get its name
+ xkb_keysym_get_name( symbol, key, sizeof(key));
+
+ // copy the keyname
+ memcpy(keyName, key, sizeof(keyName));
+
+ if (keyName[0] == '\0')
+ {
+ snprintf(keyName, sizeof(keyName), "Keycode-%u", code);
+ }
+
+ // todo support key repeat settings
+
+ Dali::KeyEvent keyEvent;
+
+ keyEvent.keyCode = code;
+ if( state == 1)
+ {
+ keyEvent.state = KeyEvent::Down;
+ }
+ else
+ {
+ keyEvent.state = KeyEvent::Up;
+ }
+ keyEvent.keyPressedName = keyName;
+ keyEvent.time = timestamp;
+ keyEvent.keyModifier = mDepressedKeyboardModifiers;
+
+ return keyEvent;
+
+}
+unsigned int Seat::GetDepressedKeyboardModifiers() const
+{
+ return mDepressedKeyboardModifiers;
+}
+
+void Seat::SetDepressedKeyboardModifiers( unsigned int modifiers)
+{
+ mDepressedKeyboardModifiers = modifiers;
+}
+
+void Seat::SetKeyRepeatInfo( unsigned int rate, unsigned int delay )
+{
+ mKeyRepeatRate = rate;
+ mKeyRepeatDelay = delay;
+}
+
+} // Internal
+} // Adaptor
+} // Dali
--- /dev/null
+#ifndef __DALI_WAYLAND_SEAT_H__
+#define __DALI_WAYLAND_SEAT_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <xkbcommon/xkbcommon.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/events/key-event.h>
+
+// INTERNAL INCLUDES
+#include <wl-types.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class InputInterface;
+
+/**
+ *
+ * A single seat is a group of keyboards, pointers and touch devices.
+ *
+ * For example you can have a car with 4 seats each with their own touch screen that
+ * is run by a central computer with a multi-display output.
+ *
+ * Or you may have two people / two seats in an office sharing the same screen at the same time.
+ *
+ *
+ * There is a single wl_pointer / wl_touch and wl_keyboard interface per seat.
+ * But each interface can have multiple devices. E.g. wl_pointer interface may have 2
+ * mouse pointers attached.
+ *
+ * Input devices can be hot plugged. However wl_pointer / wl_touch and wl_keyboard interface
+ * will only be destroyed when the interface has no devices associated with it.
+ * E.g. if a seat has a single mouse, when you unplug the mouse the interface is deleted.
+ * If a seat has two mice, only when you unplug both mice is the interface deleted.
+ *
+ */
+class Seat
+{
+
+public:
+
+ /**
+ * @brief Seat interface status for a device class ( keyboard, touch, pointer )
+ */
+ enum InterfaceStatus
+ {
+ INTERFACE_AVAILABLE,
+ INTERFACE_NOT_AVAILABLE,
+ };
+
+ /**
+ * @brief constructor
+ * @param[in] inputInterface input interface
+ * @param[in] seatInterface Wayland seat interface
+ */
+ Seat( InputInterface* inputInterface, WlSeat* seatInterface );
+
+ /**
+ * @brief non virtual destructor, not intended as base class
+ */
+ ~Seat();
+
+ /**
+ * @brief Set the pointer interface
+ * @param[in] pointer Wayland pointer interface
+ * @param[in] status of the interface
+ */
+ void SetPointerInterface( InterfaceStatus status );
+
+ /**
+ * @brief Set the touch interface
+ * @param[in] pointer Wayland pointer interface
+ * @param[in] status of the interface
+ */
+ void SetTouchInterface( InterfaceStatus status );
+
+ /**
+ * @brief Set the keyboard interface
+ * @param[in] pointer Wayland pointer interface
+ * @param[in] status of the interface
+ */
+ void SetKeyboardInterface( InterfaceStatus status );
+
+ /**
+ * @brief Get the pointer interface
+ * @return Wayland pointer interface
+ */
+ WlPointer* GetPointerInterface();
+
+ /**
+ * @brief Get the touch interface
+ * @return Wayland touch interface
+ */
+ WlTouch* GetTouchInterface();
+
+ /**
+ * @brief Get the keyboard interface
+ * @return Wayland keyboard interface
+ */
+ WlKeyboard* GetKeyboardInterface();
+
+ /**
+ * @brief Get the keyboard interface
+ * @return Wayland keyboard interface
+ */
+ WlSeat* GetSeatInterface();
+
+ /**
+ * @brief calls wl_pointer_destroy on the pointer interface
+ */
+ void DestroyPointerInterface();
+
+ /**
+ * @brief calls wl_touch_destroy on the touch interface
+ */
+ void DestroyTouchInterface();
+
+ /**
+ * @brief calls wl_touch_keyboard on the keyboard interface
+ */
+ void DestroyKeyboardInterface();
+
+ /**
+ * @brief place holder store the seat name
+ * Currently we don't store the name as DALi core isn't seat name aware
+ * Need to think about adding Seat name to touch / key events.
+ * @param[in] name seat name
+ */
+ void SetName( const char* name );
+
+ /**
+ * @brief get the seat name
+ * E.g. may return "front-passenger-seat"
+ * @return seat name
+ */
+ const std::string& GetName() const;
+
+ /**
+ * @brief get the last known pointer position
+ * @return pointer position
+ */
+ const Dali::Vector2& GetLastPointerPosition() const;
+
+ /**
+ * @brief set the pointer position
+ * So we need to cache mouse x/y position, for pointer down events which
+ * don't have x,y position attached
+ * @param[in] position pointer position
+ */
+ void SetPointerPosition( Dali::Vector2 position);
+
+ /**
+ * @brief keyboard mapping
+ * Provides a file descriptor which can be memory-mapped to a keyboard mapping description
+ * @param[in] seat the seat that produced the event
+ * @param[in] format see wl_keyboard_keymap_format
+ * @param[in] fd file descriptor
+ * @param[in] size size of the memory mapped region in bytes
+ */
+ void KeyboardKeymap( unsigned int format, int fd, unsigned int size );
+
+ /**
+ * @brief get current depressed keyboard modifiers (not latched)
+ * @return keyboard modifiers
+ */
+ unsigned int GetDepressedKeyboardModifiers() const ;
+
+ /**
+ * @brief get current depressed keyboard modifiers (not latched)
+ * @param[in] modifiers depressed keyboard modifiers
+ */
+ void SetDepressedKeyboardModifiers( unsigned int modifiers);
+
+ /**
+ * @brief set key repeat rate and delay
+ * @param[in] rate repeat rate in milliseconds
+ * @param[in] delay delay in milliseconds
+ */
+ void SetKeyRepeatInfo( unsigned int rate, unsigned int delay );
+
+ /**
+ * @brief Key has been pressed or released
+ *
+ * @param[in] seat the seat that produced the event
+ * @param[in] serial serial number
+ * @param[in] timestamp timestamp
+ * @param[in] keycode raw hardware key code
+ * @param[in] state
+ * @return Key event
+ */
+ KeyEvent GetDALiKeyEvent( unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state );
+
+
+private: // data specific to a single seat
+
+ /**
+ * Keyboard data
+ */
+ struct XkbData
+ {
+ XkbData()
+ :mContext( NULL ),
+ mKeymap( NULL ),
+ mState( NULL ),
+ mControlMask( 0 ),
+ mAltMask( 0 ),
+ mShiftMask( 0 ),
+ mControlDown( 0 ),
+ mShiftDown( 0 ),
+ mAltDown( 0 )
+ {
+
+ }
+ struct xkb_context *mContext;
+ struct xkb_keymap* mKeymap;
+ struct xkb_state* mState;
+ xkb_mod_mask_t mControlMask;
+ xkb_mod_mask_t mAltMask;
+ xkb_mod_mask_t mShiftMask;
+ bool mControlDown:1;
+ bool mShiftDown:1;
+ bool mAltDown:1;
+ };
+
+ XkbData mXkbData; ///< Keyboard data. Believe this can vary per seat
+ std::string mName; ///< Set name
+ WlPointer* mPointer; ///< Wayland Pointer interface ( for multiple pointers )
+ WlKeyboard* mKeyboard; ///< Wayland Keyboard interface ( for multiple keyboards )
+ WlTouch* mTouch; ///< Wayland Touch interface ( for multiple touch devices )
+ WlSeat* mWaylandSeat; ///< Wayland Seat interface
+ InputInterface* mInputInterface; ///< DALi Wayland Input interface
+ Vector2 mPointerPosition; ///< Current pointer X,Y position
+ unsigned int mDepressedKeyboardModifiers; ///< keyboard modifiers
+ unsigned int mKeyRepeatRate;
+ unsigned int mKeyRepeatDelay;
+
+
+};
+
+} // Internal
+} // Adaptor
+} // Dali
+
+#endif //__DALI_WAYLAND_SEAT_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "native-image-source-impl.h"
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+
+NativeImageSource* NativeImageSource::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+{
+ return NULL;
+}
+
+NativeImageSource::~NativeImageSource()
+{
+
+}
+
+Any NativeImageSource::GetNativeImageSource() const
+{
+ DALI_ASSERT_ALWAYS( false && "NativeImageSource::GetNativeImageSource() is not supported for Wayland." );
+ return Any();
+}
+
+bool NativeImageSource::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+{
+ return false;
+}
+
+bool NativeImageSource::EncodeToFile(const std::string& filename) const
+{
+ return false;
+}
+
+bool NativeImageSource::GlExtensionCreate()
+{
+ return false;
+}
+
+void NativeImageSource::GlExtensionDestroy()
+{
+}
+
+unsigned int NativeImageSource::TargetTexture()
+{
+ return 0;
+}
+
+
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
+#define __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <native-image-source.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class EglImageExtensions;
+
+/**
+ * Dali internal NativeImageSource.
+ */
+class NativeImageSource
+{
+public:
+
+ /**
+ * Create a new NativeImageSource internally.
+ * Depending on hardware the width and height may have to be a power of two.
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] depth color depth of the image.
+ * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+ * @return A smart-pointer to a newly allocated image.
+ */
+ static NativeImageSource* New(unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetNativeImageSource()
+ */
+ Any GetNativeImageSource() const;
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetPixels()
+ */
+ bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
+
+ /**
+ * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
+ */
+ bool EncodeToFile(const std::string& filename) const;
+
+ /**
+ * destructor
+ */
+ ~NativeImageSource();
+
+ /**
+ * @copydoc Dali::NativeImageSource::GlExtensionCreate()
+ */
+ bool GlExtensionCreate();
+
+ /**
+ * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
+ */
+ void GlExtensionDestroy();
+
+ /**
+ * @copydoc Dali::NativeImageSource::TargetTexture()
+ */
+ unsigned int TargetTexture();
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetWidth()
+ */
+ unsigned int GetWidth() const
+ {
+ return 0;
+ }
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetHeight()
+ */
+ unsigned int GetHeight() const
+ {
+ return 0;
+ }
+
+ /**
+ * @copydoc Dali::NativeImageSource::RequiresBlending()
+ */
+ bool RequiresBlending() const
+ {
+ return false;
+ }
+
+protected:
+
+ /**
+ * @brief constructor
+ */
+ NativeImageSource() {}
+
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "render-surface-wl.h"
+
+// EXTERNAL INCLUDES
+#include <stdio.h>
+#include <dali/integration-api/gl-abstraction.h>
+#include <dali/integration-api/debug.h>
+#include <cstring>
+#include <unistd.h>
+
+// INTERNAL INCLUDES
+#include <base/separate-update-render/thread-synchronization.h>
+#include <gl/egl-implementation.h>
+#include <trigger-event.h>
+#include <base/interfaces/window-event-interface.h>
+#include <wayland-manager.h>
+
+
+namespace Dali
+{
+
+namespace Wayland
+{
+
+RenderSurface::RenderSurface(Dali::PositionSize positionSize,
+ Any surface,
+ const std::string& name,
+ bool isTransparent)
+: mRenderNotification(NULL),
+ mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24)
+{
+ mWindow.mPosition = positionSize;
+ mWindow.mTitle = name;
+ mWaylandManager = new Dali::Internal::Adaptor::WaylandManager;
+ mWaylandManager->Initialise();
+}
+
+RenderSurface::~RenderSurface()
+{
+ delete mWaylandManager;
+}
+
+void RenderSurface::CreateSurface()
+{
+ mWaylandManager->CreateSurface( mWindow );
+}
+
+Window* RenderSurface::GetWindow()
+{
+ return &mWindow;
+}
+
+
+void RenderSurface::AssignWindowEventInterface( Dali::Internal::Adaptor::WindowEventInterface* eventInterface)
+{
+ mWaylandManager->AssignWindowEventInterface( eventInterface );
+}
+
+PositionSize RenderSurface::GetPositionSize() const
+{
+ return mWindow.mPosition;
+}
+
+void RenderSurface::InitializeEgl( EglInterface& egl )
+{
+ Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+
+ if (!eglImpl.InitializeGles(static_cast<EGLNativeDisplayType>( mWaylandManager->mDisplay )))
+ {
+ DALI_LOG_ERROR("Failed to initialize GLES.");
+ }
+
+ eglImpl.ChooseConfig( true, mColorDepth );
+}
+
+void RenderSurface::CreateEglSurface( EglInterface& egl )
+{
+ Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+
+ CreateSurface();
+
+ mEglWindow = wl_egl_window_create( mWaylandManager->GetSurface(), mWindow.mPosition.width, mWindow.mPosition.height);
+
+ eglImpl.CreateSurfaceWindow( (EGLNativeWindowType)mEglWindow, mColorDepth ); // reinterpret_cast does not compile
+
+}
+
+void RenderSurface::DestroyEglSurface( EglInterface& eglIf )
+{
+ Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
+ eglImpl.DestroySurface();
+ wl_egl_window_destroy( mEglWindow );
+ mEglWindow = NULL;
+}
+
+bool RenderSurface::ReplaceEGLSurface( EglInterface& egl )
+{
+ return true;
+}
+
+void RenderSurface::MoveResize( Dali::PositionSize positionSize )
+{
+}
+
+void RenderSurface::SetViewMode( ViewMode viewMode )
+{
+}
+
+void RenderSurface::StartRender()
+{
+}
+
+bool RenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
+{
+ return true;
+}
+
+void RenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface )
+{
+ Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+ eglImpl.SwapBuffers();
+}
+
+void RenderSurface::StopRender()
+{
+}
+
+void RenderSurface::ReleaseLock()
+{
+}
+void RenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
+{
+}
+
+
+
+} // namespace Wayland
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_RENDER_SURFACE_WL_H__
+#define __DALI_RENDER_SURFACE_WL_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <wayland-manager.h>
+#include <wayland-egl.h>
+
+// INTERNAL INCLUDES
+#include <wayland-window.h>
+#include <render-surface.h>
+#include <egl-interface.h> // for color depth
+
+namespace Dali
+{
+
+class TriggerEventInterface;
+
+namespace Internal
+{
+namespace Adaptor
+{
+class WaylandManager;
+class WindowEventInterface;
+}
+}
+
+namespace Wayland
+{
+
+
+/**
+ * Wayland render surface.
+ */
+class RenderSurface : public Dali::RenderSurface
+{
+public:
+
+ /**
+ * @brief Constructor.
+ *
+ * @param [in] positionSize the position and size of the surface
+ * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
+ * @param [in] name optional name of surface passed in
+ * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
+ */
+ RenderSurface(Dali::PositionSize positionSize,
+ Any surface,
+ const std::string& name,
+ bool isTransparent = false);
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~RenderSurface();
+
+protected:
+
+
+ /**
+ * @Create the surface
+ */
+ void CreateSurface();
+
+public:
+
+ /**
+ * @brief Get window handle
+ *
+ * @return the wayland window pointer
+ */
+ Window* GetWindow();
+
+ /**
+ * Assigns an event interface to the surface for getting
+ * input events / window notifications
+ */
+ void AssignWindowEventInterface( Dali::Internal::Adaptor::WindowEventInterface* eventInterface );
+
+public: // from Dali::RenderSurface
+
+ /**
+ * @copydoc Dali::RenderSurface::GetPositionSize()
+ */
+ virtual PositionSize GetPositionSize() const;
+
+ /**
+ * @copydoc Dali::RenderSurface::InitializeEgl()
+ */
+ virtual void InitializeEgl( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::RenderSurface::CreateEglSurface()
+ */
+ virtual void CreateEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::RenderSurface::DestroyEglSurface()
+ */
+ virtual void DestroyEglSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
+ */
+ virtual bool ReplaceEGLSurface( EglInterface& egl );
+
+ /**
+ * @copydoc Dali::RenderSurface::MoveResize()
+ */
+ virtual void MoveResize( Dali::PositionSize positionSize);
+
+ /**
+ * @copydoc Dali::RenderSurface::SetViewMode()
+ */
+ virtual void SetViewMode( ViewMode viewMode );
+
+ /**
+ * @copydoc Dali::RenderSurface::StartRender()
+ */
+ virtual void StartRender();
+
+ /**
+ * @copydoc Dali::RenderSurface::PreRender()
+ */
+ virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
+
+ /**
+ * @copydoc Dali::RenderSurface::PostRender()
+ */
+ virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface );
+
+ /**
+ * @copydoc Dali::RenderSurface::StopRender();
+ */
+ virtual void StopRender();
+
+ /**
+ * @copydoc Dali::RenderSurface::ReleaseLock()
+ */
+ virtual void ReleaseLock();
+
+ /**
+ * @copydoc Dali::RenderSurface::SetThreadSynchronization()
+ */
+ virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization );
+
+protected: // Data
+
+ Window mWindow;
+ TriggerEventInterface* mRenderNotification; ///< Render notification trigger
+ Dali::ColorDepth mColorDepth; ///< Color depth
+ Dali::Internal::Adaptor::WaylandManager* mWaylandManager; ///< wayland manager
+ wl_egl_window* mEglWindow;
+
+};
+
+} // namespace Wayland
+
+} // namespace Dali
+
+#endif // __DALI_RENDER_SURFACE_WL_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "wayland-manager.h"
+
+// EXTERNAL INCLUDES
+#include <stdio.h>
+#include <cstring>
+
+// INTERNAL INCLUDES
+#include <base/interfaces/window-event-interface.h>
+#include <base/interfaces/performance-interface.h>
+#include <input/input-listeners.h>
+#include <input/seat.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+namespace
+{
+
+void ShellSurfacePing( void* data, struct wl_shell_surface* shell_surface, uint32_t serial)
+{
+ // The ping event comes from the compositor to checks if we're still alive.
+ wl_shell_surface_pong(shell_surface, serial);
+}
+
+void ShellSurfaceConfigure( void* data, struct wl_shell_surface* shell_surface, uint32_t edges, int32_t width, int32_t height)
+{
+}
+
+const struct wl_shell_surface_listener ShellSurfaceListener =
+{
+ ShellSurfacePing,
+ ShellSurfaceConfigure,
+};
+
+
+void XdgShellPing( void* data, Dali::WlXdgShell* shell, uint32_t serial)
+{
+ // The ping event comes from the compositor to checks if we're still alive.
+ xdg_shell_pong( shell, serial);
+}
+
+struct xdg_shell_listener XdgShellListener=
+{
+ XdgShellPing,
+};
+
+void RegisterSeatListener( WaylandManager* client,
+ struct wl_registry *wlRegistry,
+ uint32_t name,
+ const char *interface,
+ uint32_t version)
+{
+ Dali::WlSeat* seatInterface = static_cast<Dali::WlSeat*>( wl_registry_bind( wlRegistry, name, &wl_seat_interface, version ));
+
+ Seat* seat = new Seat( &client->mInputManager, seatInterface );
+
+ client->mInputManager.AddSeat( seat );
+
+ // listen to seat events
+ wl_seat_add_listener( seatInterface, Wayland::GetSeatListener(), &client->mInputManager );
+
+}
+void RegistryGlobalCallback( void *data,
+ struct wl_registry *wlRegistry,
+ uint32_t name,
+ const char *interface,
+ uint32_t version)
+{
+
+ WaylandManager* client = static_cast< WaylandManager* >( data );
+
+ if (strcmp( interface, wl_compositor_interface.name) == 0)
+ {
+ client->mCompositor = static_cast<Dali::WlCompositor*>(wl_registry_bind( wlRegistry, name , &wl_compositor_interface, version ));
+ }
+ else if( strcmp( interface, wl_seat_interface.name) == 0 )
+ {
+ // register for seat callbacks and add a new seat to the input manager
+ RegisterSeatListener( client, wlRegistry, name, interface, version);
+ }
+ else if (strcmp(interface, wl_shell_interface.name) == 0)
+ {
+ client->mShell = static_cast<Dali::WlShell*>(wl_registry_bind( wlRegistry, name , &wl_shell_interface, version));
+ }
+ else if ( strcmp( interface, xdg_shell_interface.name ) == 0)
+ {
+ client->mXdgShell = static_cast< struct xdg_shell* >(wl_registry_bind(wlRegistry, name, &xdg_shell_interface, version));
+ // without this line Tizen 3 reports...
+ // xdg_shell@7: error 0: Must call use_unstable_version first
+ xdg_shell_use_unstable_version(client->mXdgShell, 5);
+ }
+
+
+}
+
+
+void RegistryGlobalCallbackRemove(void *data, struct wl_registry *registry, uint32_t id)
+{
+ // occurs when a device is unplugged
+}
+
+const struct wl_registry_listener RegistryListener =
+{
+ RegistryGlobalCallback,
+ RegistryGlobalCallbackRemove,
+};
+
+} //unnamed namespace
+
+WaylandManager::WaylandManager()
+:mDisplay( NULL ),
+ mShell( NULL ),
+ mCompositor( NULL ),
+ mDisplayFileDescriptor( 0 ),
+ mFileDescriptorMonitor( NULL ),
+ mXdgShell( NULL ),
+ mSurface( NULL ),
+ mShellSurface( NULL ),
+ mXdgSurface( NULL )
+{
+}
+WaylandManager::~WaylandManager()
+{
+ if( mXdgShell)
+ {
+ xdg_shell_destroy( mXdgShell );
+ }
+ if( mShell )
+ {
+ wl_shell_destroy( mShell );
+ }
+ if( mCompositor )
+ {
+ wl_compositor_destroy( mCompositor );
+ }
+ if( mDisplay )
+ {
+ wl_display_disconnect( mDisplay );
+ }
+
+ delete mFileDescriptorMonitor;
+}
+
+void WaylandManager::Initialise()
+{
+ if( mDisplay )
+ {
+ return;
+ }
+ // Connect to a Wayland socket on the Wayland server/
+ // NULL = use default display aka "wayland-0"
+ // returns a new display context object
+
+ mDisplay = wl_display_connect( NULL );
+
+ DALI_ASSERT_ALWAYS( mDisplay && "wl_display_connect failed");
+
+ // Monitor the display file descriptor used to communicate with Wayland server
+ InstallFileDescriptorMonitor();
+
+ // Get the interfaces to compositor / shell etc
+ GetWaylandInterfaces();
+
+}
+
+void WaylandManager::AssignWindowEventInterface( WindowEventInterface* eventInterface)
+{
+ mInputManager.AssignWindowEventInterface( eventInterface );
+}
+void WaylandManager::GetWaylandInterfaces()
+{
+ // get and listen to the registry
+ WlRegistry* registry = wl_display_get_registry( mDisplay );
+
+ wl_registry_add_listener( registry, &RegistryListener, this);
+
+ // send and receive, to trigger the registry listener callback
+ wl_display_roundtrip( mDisplay );
+
+ wl_registry_destroy( registry );
+}
+
+void WaylandManager::InstallFileDescriptorMonitor()
+{
+ // get the file descriptor
+ mDisplayFileDescriptor = wl_display_get_fd( mDisplay );
+
+ // create the callback that gets triggered when a read / write event occurs
+ CallbackBase* callback = MakeCallback( this, &WaylandManager::FileDescriptorCallback);
+
+ // monitor read and write events
+ int events = FileDescriptorMonitor::FD_READABLE;
+
+ mFileDescriptorMonitor = new FileDescriptorMonitor( mDisplayFileDescriptor, callback, events );
+
+}
+void WaylandManager::FileDescriptorCallback( FileDescriptorMonitor::EventType eventTypeMask )
+{
+ if( eventTypeMask & FileDescriptorMonitor::FD_READABLE )
+ {
+ // read and dispatch
+ wl_display_dispatch( mDisplay );
+ }
+}
+
+void WaylandManager::CreateSurface( Dali::Wayland::Window& window )
+{
+ // Create the surface
+ // A Wayland surface is a rectangular area that is displayed on the screen.
+ // It has a location, size and pixel contents.
+
+ mSurface = wl_compositor_create_surface( mCompositor );
+
+ DALI_ASSERT_ALWAYS( mSurface && "wl_compositor_create_surface failed" );
+
+ // keep track of the surface id
+ window.mSurfaceId = wl_proxy_get_id( reinterpret_cast<struct wl_proxy *>( mSurface ));
+
+ // A surface in Wayland needs to be assigned a role.
+ // This gives the surface the role of a shell surface.
+ // It allows the surface to be treated like a toplevel, fullscreen or popup window.
+ // which can be moved, resize or maximized and have associate metadata like title and class.
+ // Try the xdg shell first. XDG is a designed to create a desktop shell with features like minimise etc.
+ if( mXdgShell )
+ {
+ mXdgSurface = xdg_shell_get_xdg_surface( mXdgShell, mSurface );
+
+ DALI_ASSERT_ALWAYS( mXdgSurface&& "xdg_shell_get_xdg_surface failed" );
+
+ if( window.mTitle.length() )
+ {
+ xdg_surface_set_title( mXdgSurface, window.mTitle.c_str() );
+ }
+ xdg_shell_add_listener( mXdgShell, &XdgShellListener, 0);
+ }
+ else
+ {
+ // try the generic Wayland Shell
+ mShellSurface = wl_shell_get_shell_surface( mShell, mSurface );
+ DALI_ASSERT_ALWAYS( mShellSurface && "wl_shell_get_shell_surface failed" );
+
+ if( window.mTitle.length() )
+ {
+ wl_shell_surface_set_title( mShellSurface, window.mTitle.c_str() );
+ }
+
+ wl_shell_surface_set_toplevel( mShellSurface);
+
+ wl_shell_surface_add_listener( mShellSurface , &ShellSurfaceListener, 0);
+ }
+
+ // send / receive all commands
+ wl_display_roundtrip( mDisplay );
+}
+
+WlSurface* WaylandManager::GetSurface()
+{
+ return mSurface;
+}
+
+}
+}
+}
--- /dev/null
+#ifndef __DALI_WAYLAND_MANAGER_H__
+#define __DALI_WAYLAND_MANAGER_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <wayland-extension/xdg-shell-client-protocol.h> // from wayland
+
+// INTERNAL INCLUDES
+#include <wl-types.h>
+#include <file-descriptor-monitor.h>
+#include "input-manager.h"
+#include "wayland-window.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+
+
+class WindowEventInterface;
+class PerformanceInterface;
+
+/**
+ * Client used to talk to Wayland server over a UNIX domain stream socket.
+ *
+ * Brief overview of Wayland:
+ *
+ * Transport mechanism = Socket
+ * Display = handles all the data sent from and to the compositor
+ * Display has a file descriptor that can be monitored for read / write events
+ *
+ * wl client function calls will place messages in a queue
+ * Calling wl_display_flush() will flush the messages to the server
+ *
+ * Incoming data is handled in two steps: queueing and dispatching.
+ * In the queue step, the data coming from the display fd is interpreted and
+ * added to a queue. On the dispatch step, the handler for the incoming event is called.
+ *
+ * default queue is dispatched by calling wl_display_dispatch().
+ *
+ * The compositor sends out the frame event every time it draws a frame.
+ * wl_display_frame_callback() to schedule a callback per frame.
+ *
+ *
+ * wl_display_dispatch(). This will dispatch any events queued on the default queue and
+ * attempt to read from the display fd if it's empty.
+ * Events read are then queued on the appropriate queues according to the proxy assignment.
+ *
+ *
+ */
+class WaylandManager
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ */
+ WaylandManager();
+
+ /**
+ * @brief Destructor
+ */
+ ~WaylandManager();
+
+ /**
+ * @brief Connect to Wayland server and setup internal data structures
+ */
+ void Initialise();
+
+ /**
+ * @brief Assign window event interface.
+ * @param[in] eventInterface window event interface
+ */
+ void AssignWindowEventInterface( WindowEventInterface* eventInterface);
+
+ /**
+ * @brief create a surface for a window
+ * @param[in] window window object
+ */
+ void CreateSurface( Dali::Wayland::Window& window );
+
+ /**
+ * @brief get the wayland surface
+ * @return surface
+ */
+ WlSurface* GetSurface();
+
+private: // change to private
+
+ /**
+ * @brief Install file descriptor monitor
+ */
+ void InstallFileDescriptorMonitor();
+
+ /**
+ * @brief File descriptor callback function, triggered when wayland compositor
+ * sends an event to the client (us)
+ * @param[in] eventTypeMask
+ */
+ void FileDescriptorCallback( FileDescriptorMonitor::EventType eventTypeMask );
+
+ /**
+ * @brief helper to get wayland interfaces
+ */
+ void GetWaylandInterfaces();
+
+public:
+
+
+ InputManager mInputManager;
+ WlDisplay* mDisplay; ///< Wayland display, handles all the data sent from and to the compositor
+ WlShell* mShell; ///< shell
+ WlCompositor* mCompositor; ///< compositor
+ int mDisplayFileDescriptor; ///< File descriptor used by wayland client socket
+ FileDescriptorMonitor* mFileDescriptorMonitor; ///< File descriptor monitor
+ WlXdgShell* mXdgShell; ///< XDG Shell
+ WlSurface* mSurface; ///< Wayland surface
+ WlShellSurface* mShellSurface; ///< Shell surface
+ WlXdgShellSurface* mXdgSurface; ///< XDG Shell surface
+
+
+};
+} // Internal
+} // Adaptor
+} // Dali
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "wayland-window.h"
+
+namespace Dali
+{
+
+namespace Wayland
+{
+
+Window::Window()
+:mSurfaceId( 0 )
+{
+
+}
+
+Window::~Window()
+{
+}
+
+
+} // namespace Wayland
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_WAYLAND_WINDOW_H__
+#define __DALI_WAYLAND_WINDOW_H__
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/math/rect.h>
+#include <string>
+
+namespace Dali
+{
+
+typedef Dali::Rect<int> PositionSize;
+
+namespace Wayland
+{
+
+/**
+ * @brief Ecapsulates data for a wayland window.
+ */
+class Window
+{
+ public:
+
+ /**
+ * @brief constructor
+ */
+ Window();
+
+ /**
+ * @brief destructor. Non-virtual not intended as a base class.
+ */
+ ~Window();
+
+private:
+
+ // @brief Undefined copy constructor.
+ Window( const Window& );
+
+ // @brief Undefined assignment operator.
+ Window& operator=( const Window& );
+
+public:
+
+ std::string mTitle; ///< Window title
+ PositionSize mPosition; ///< Position
+ int mSurfaceId; ///< wayland surface id
+
+};
+
+
+} // namespace Wayland
+
+} // namespace Dali
+
+#endif // __DALI_WAYLAND_WINDOW_H__
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "window-impl.h"
+
+// EXTERNAL HEADERS
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/system-overlay.h>
+#include <dali/public-api/render-tasks/render-task.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <orientation.h>
+
+// INTERNAL HEADERS
+#include "render-surface/render-surface-wl.h"
+#include <drag-and-drop-detector-impl.h>
+#include <window-visibility-observer.h>
+#include <orientation-impl.h>
+
+
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
+#endif
+
+struct Window::EventHandler
+{
+ // place holder
+};
+
+Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
+{
+ Window* window = new Window();
+ window->mIsTransparent = isTransparent;
+ window->Initialize(posSize, name, className);
+ return window;
+}
+
+void Window::SetAdaptor(Dali::Adaptor& adaptor)
+{
+ DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
+ mStarted = true;
+
+ // Only create one overlay per window
+ Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
+ Integration::Core& core = adaptorImpl.GetCore();
+ mOverlay = &core.GetSystemOverlay();
+
+ Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
+ taskList.CreateTask();
+
+ mAdaptor = &adaptorImpl;
+ mAdaptor->AddObserver( *this );
+
+ // Can only create the detector when we know the Core has been instantiated.
+ mDragAndDropDetector = DragAndDropDetector::New();
+ mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
+
+
+}
+
+RenderSurface* Window::GetSurface()
+{
+ return mSurface;
+}
+
+void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
+{
+
+}
+
+void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
+{
+}
+
+void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
+{
+}
+
+void Window::SetClass(std::string name, std::string klass)
+{
+}
+
+Window::Window()
+: mSurface(NULL),
+ mIndicatorVisible(Dali::Window::VISIBLE),
+ mIndicatorIsShown(false),
+ mShowRotatedIndicatorOnClose(false),
+ mStarted(false),
+ mIsTransparent(false),
+ mWMRotationAppSet(false),
+ mIndicator(NULL),
+ mIndicatorOrientation(Dali::Window::PORTRAIT),
+ mNextIndicatorOrientation(Dali::Window::PORTRAIT),
+ mIndicatorOpacityMode(Dali::Window::OPAQUE),
+ mOverlay(NULL),
+ mAdaptor(NULL)
+{
+ mEventHandler = NULL;
+}
+
+Window::~Window()
+{
+ delete mEventHandler;
+
+ if ( mAdaptor )
+ {
+ mAdaptor->RemoveObserver( *this );
+ mAdaptor->SetDragAndDropDetector( NULL );
+ mAdaptor = NULL;
+ }
+
+ delete mSurface;
+}
+
+void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
+{
+ // create an Wayland window by default
+ Any surface;
+ Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
+
+ mSurface = windowSurface;
+
+ mOrientation = Orientation::New(this);
+
+}
+
+void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
+{
+
+}
+
+void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
+{
+
+}
+
+void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
+{
+}
+
+void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
+{
+}
+
+void Window::IndicatorClosed( IndicatorInterface* indicator )
+{
+
+}
+
+void Window::IndicatorVisibilityChanged(bool isVisible)
+{
+
+}
+
+void Window::SetIndicatorActorRotation()
+{
+
+}
+
+void Window::Raise()
+{
+}
+
+void Window::Lower()
+{
+}
+
+void Window::Activate()
+{
+}
+
+Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
+{
+ return mDragAndDropDetector;
+}
+
+Dali::Any Window::GetNativeHandle() const
+{
+ Wayland::RenderSurface* surface = static_cast< Wayland::RenderSurface* >( mSurface );
+
+ return surface->GetWindow();
+}
+
+void Window::OnStart()
+{
+}
+
+void Window::OnPause()
+{
+}
+
+void Window::OnResume()
+{
+}
+
+void Window::OnStop()
+{
+}
+
+void Window::OnDestroy()
+{
+ mAdaptor = NULL;
+}
+
+void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
+{
+ bool found = false;
+
+ for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
+ {
+ if(mAvailableOrientations[i] == orientation)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if( ! found )
+ {
+ mAvailableOrientations.push_back(orientation);
+ SetAvailableOrientations( mAvailableOrientations );
+ }
+}
+
+void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
+{
+ for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
+ iter != mAvailableOrientations.end(); ++iter )
+ {
+ if( *iter == orientation )
+ {
+ mAvailableOrientations.erase( iter );
+ break;
+ }
+ }
+ SetAvailableOrientations( mAvailableOrientations );
+}
+
+void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
+{
+ DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
+}
+
+const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
+{
+ return mAvailableOrientations;
+}
+
+void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
+{
+ mPreferredOrientation = orientation;
+}
+
+Dali::Window::WindowOrientation Window::GetPreferredOrientation()
+{
+ return mPreferredOrientation;
+}
+
+void Window::RotationDone( int orientation, int width, int height )
+{
+}
+
+//} // Wayland
+} // Adaptor
+} // Internal
+} // Dali
adaptor_common_dir = ../../../adaptors/common
include ../../../adaptors/common/file.list
+if USE_EFL
# ECore Common
adaptor_ecore_common_dir = ../../../adaptors/ecore/common
include ../../../adaptors/ecore/common/file.list
+else
+# If we're not using any EFL, then we need to use libuv mainloop
+# for the frame work
+adaptor_libuv_dir = ../../../adaptors/libuv
+include ../../../adaptors/libuv/file.list
+endif
# Wayland
if WAYLAND
+if USE_EFL
+## Use ecore_wayland
adaptor_ecore_wayland_dir = ../../../adaptors/ecore/wayland
include ../../../adaptors/ecore/wayland/file.list
else
+## Use wayland
+adaptor_wayland_dir = ../../../adaptors/wayland
+include ../../../adaptors/wayland/file.list
+endif
+else
# X11
adaptor_x11_dir = ../../../adaptors/x11
include ../../../adaptors/x11/file.list
############# source files #############
+# FRAMEWORK FILES for adaptor
+# Either use ecore mainloop + appcore / uiman
+# Or libuv main loop with no appcore / uimain
+if USE_EFL
+adaptor_internal_src_files = $(adaptor_tizen_framework_efl_src_files) \
+ $(adaptor_ecore_common_internal_src_files)
+else
+adaptor_internal_src_files = $(adaptor_tizen_framework_libuv_src_files)
+endif
+
# COMMON
if COMMON_PROFILE
-adaptor_internal_src_files = $(adaptor_common_internal_src_files) \
- $(adaptor_common_internal_default_profile_src_files) \
- $(adaptor_ecore_common_internal_src_files) \
- $(adaptor_tizen_internal_src_files) \
- $(adaptor_tizen_internal_non_mobile_src_files) \
- $(static_libraries_libunibreak_src_files)
+adaptor_internal_src_files += $(adaptor_common_internal_src_files) \
+ $(adaptor_common_internal_default_profile_src_files) \
+ $(adaptor_tizen_internal_src_files) \
+ $(adaptor_tizen_internal_non_mobile_src_files) \
+ $(static_libraries_libunibreak_src_files)
if WAYLAND
-adaptor_internal_src_files += $(adaptor_wayland_tizen_internal_src_files) \
- $(adaptor_wayland_internal_default_profile_src_files)
+if USE_ECORE_WAYLAND
+adaptor_internal_src_files += $(adaptor_ecore_wayland_tizen_internal_src_files) \
+ $(adaptor_ecore_wayland_internal_default_profile_src_files)
+else
+adaptor_internal_src_files += $(adaptor_wayland_tizen_internal_src_files)
+endif
else
adaptor_internal_src_files += $(adaptor_x11_tizen_internal_src_files) \
$(adaptor_x11_internal_default_profile_src_files)
# UBUNTU
if UBUNTU_PROFILE
-adaptor_internal_src_files = $(adaptor_common_internal_src_files) \
+adaptor_internal_src_files += $(adaptor_common_internal_src_files) \
$(adaptor_common_internal_default_profile_src_files) \
- $(adaptor_ecore_common_internal_src_files) \
$(adaptor_ubuntu_internal_src_files) \
$(adaptor_x11_ubuntu_internal_src_files) \
$(adaptor_x11_internal_default_profile_src_files) \
# MOBILE
if MOBILE_PROFILE
-adaptor_internal_src_files = $(adaptor_common_internal_src_files) \
+adaptor_internal_src_files += $(adaptor_common_internal_src_files) \
$(adaptor_common_internal_mobile_profile_src_files) \
- $(adaptor_ecore_common_internal_src_files) \
$(adaptor_tizen_internal_src_files) \
$(static_libraries_libunibreak_src_files)
if WAYLAND
+if USE_ECORE_WAYLAND
+adaptor_internal_src_files += $(adaptor_ecore_wayland_tizen_internal_src_files)
+else
adaptor_internal_src_files += $(adaptor_wayland_tizen_internal_src_files)
+endif
else
adaptor_internal_src_files += $(adaptor_x11_tizen_internal_src_files)
endif # WAYLAND
# WEARABLE
if WEARABLE_PROFILE
-adaptor_internal_src_files = $(adaptor_common_internal_src_files) \
+adaptor_internal_src_files += $(adaptor_common_internal_src_files) \
$(adaptor_common_internal_mobile_profile_src_files) \
- $(adaptor_ecore_common_internal_src_files) \
$(adaptor_tizen_internal_src_files) \
$(static_libraries_libunibreak_src_files)
if WAYLAND
+if USE_ECORE_WAYLAND
+adaptor_internal_src_files += $(adaptor_ecore_wayland_tizen_internal_src_files)
+else
adaptor_internal_src_files += $(adaptor_wayland_tizen_internal_src_files)
+endif
else
adaptor_internal_src_files += $(adaptor_x11_tizen_internal_src_files)
endif # WAYLAND
# TV
if TV_PROFILE
-adaptor_internal_src_files = $(adaptor_common_internal_src_files) \
+adaptor_internal_src_files += $(adaptor_common_internal_src_files) \
$(adaptor_common_internal_tv_profile_src_files) \
- $(adaptor_ecore_common_internal_src_files) \
$(adaptor_tizen_internal_src_files) \
$(adaptor_tizen_internal_non_mobile_src_files) \
$(static_libraries_libunibreak_src_files)
if WAYLAND
+if USE_ECORE_WAYLAND
+adaptor_internal_src_files += $(adaptor_ecore_wayland_tizen_internal_src_files)
+else
adaptor_internal_src_files += $(adaptor_wayland_tizen_internal_src_files)
+endif
else
adaptor_internal_src_files += $(adaptor_x11_tv_internal_src_files) \
$(adaptor_x11_internal_tv_profile_key_src_files)
-I../../../text/dali/internal/libunibreak
if WAYLAND
+libdali_adaptor_la_includes += -I../../../adaptors/integration-api/wayland
+if USE_ECORE_WAYLAND
libdali_adaptor_la_includes += \
-I../../../adaptors/ecore/common \
- -I../../../adaptors/ecore/wayland \
- -I../../../adaptors/integration-api/wayland
+ -I../../../adaptors/ecore/wayland
+else
+libdali_adaptor_la_includes += -I../../../adaptors/wayland \
+ -I../../../adaptors/wayland/imf \
+ -I../../../adaptors/wayland/clipboard \
+ -I../../../adaptors/wayland/native-image
+endif
else
libdali_adaptor_la_includes += \
-I../../../adaptors/ecore/common \
$(FREETYPE_CFLAGS) \
$(FONTCONFIG_CFLAGS) \
$(PNG_CFLAGS) \
- $(CAPI_APPFW_APPLICATION_CFLAGS) \
- $(CAPI_SYSTEM_INFO_CFLAGS) \
- $(ELEMENTARY_CFLAGS) \
- $(EVAS_CFLAGS) \
- $(ECORE_CFLAGS) \
- $(ECORE_IPC_CFLAGS) \
$(DLOG_CFLAGS) \
$(VCONF_CFLAGS) \
$(EXIF_CFLAGS) \
$(MMFSOUND_CFLAGS) \
$(TTS_CFLAGS) \
- $(SENSOR_CFLAGS) \
$(LIBDRM_CFLAGS) \
$(LIBEXIF_CFLAGS) \
- $(LIBCURL_CFLAGS) \
- $(CAPI_SYSTEM_SYSTEM_SETTINGS_CFLAGS) \
- $(ELDBUS_CFLAGS)
+ $(LIBCURL_CFLAGS)
+
+# Todo, as soon as common repos are updated on build server remove this.
+if !COMMON_PROFILE
+libdali_adaptor_la_CXXFLAGS += -DWAYLAND_EXTENSIONS_SUPPORTED
+endif
libdali_adaptor_la_CFLAGS = $(libdali_adaptor_la_CXXFLAGS)
$(FREETYPE_LIBS) \
$(FONTCONFIG_LIBS) \
$(PNG_LIBS) \
- $(ELEMENTARY_LIBS) \
- $(ECORE_IPC_LIBS) \
$(DLOG_LIBS) \
$(VCONF_LIBS) \
$(EXIF_LIBS) \
$(TTS_LIBS) \
- $(SENSOR_LIBS) \
$(LIBDRM_LIBS) \
$(LIBEXIF_LIBS) \
$(LIBCURL_LIBS) \
- $(CAPI_SYSTEM_SYSTEM_SETTINGS_LIBS) \
- $(CAPI_APPFW_APPLICATION_LIBS) \
$(HARFBUZZ_LIBS) \
- $(CAPI_SYSTEM_INFO_LIBS) \
- $(ELDBUS_LIBS) \
-lgif \
-lpthread \
-lturbojpeg
+if USE_EFL
+# EVAS used indicator
+libdali_adaptor_la_CXXFLAGS += $(ELEMENTARY_CFLAGS) \
+ $(EVAS_CFLAGS) \
+ $(ECORE_CFLAGS) \
+ $(ECORE_IPC_CFLAGS) \
+ $(ELDBUS_CFLAGS) \
+ -DUSE_EFL
+
+
+libdali_adaptor_la_LIBADD += $(ELEMENTARY_LIBS) \
+ $(ECORE_IPC_LIBS) \
+ $(ELDBUS_LIBS)
+
+endif
+
+if USE_APPFW
+
+libdali_adaptor_la_CXXFLAGS += $(CAPI_APPFW_APPLICATION_CFLAGS) \
+ $(CAPI_SYSTEM_SYSTEM_SETTINGS_CFLAGS) \
+ $(CAPI_SYSTEM_INFO_CFLAGS) \
+ $(TTS_CFLAGS) \
+ $(SENSOR_CFLAGS)
+
+libdali_adaptor_la_LIBADD += $(CAPI_APPFW_APPLICATION_LIBS) \
+ $(CAPI_SYSTEM_SYSTEM_SETTINGS_LIBS) \
+ $(CAPI_SYSTEM_INFO_LIBS) \
+ $(TTS_LIBS) \
+ $(SENSOR_LIBS)
+
+endif
if WAYLAND
# This is to avoid having to include wayland-egl.h everywhere
libdali_adaptor_la_CXXFLAGS += -DWL_EGL_PLATFORM
FREETYPE_BITMAP_SUPPORT_VERSION=17.1.11
PKG_CHECK_MODULES(DALICORE, dali-core)
-PKG_CHECK_MODULES(ELEMENTARY, elementary)
-PKG_CHECK_MODULES(ECORE, ecore)
-PKG_CHECK_MODULES(ECORE_IPC, ecore-ipc)
PKG_CHECK_MODULES(EXIF, libexif)
PKG_CHECK_MODULES(FREETYPE, [freetype2 >= $FREETYPE_REQUIRED])
PKG_CHECK_MODULES(FREETYPE_BITMAP_SUPPORT, [freetype2 >= $FREETYPE_BITMAP_SUPPORT_VERSION], [ freetype_bitmap_support=yes ], [ freetype_bitmap_support=no ] )
PKG_CHECK_MODULES(TTRACE, ttrace, AC_DEFINE(ENABLE_TTRACE, 1, [ttrace available]),
[ AC_MSG_NOTICE([Tizen Trace not avaiable]) ]
)
-PKG_CHECK_MODULES(ECORE_IMF, [ecore-imf >= 1.13], [ecore_imf_1_13=yes], [ecore_imf_1_13=no])
+AC_ARG_ENABLE([efl],
+ [AC_HELP_STRING([--enable-efl],
+ [Builds with EFL libraries, On by default])],
+ [enable_efl=$enableval],
+ [enable_efl=yes])
+
+
+
+# Check if we need EFL Libraries ( on by default, disabled with --use-efl=no )
+# When running on Node.JS with Wayland no EFL libraries are required.
+if test "x$enable_efl" = "xyes"; then
+PKG_CHECK_MODULES(ECORE, ecore)
+PKG_CHECK_MODULES(ECORE_IPC, ecore-ipc)
+PKG_CHECK_MODULES(ECORE_IMF, [ecore-imf >= 1.13], [ecore_imf_1_13=yes], [ecore_imf_1_13=no])
+PKG_CHECK_MODULES(ELEMENTARY, elementary)
# Check for EldBus.h in ECore
PKG_CHECK_MODULES(ELDBUS, eldbus, [ eldbus_available=yes ], [ eldbus_available=no ] )
+fi
+
DALI_ELDBUS_AVAILABLE=
if test "x$eldbus_available" = "xyes"; then
# a libuv headers/ shared library. So we can't use pkg-config to access any headers.
# As a work around we pass the node deps path so we can access the libuv headers inside nodes
# directory
-AC_ARG_WITH([node-js],
- [AC_HELP_STRING([--with-node-js],
- [Node.JS path that contains Lib UV headers. Setting this configures DALi to work with LibUV mainloop used in Node.JS.
- For example /usr/tmp/downloads/node-v0.12.4/deps/uv/include/ ])],
- [with_node_js=$withval],
- [with_node_js=no])
+AC_ARG_WITH([libuv],
+ [AC_HELP_STRING([--with-libuv],
+ [Path that contains libuv headers. Setting this configures DALi to work with LibUV mainloop used in Node.JS.
+ For example /usr/tmp/downloads/node/deps/uv/include/ ])],
+ [with_libuv=$withval],
+ [with_libuv=no])
# Node.JS already has a libuv main loop running,so we have to integrate with it
-AM_CONDITIONAL(LIB_UV_EVENT_LOOP, test x$with_node_js != xno)
+AM_CONDITIONAL(LIB_UV_EVENT_LOOP, test x$with_libuv != xno)
-build_for_node_js=no
-if test "x$with_node_js" != "xno"; then
- AC_MSG_NOTICE("build for node_js == yes");
- [build_for_node_js=yes]
- DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DNODE_JS_SUPPORT -I${with_node_js}"
+build_for_libuv=no
+if test "x$with_libuv" != "xno"; then
+ AC_MSG_NOTICE("build with libuv mainloop (Node.JS support) == yes");
+ [build_for_libuv=yes]
+ DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DNODE_JS_SUPPORT -I${with_libuv}"
else
- #not using node.js build
- AC_MSG_NOTICE("build for node_js == no");
+ #not using libuv build
+ AC_MSG_NOTICE("build with libuv mainloop == no (Node.JS not supported)");
fi
+AC_ARG_ENABLE([appfw],
+ [AC_HELP_STRING([--enable-appfw],
+ [Builds with Tizen App framework libraries, off by default])],
+ [enable_appfw=$enableval],
+ [enable_appfw=no])
+
# Option to allow building with Tizen SDK 2.2
AC_ARG_WITH([tizen-2-2-compatibility],
[AC_HELP_STRING([--with-tizen-2-2-compatibility],
DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DDALI_PROFILE_${enable_profile}"
DALI_PROFILE_CFLAGS=" -DDALI_PROFILE_${enable_profile}"
AM_CONDITIONAL([COMMON_PROFILE], [test x$enable_profile = xCOMMON])
-AM_CONDITIONAL([WAYLAND_EXTENSIONS_SUPPORTED], [test x$enable_profile != xCOMMON])
AM_CONDITIONAL([MOBILE_PROFILE], [test x$enable_profile = xMOBILE])
AM_CONDITIONAL([WEARABLE_PROFILE], [test x$enable_profile = xWEARABLE])
AM_CONDITIONAL([TV_PROFILE], [test x$enable_profile = xTV])
AM_CONDITIONAL([UBUNTU_PROFILE], [test x$enable_profile = xUBUNTU])
AM_CONDITIONAL([WAYLAND], [test x$enable_wayland = xyes])
+AM_CONDITIONAL([USE_EFL], [test x$enable_efl = xyes])
+AM_CONDITIONAL([USE_APPFW], [test x$enable_appfw = xyes])
AM_CONDITIONAL([ENABLE_NETWORK_LOGGING], [test x$enable_networklogging = xyes])
if test "x$enable_profile" = "xUBUNTU"; then
PKG_CHECK_MODULES(OPENGLES20, glesv2 egl)
else
-PKG_CHECK_MODULES(CAPI_APPFW_APPLICATION, capi-appfw-application)
+
+
+
PKG_CHECK_MODULES(DLOG, dlog)
PKG_CHECK_MODULES(SENSOR, sensor)
PKG_CHECK_MODULES(TTS, tts)
PKG_CHECK_MODULES(VCONF, vconf)
-PKG_CHECK_MODULES(CAPI_SYSTEM_SYSTEM_SETTINGS, capi-system-system-settings)
-
+if test "x$enable_efl" = "xyes"; then
if test "x$with_tizen_2_2_compatibility" = "xno"; then
PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, capi-system-info)
fi
+fi
fi # ubuntu profile test
+if test "x$enable_appfw" = "xyes"; then
+PKG_CHECK_MODULES(CAPI_APPFW_APPLICATION, capi-appfw-application)
+PKG_CHECK_MODULES(CAPI_SYSTEM_SYSTEM_SETTINGS, capi-system-system-settings)
+fi
+
+# Using EFL api's for WAYLAND AND X11 to run on ecore mainloop
+if test "x$enable_efl" = "xyes"; then
if test "x$enable_wayland" = "xyes"; then
PKG_CHECK_MODULES(WAYLAND, [ecore-wayland egl wayland-egl wayland-client >= 1.2.0 xkbcommon],
- [DALI_HAS_ECOREWL=yes],
- [DALI_HAS_ECOREWL=no])
+ [DALI_USE_ECORE_WAYLAND=1],
+ [DALI_USE_ECORE_WAYLAND=0])
+else
+PKG_CHECK_MODULES(ECORE_X, [ecore-x],
+ [DALI_USE_ECORE_X11=1],
+ [DALI_USE_ECORE_X11=0])
+PKG_CHECK_MODULES(X11, [x11],
+ [DALI_USE_X11=1],
+ [DALI_USE_X11=0])
+fi
+fi
+# Using Wayland API directly ( main loop agnostic, typically for running on libuv)
+# wayland-extension-client include xdg-shell-client
+if test "x$enable_efl" = "xno"; then
+if test "x$enable_wayland" = "xyes"; then
+PKG_CHECK_MODULES(WAYLAND, [ egl wayland-egl wayland-client >= 1.2.0 xkbcommon],
+ [DALI_USE_WAYLAND=1],
+ [DALI_USE_WAYLAND=0])
+fi
+fi
+
+# remove this when we update common repos
# common profile currently does not have wayland extensions like xdg-shell
+if test "x$enable_wayland" = "xyes"; then
if test "x$enable_profile" != "xCOMMON"; then
PKG_CHECK_MODULES(WAYLAND_EXTENSION, xdg-shell-client)
fi
-else
-PKG_CHECK_MODULES(ECORE_X, [ecore-x],
- [DALI_HAS_ECOREX=yes],
- [DALI_HAS_ECOREX=no])
-PKG_CHECK_MODULES(X11, [x11],
- [DALI_HAS_X11=yes],
- [DALI_HAS_X11=no])
fi
+AM_CONDITIONAL([USE_ECORE_WAYLAND], [test "$DALI_USE_ECORE_WAYLAND" -eq 1])
if test "x$enable_feedback" = "xyes"; then
Tizen SDK 2.2 compatibility: $with_tizen_2_2_compatibility
EldBus: $eldbus_available
Shader Binary Cache: $enable_shaderbincache
- Build for Node.JS (LibUV) $build_for_node_js
+ Using LibUV mainloop (Node.JS) $build_for_libuv
Ecore Version At Least 1.13.0 $ecore_imf_1_13
Network logging enabled: $enable_networklogging
Font config file: $fontConfigurationFile
+ Building with EFL Libraries $enable_efl
+ Using Tizen APP FW libraries $enable_appfw
"
-# optional output of node.js source path if we're building for node.js
-if test "x$build_for_node_js" != "xno"; then
-echo " Node.JS LibUV header path $with_node_js"
+# optional output of node.js source path if we're building with libuv
+if test "x$build_for_libuv" != "xno"; then
+echo " LibUV header path $with_libuv"
fi
+# NOTES
+# This spec file is used to build DALi Adaptor for different Tizen Profiles
+# Current profiles are: Mobile, TV, Wearable, Common
+#
+# The profile variable is defined outside of the spec file in a build.conf file.
+# It will contain the profile and whether or not to build with X11 or Wayland
+#
+# gbs will try to download the build.conf for the platform automatically from the repo location when
+# performing a gbs build ( use gbs build -v to see it download location) E.g.
+# http://download.tizen.org/snapshots/tizen/tv/tizen-tv/repos/arm-wayland/packages/repodata/xxxx-build.conf.gz
+
+
%bcond_with wayland
Name: dali-adaptor
%define shaderbincache_flag DISABLE
%endif
+# macro is enabled by passing gbs build --define "with_libuv 1"
+%define build_with_libuv 0%{?with_libuv:1}
+
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
Requires: giflib
BuildRequires: pkgconfig(aul)
BuildRequires: giflib-devel
BuildRequires: pkgconfig(fontconfig)
-BuildRequires: pkgconfig(elementary)
-BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: libjpeg-turbo-devel
-BuildRequires: pkgconfig(evas)
BuildRequires: dali-devel
BuildRequires: dali-integration-devel
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(dlog)
BuildRequires: libdrm-devel
BuildRequires: pkgconfig(libexif)
-BuildRequires: pkgconfig(capi-system-system-settings)
BuildRequires: pkgconfig(libpng)
BuildRequires: pkgconfig(glesv2)
-BuildRequires: pkgconfig(egl)
BuildRequires: libcurl-devel
+BuildRequires: pkgconfig(harfbuzz)
+
+BuildRequires: fribidi-devel
+
%if 0%{?tizen_2_2_compatibility} != 1
BuildRequires: pkgconfig(capi-system-info)
%endif
+%if 0%{?build_with_libuv}
+# Tizen currently does not have libuv as a separate libuv package
+# So we have to look into the uv headers bundled inside node-js
+BuildRequires: nodejs-devel
+%endif
+
+
+
+%define dali_needs_efl_libraries 1
+%define dali_needs_appfw_libraries 1
%if %{with wayland}
-BuildRequires: pkgconfig(ecore-wayland)
+
+####### BUILDING FOR WAYLAND #######
BuildRequires: pkgconfig(wayland-egl)
BuildRequires: pkgconfig(wayland-client)
BuildRequires: wayland-devel
-# Currently Tizen Common does not use wayland extensions like xdg-shell
+# Currently Tizen Common we use does not have wayland extensions like xdg-shell
%if "%{profile}" != "common"
-BuildRequires: pkgconfig(wayland-extension-client)
BuildRequires: wayland-extension-client-devel
%endif
+%if %{build_with_libuv}
+####### BUILDING FOR PURE WAYLAND #######
+# if we're building with wayland and runnning under node.js then we are using libuv mainloop
+# and DALis own wayland client (it needs wayland-client headers).
+# EFL libraries and APP Framework libraries are not required in this case
+%define dali_needs_efl_libraries 0
+%define dali_needs_appfw_libraries 0
+BuildRequires: libxkbcommon-devel
%else
+####### BUILDING FOR ECORE WAYLAND #######
+BuildRequires: pkgconfig(ecore-wayland)
+%endif
+####### BUILDING FOR X11#######
+%else
+BuildRequires: pkgconfig(egl)
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(xi)
BuildRequires: pkgconfig(xfixes)
BuildRequires: pkgconfig(utilX)
%endif
-BuildRequires: pkgconfig(harfbuzz)
-BuildRequires: fribidi-devel
+###### Building with EFL libraries
+%if 0%{?dali_needs_efl_libraries}
+BuildRequires: pkgconfig(evas)
+BuildRequires: pkgconfig(elementary)
+%endif
+
+###### Build with APP Framework
+%if 0%{?dali_needs_appfw_libraries}
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-system-system-settings)
+%endif
+
+%if 0%{?over_tizen_2_2}
+BuildRequires: pkgconfig(capi-system-info)
+%endif
+
+
+
+
%description
The DALi Tizen Adaptor provides a Tizen specific implementation of the dali-core
%endif
%if 0%{?tizen_2_2_compatibility}
--with-tizen-2-2-compatibility \
+%endif
+%if 0%{?dali_needs_efl_libraries}
+ --enable-efl=yes \
+%else
+ --enable-efl=no \
+%endif
+%if 0%{?dali_needs_appfw_libraries}
+ --enable-appfw=yes \
+%else
+ --enable-appfw=no \
+%endif
+%if %{?build_with_libuv}
+ --with-libuv=/usr/include/node/ \
%endif
$configure_flags --libdir=%{_libdir}