public:
typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
typedef Dali::DevelWindow::FocusSignalType FocusSignalType;
+ typedef Dali::DevelWindow::ResizedSignalType ResizedSignalType;
typedef Signal< void () > SignalType;
/**
IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
/**
- * The user should connect to this signal to get a timing when window gains focus or loses focus.
+ * @copydoc Dali::DevelWindow::FocusChangedSignal()
*/
FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
/**
+ * @copydoc Dali::DevelWindow::ResizedSignal()
+ */
+ ResizedSignalType& ResizedSignal() { return mResizedSignal; }
+
+ /**
* This signal is emitted when the window is requesting to be deleted
*/
SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
// Signals
IndicatorSignalType mIndicatorVisibilityChangedSignal;
FocusSignalType mFocusChangedSignal;
+ ResizedSignalType mResizedSignal;
SignalType mDeleteRequestSignal;
};
return GetImplementation( window ).GetBrightness();
}
+ResizedSignalType& ResizedSignal( Window window )
+{
+ return GetImplementation( window ).ResizedSignal();
+}
+
} // namespace DevelWindow
} // namespace Dali
};
typedef Signal< void (bool) > FocusSignalType; ///< Window focus signal type
+typedef Signal< void (int, int) > ResizedSignalType; ///< Window resized signal type
/**
* @brief The user should connect to this signal to get a timing when window gains focus or loses focus.
*/
DALI_IMPORT_API int GetBrightness( Window window );
+/**
+ * @brief This signal is emitted when the window is resized.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName( int width, int height );
+ * @endcode
+ * The parameters are the resized width and height.
+ *
+ * @param[in] window The window to get a signal
+ * @return The signal to connect to
+ */
+DALI_IMPORT_API ResizedSignalType& ResizedSignal( Window window );
+
} // namespace DevelWindow
} // namespace Dali
Impl( EventHandler* handler, Ecore_Wl_Window* window )
: mHandler( handler ),
mEcoreEventHandler(),
- mWindow( window )
+ mWindow( window ),
+ mRotationAngle( 0 ),
+ mWindowWidth( 0 ),
+ mWindowHeight( 0 )
#ifdef DALI_ELDBUS_AVAILABLE
, mSystemConnection( NULL )
#endif // DALI_ELDBUS_AVAILABLE
RotationEvent rotationEvent;
rotationEvent.angle = ev->angle;
rotationEvent.winResize = 0;
- rotationEvent.width = ev->w;
- rotationEvent.height = ev->h;
+
+ if( ev->angle == 0 || ev->angle == 180 )
+ {
+ rotationEvent.width = ev->w;
+ rotationEvent.height = ev->h;
+ }
+ else
+ {
+ rotationEvent.width = ev->h;
+ rotationEvent.height = ev->w;
+ }
+
handler->SendRotationPrepareEvent( rotationEvent );
return ECORE_CALLBACK_PASS_ON;
handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
}
+ void ConvertTouchPosition( Integration::Point& point )
+ {
+ Vector2 position = point.GetScreenPosition();
+ Vector2 convertedPosition;
+
+ switch( mRotationAngle )
+ {
+ case 90:
+ {
+ convertedPosition.x = mWindowWidth - position.y;
+ convertedPosition.y = position.x;
+ break;
+ }
+ case 180:
+ {
+ convertedPosition.x = mWindowWidth - position.x;
+ convertedPosition.y = mWindowHeight - position.y;
+ break;
+ }
+ case 270:
+ {
+ convertedPosition.x = position.y;
+ convertedPosition.y = mWindowHeight - position.x;
+ break;
+ }
+ default:
+ {
+ convertedPosition = position;
+ break;
+ }
+ }
+
+ point.SetScreenPosition( convertedPosition );
+ }
+
// Data
EventHandler* mHandler;
std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
Ecore_Wl_Window* mWindow;
+ int mRotationAngle;
+ int mWindowWidth;
+ int mWindowHeight;
#ifdef DALI_ELDBUS_AVAILABLE
Eldbus_Connection* mSystemConnection;
#endif // DALI_ELDBUS_AVAILABLE
timeStamp = GetCurrentMilliSeconds();
}
+ mImpl->ConvertTouchPosition( point );
+
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.GetDeviceId(), point.GetState(), point.GetLocalPosition().x, point.GetLocalPosition().y);
+ DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y);
// First the touch and/or hover event & related gesture events are queued
if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
{
if( mRotationObserver != NULL )
{
+ mImpl->mRotationAngle = event.angle;
+ mImpl->mWindowWidth = event.width;
+ mImpl->mWindowHeight = event.height;
+
mRotationObserver->OnRotationPrepare( event );
mRotationObserver->OnRotationRequest();
}
{
#if defined(DEBUG_ENABLED)
-Debug::Filter* gRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_ECORE_X_RENDER_SURFACE");
+Debug::Filter* gRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_ECORE_WL_RENDER_SURFACE");
#endif
namespace ECore
mEventHandler( NULL ),
mPreferredOrientation( Dali::Window::PORTRAIT ),
mSupportedAuxiliaryHints(),
- mAuxiliaryHints()
+ mAuxiliaryHints(),
+ mIndicatorVisibilityChangedSignal(),
+ mFocusChangedSignal(),
+ mResizedSignal(),
+ mDeleteRequestSignal()
{
}
void Window::RotationDone( int orientation, int width, int height )
{
- ecore_wl_window_rotation_change_done_send( mEventHandler->mEcoreWindow );
+ PositionSize positionSize( 0, 0, width, height );
+
+ mAdaptor->SurfaceSizeChanged( positionSize );
+
+ // Emit signal
+ mResizedSignal.Emit( positionSize.width, positionSize.height );
+
+ Dali::Window::WindowOrientation windowOrientation;
+ switch( orientation )
+ {
+ case 0:
+ {
+ windowOrientation = Dali::Window::PORTRAIT;
+ break;
+ }
+ case 90:
+ {
+ windowOrientation = Dali::Window::LANDSCAPE;
+ break;
+ }
+ case 180:
+ {
+ windowOrientation = Dali::Window::PORTRAIT_INVERSE;
+ break;
+ }
+ case 270:
+ {
+ windowOrientation = Dali::Window::LANDSCAPE_INVERSE;
+ break;
+ }
+ default:
+ {
+ windowOrientation = Dali::Window::PORTRAIT;
+ break;
+ }
+ }
+
+ ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
+ wlSurface->RequestRotation( windowOrientation, positionSize.width, positionSize.height );
}
unsigned int Window::GetSupportedAuxiliaryHintCount()
*/
// CLASS HEADER
-#include "window-render-surface.h"
+#include <window-render-surface.h>
// EXTERNAL INCLUDES
#include <dali/integration-api/gl-abstraction.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/gl-defines.h>
// INTERNAL INCLUDES
#include <wl-types.h>
-#include <trigger-event.h>
#include <gl/egl-implementation.h>
#include <base/display-connection.h>
+#include <adaptors/common/adaptor-impl.h>
+#include <integration-api/trigger-event-factory-interface.h>
namespace Dali
{
bool isTransparent)
: EcoreWlRenderSurface( positionSize, surface, name, isTransparent ),
mWlWindow( NULL ),
- mEglWindow( NULL )
+ mEglWindow( NULL ),
+ mThreadSynchronization( NULL ),
+ mRotationTrigger( NULL ),
+ mRotationSupported( false ),
+ mRotated( false )
{
DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
Init( surface );
{
ecore_wl_window_free( mWlWindow );
}
+
+ if( mRotationTrigger )
+ {
+ delete mRotationTrigger;
+ }
}
Ecore_Wl_Window* WindowRenderSurface::GetDrawable()
return mWlWindow;
}
+void WindowRenderSurface::RequestRotation( Dali::Window::WindowOrientation orientation, int width, int height )
+{
+ if( !mRotationSupported )
+ {
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: Rotation is not supported!\n" );
+ return;
+ }
+
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: orientation = %d\n", orientation );
+
+ if( !mRotationTrigger )
+ {
+ TriggerEventFactoryInterface& triggerFactory = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetTriggerEventFactoryInterface();
+ mRotationTrigger = triggerFactory.CreateTriggerEvent( MakeCallback( this, &WindowRenderSurface::ProcessRotationRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER );
+ }
+
+ mPosition.width = width;
+ mPosition.height = height;
+
+ mRotated = true;
+
+ int angle;
+ wl_egl_window_rotation rotation;
+
+ switch( orientation )
+ {
+ case Dali::Window::PORTRAIT:
+ {
+ angle = 0;
+ rotation = ROTATION_0;
+ break;
+ }
+ case Dali::Window::LANDSCAPE:
+ {
+ angle = 90;
+ rotation = ROTATION_270;
+ break;
+ }
+ case Dali::Window::PORTRAIT_INVERSE:
+ {
+ angle = 180;
+ rotation = ROTATION_180;
+ break;
+ }
+ case Dali::Window::LANDSCAPE_INVERSE:
+ {
+ angle = 270;
+ rotation = ROTATION_90;
+ break;
+ }
+ default:
+ {
+ angle = 0;
+ rotation = ROTATION_0;
+ break;
+ }
+ }
+
+ ecore_wl_window_rotation_set( mWlWindow, angle );
+
+ wl_egl_window_set_rotation( mEglWindow, rotation );
+}
+
void WindowRenderSurface::InitializeEgl( EglInterface& eglIf )
{
DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
mEglWindow = wl_egl_window_create(ecore_wl_window_surface_get(mWlWindow), mPosition.width, mPosition.height);
EGLNativeWindowType windowType( mEglWindow );
eglImpl.CreateSurfaceWindow( windowType, mColorDepth );
+
+ // Check capability
+ wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) );
+ if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED )
+ {
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::CreateEglSurface: capability = %d\n", capability );
+ mRotationSupported = true;
+ }
}
void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf )
void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface )
{
+ if( mRotated )
+ {
+ // Check viewport size
+ Dali::Vector< GLint > viewportSize;
+ viewportSize.Resize( 4 );
+
+ glAbstraction.GetIntegerv( GL_VIEWPORT, &viewportSize[0] );
+
+ if( viewportSize[2] == mPosition.width && viewportSize[3] == mPosition.height )
+ {
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
+
+ mRotationTrigger->Trigger();
+
+ if( mThreadSynchronization )
+ {
+ // Wait until the event-thread complete the rotation event processing
+ mThreadSynchronization->PostRenderWaitForCompletion();
+ }
+ }
+ }
+
Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
eglImpl.SwapBuffers();
mWlWindow = AnyCast< Ecore_Wl_Window* >( surfaceId );
}
-void WindowRenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& /* threadSynchronization */ )
+void WindowRenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
{
- // Nothing to do.
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::SetThreadSynchronization: called\n" );
+
+ mThreadSynchronization = &threadSynchronization;
}
void WindowRenderSurface::ReleaseLock()
// Nothing to do.
}
+void WindowRenderSurface::ProcessRotationRequest()
+{
+ mRotated = false;
+
+ ecore_wl_window_rotation_change_done_send( mWlWindow );
+
+ DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::ProcessRotationRequest: Rotation Done\n" );
+
+ if( mThreadSynchronization )
+ {
+ mThreadSynchronization->PostRenderComplete();
+ }
+}
+
} // namespace ECore
} // namespace Dali
#define __DALI_INTERNAL_ECORE_WL_WINDOW_RENDER_SURFACE_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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 <wayland-egl.h>
+
// INTERNAL INCLUDES
#include <ecore-wl-render-surface.h>
-#include <wayland-egl.h>
+#include <window.h>
+#include <integration-api/thread-synchronization-interface.h>
namespace Dali
{
*/
virtual Ecore_Wl_Window* GetWlWindow();
+ /**
+ * Request surface rotation
+ * @param[in] orientation A new orientation of the surface
+ * @param[in] width A new width of the surface
+ * @param[in] height A new height of the surface
+ */
+ void RequestRotation( Dali::Window::WindowOrientation orientation, int width, int height );
+
public: // from Dali::RenderSurface
/**
*/
virtual void UseExistingRenderable( unsigned int surfaceId );
+private:
+
+ /**
+ * Used as the callback for the rotation-trigger.
+ */
+ void ProcessRotationRequest();
+
private: // Data
- Ecore_Wl_Window* mWlWindow; ///< Wayland-Window
- wl_egl_window* mEglWindow;
+ Ecore_Wl_Window* mWlWindow; ///< Wayland-Window
+ wl_egl_window* mEglWindow;
+ ThreadSynchronizationInterface* mThreadSynchronization;
+ TriggerEventInterface* mRotationTrigger;
+ bool mRotationSupported;
+ bool mRotated;
}; // class WindowRenderSurface
Application::AppSignalType& Application::ResizeSignal()
{
+ DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: ResizeSignal() is deprecated and will be removed from next release. Use Window::ResizedSignal() instead.\n" );
+
return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
}
AppSignalType& ResetSignal();
/**
+ * @DEPRECATED_1_1.43 Use Window::ResizedSignal() instead.
* @brief This signal is emitted when the window application rendering on is resized.
* @SINCE_1_0.0
* @return The signal to connect to
mType( Dali::DevelWindow::NORMAL ),
mPreferredOrientation( Dali::Window::PORTRAIT ),
mSupportedAuxiliaryHints(),
- mAuxiliaryHints()
+ mAuxiliaryHints(),
+ mIndicatorVisibilityChangedSignal(),
+ mFocusChangedSignal(),
+ mResizedSignal(),
+ mDeleteRequestSignal()
{
mEventHandler = NULL;
}
mEventHandler( NULL ),
mPreferredOrientation( Dali::Window::PORTRAIT ),
mSupportedAuxiliaryHints(),
- mAuxiliaryHints()
+ mAuxiliaryHints(),
+ mIndicatorVisibilityChangedSignal(),
+ mFocusChangedSignal(),
+ mResizedSignal(),
+ mDeleteRequestSignal()
{
// Detect if we're not running in a ecore main loop (e.g. libuv).