/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
#include <dali/internal/window-system/common/window-impl.h>
// EXTERNAL HEADERS
+#include <thread>
#include <dali/integration-api/core.h>
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/actors/layer.h>
#include <dali/public-api/render-tasks/render-task.h>
#include <dali/public-api/render-tasks/render-task-list.h>
#include <dali/public-api/rendering/frame-buffer.h>
+#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <dali/devel-api/adaptor-framework/orientation.h>
#include <dali/integration-api/events/touch-event-integ.h>
// INTERNAL HEADERS
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
#include <dali/internal/window-system/common/event-handler.h>
#include <dali/internal/window-system/common/orientation-impl.h>
#include <dali/internal/window-system/common/render-surface-factory.h>
#include <dali/internal/window-system/common/window-system.h>
#include <dali/internal/window-system/common/window-render-surface.h>
#include <dali/internal/window-system/common/window-visibility-observer.h>
+#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
namespace Dali
{
} // unnamed namespace
-Window* Window::New( const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent )
+Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
+{
+ Any surface;
+ return Window::New(surface, positionSize, name, className, isTransparent);
+}
+
+Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
{
Window* window = new Window();
window->mIsTransparent = isTransparent;
- window->Initialize( positionSize, name, className );
+ window->Initialize(surface, positionSize, name, className);
return window;
}
mIconified( false ),
mOpaqueState( false ),
mResizeEnabled( false ),
- mType( Dali::Window::NORMAL ),
+ mType( WindowType::NORMAL ),
mParentWindow( NULL ),
- mPreferredAngle( Dali::Window::NO_ORIENTATION_PREFERENCE ),
+ mPreferredAngle( static_cast< int >( WindowOrientation::NO_ORIENTATION_PREFERENCE ) ),
mRotationAngle( -1 ),
mWindowWidth( 0 ),
mWindowHeight( 0 ),
mOrientationMode( Internal::Adaptor::Window::OrientationMode::PORTRAIT ),
mNativeWindowId( -1 ),
- mFocusChangedSignal(),
- mResizedSignal(),
mDeleteRequestSignal(),
mFocusChangeSignal(),
mResizeSignal(),
mVisibilityChangedSignal(),
- mTransitionEffectEventSignal()
+ mTransitionEffectEventSignal(),
+ mKeyboardRepeatSettingsChangedSignal()
{
}
Window::~Window()
{
+ if ( mAdaptor )
+ {
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto accessible2 = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get( accessible2 );
+ bridge->RemoveTopLevelWindow( accessible );
+
+ mAdaptor->RemoveWindow( this );
+ }
+
if ( mEventHandler )
{
mEventHandler->RemoveObserver( *this );
}
}
-void Window::Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className)
+void Window::Initialize(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className)
{
// Create a window render surface
- Any surface;
auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
mWindowSurface = static_cast<WindowRenderSurface*>( mSurface.get() );
mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
+ mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect( this, &Window::OnKeyboardRepeatSettingsChanged );
+ mWindowBase->WindowRedrawRequestSignal().Connect( this, &Window::OnWindowRedrawRequest );
mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
{
- mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface, *mAdaptor ) );
+ mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface->GetWindowBase(), *mAdaptor ) );
mEventHandler->AddObserver( *this );
-}
-void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
-{
- mWindowSurface = static_cast<WindowRenderSurface*>( surface );
-}
-
-void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
-{
-}
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto v = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get( v, true );
+ bridge->AddTopLevelWindow( accessible );
-void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
-{
+ //FIXME: line below is temporary solution for missing "activate" signal and should be removed
+ Show();
}
-void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
+void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
{
+ mWindowSurface = static_cast<WindowRenderSurface*>( surface );
}
void Window::SetClass( std::string name, std::string className )
void Window::Raise()
{
mWindowBase->Raise();
+
+ mSurface->SetFullSwapNextFrame();
+
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
}
void Window::Lower()
{
mWindowBase->Lower();
+
+ mSurface->SetFullSwapNextFrame();
+
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
}
void Window::Activate()
{
mWindowBase->Activate();
+
+ mSurface->SetFullSwapNextFrame();
+
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
}
return mScene.GetRenderTaskList();
}
-void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
+void Window::AddAvailableOrientation( WindowOrientation orientation )
{
if( IsOrientationAvailable( orientation ) == false )
{
}
}
-void Window::RemoveAvailableOrientation( Dali::Window::WindowOrientation orientation )
+void Window::RemoveAvailableOrientation( WindowOrientation orientation )
{
if( IsOrientationAvailable( orientation ) == false )
{
SetAvailableAnlges( mAvailableAngles );
}
-void Window::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
+void Window::SetPreferredOrientation( WindowOrientation orientation )
{
- if( orientation < Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
+ if( orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE )
{
DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
return;
mWindowBase->SetPreferredAngle( mPreferredAngle );
}
-Dali::Window::WindowOrientation Window::GetPreferredOrientation()
+WindowOrientation Window::GetPreferredOrientation()
{
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
- Dali::Window::WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
+ WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
return preferredOrientation;
}
mWindowBase->SetAvailableAnlges( angles );
}
-int Window::ConvertToAngle( Dali::Window::WindowOrientation orientation )
+int Window::ConvertToAngle( WindowOrientation orientation )
{
int convertAngle = static_cast< int >( orientation );
if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
{
switch( orientation )
{
- case Dali::Window::LANDSCAPE:
+ case WindowOrientation::LANDSCAPE:
{
convertAngle = 0;
break;
}
- case Dali::Window::PORTRAIT:
+ case WindowOrientation::PORTRAIT:
{
convertAngle = 90;
break;
}
- case Dali::Window::LANDSCAPE_INVERSE:
+ case WindowOrientation::LANDSCAPE_INVERSE:
{
convertAngle = 180;
break;
}
- case Dali::Window::PORTRAIT_INVERSE:
+ case WindowOrientation::PORTRAIT_INVERSE:
{
convertAngle = 270;
break;
}
- case Dali::Window::NO_ORIENTATION_PREFERENCE:
+ case WindowOrientation::NO_ORIENTATION_PREFERENCE:
{
convertAngle = -1;
break;
return convertAngle;
}
-Dali::Window::WindowOrientation Window::ConvertToOrientation( int angle ) const
+WindowOrientation Window::ConvertToOrientation( int angle ) const
{
- Dali::Window::WindowOrientation orientation = static_cast< Dali::Window::WindowOrientation >( angle );
+ WindowOrientation orientation = static_cast< WindowOrientation >( angle );
if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
{
switch( angle )
{
case 0:
{
- orientation = Dali::Window::LANDSCAPE;
+ orientation = WindowOrientation::LANDSCAPE;
break;
}
case 90:
{
- orientation = Dali::Window::PORTRAIT;
+ orientation = WindowOrientation::PORTRAIT;
break;
}
case 180:
{
- orientation = Dali::Window::LANDSCAPE_INVERSE;
+ orientation = WindowOrientation::LANDSCAPE_INVERSE;
break;
}
case 270:
{
- orientation = Dali::Window::PORTRAIT_INVERSE;
+ orientation = WindowOrientation::PORTRAIT_INVERSE;
break;
}
case -1:
{
- orientation = Dali::Window::NO_ORIENTATION_PREFERENCE;
+ orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
break;
}
}
return orientation;
}
-bool Window::IsOrientationAvailable( Dali::Window::WindowOrientation orientation ) const
+bool Window::IsOrientationAvailable( WindowOrientation orientation ) const
{
- if( orientation <= Dali::Window::NO_ORIENTATION_PREFERENCE || orientation > Dali::Window::LANDSCAPE_INVERSE )
+ if( orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE )
{
DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
return false;
mVisibilityChangedSignal.Emit( handle, true );
}
+ mSurface->SetFullSwapNextFrame();
+
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
}
DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
}
-void Window::SetType( Dali::Window::Type type )
+void Window::SetType( WindowType type )
{
if( type != mType )
{
}
}
-Dali::Window::Type Window::GetType() const
+WindowType Window::GetType() const
{
return mType;
}
-bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
+bool Window::SetNotificationLevel( WindowNotificationLevel level )
{
- if( mType != Dali::Window::NOTIFICATION )
+ if( mType != WindowType::NOTIFICATION )
{
DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
return false;
return mWindowBase->SetNotificationLevel( level );
}
-Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
+WindowNotificationLevel Window::GetNotificationLevel() const
{
- if( mType != Dali::Window::NOTIFICATION )
+ if( mType != WindowType::NOTIFICATION )
{
DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
- return Dali::Window::NotificationLevel::NONE;
+ return WindowNotificationLevel::NONE;
}
return mWindowBase->GetNotificationLevel();
return mOpaqueState;
}
-bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
+bool Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
{
return mWindowBase->SetScreenOffMode( screenOffMode );
}
-Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
+WindowScreenOffMode Window::GetScreenOffMode() const
{
return mWindowBase->GetScreenOffMode();
}
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
Dali::Window handle( this );
- mResizedSignal.Emit( newSize );
mResizeSignal.Emit( handle, newSize );
mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
}
+
+ mSurface->SetFullSwapNextFrame();
}
Dali::Window::WindowSize Window::GetSize() const
PositionSize oldRect = mSurface->GetPositionSize();
mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
+
+ mSurface->SetFullSwapNextFrame();
}
Dali::Window::WindowPosition Window::GetPosition() const
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
Dali::Window handle( this );
- mResizedSignal.Emit( newSize );
mResizeSignal.Emit( handle, newSize );
mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
}
+
+ mSurface->SetFullSwapNextFrame();
}
Dali::Layer Window::GetRootLayer() const
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
}
+
+ mSurface->SetFullSwapNextFrame();
}
void Window::OnFocusChanged( bool focusIn )
{
Dali::Window handle( this );
- mFocusChangedSignal.Emit( focusIn );
mFocusChangeSignal.Emit( handle, focusIn );
+
+ mSurface->SetFullSwapNextFrame();
+
+ if (auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
+ {
+ if (focusIn)
+ {
+ b->ApplicationShown();
+ }
+ else
+ {
+ b->ApplicationHidden();
+ }
+ }
}
void Window::OnOutputTransformed()
mDeleteRequestSignal.Emit();
}
-void Window::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
+void Window::OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type )
{
Dali::Window handle( this );
mTransitionEffectEventSignal.Emit( handle, state, type );
}
+void Window::OnKeyboardRepeatSettingsChanged()
+{
+ Dali::Window handle( this );
+ mKeyboardRepeatSettingsChangedSignal.Emit();
+}
+
+void Window::OnWindowRedrawRequest()
+{
+ mAdaptor->RenderOnce();
+}
+
void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
{
FeedTouchPoint( point, timeStamp );
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
// Emit signal
Dali::Window handle( this );
- mResizedSignal.Emit( Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
mResizeSignal.Emit( handle, Dali::Window::WindowSize( mWindowWidth, mWindowHeight ) );
mAdaptor->SurfaceResizeComplete( mSurface.get(), Adaptor::SurfaceSize( mWindowWidth, mWindowHeight ) );
{
mEventHandler->Resume();
}
+
+ mSurface->SetFullSwapNextFrame();
}
void Window::RecalculateTouchPosition( Integration::Point& point )
return mParentWindow;
}
-Dali::Window::WindowOrientation Window::GetCurrentOrientation() const
+WindowOrientation Window::GetCurrentOrientation() const
{
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
return ConvertToOrientation( mRotationAngle );
}
-void Window::SetAvailableOrientations( const Dali::Vector<Dali::Window::WindowOrientation>& orientations )
+void Window::SetAvailableOrientations( const Dali::Vector<WindowOrientation>& orientations )
{
Dali::Vector<float>::SizeType count = orientations.Count();
for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
SetAvailableAnlges( mAvailableAngles );
}
+int32_t Window::GetNativeId() const
+{
+ return mWindowBase->GetNativeWindowId();
+}
+
} // Adaptor
} // Internal