/*
- * 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.
#include "window-impl.h"
// EXTERNAL HEADERS
-#include <Ecore.h>
-#include <Ecore_Wayland.h>
-
#include <dali/integration-api/core.h>
#include <dali/integration-api/system-overlay.h>
#include <dali/public-api/render-tasks/render-task.h>
#include <orientation.h>
// INTERNAL HEADERS
-#include <window-render-surface.h>
+#include "render-surface/render-surface-wl.h"
#include <drag-and-drop-detector-impl.h>
-#include <indicator-impl.h>
#include <window-visibility-observer.h>
#include <orientation-impl.h>
-namespace
-{
-const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
-const float INDICATOR_SHOW_Y_POSITION( 0.0f );
-const float INDICATOR_HIDE_Y_POSITION( -52.0f );
-}
+
namespace Dali
{
Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
#endif
-/**
- * TODO: Abstract Window class out and move this into a window implementation for Ecore
- */
struct Window::EventHandler
{
- /**
- * Constructor
- * @param[in] window A pointer to the window class.
- */
- EventHandler( Window* window )
- : mWindow( window ),
- mEcoreWindow( 0 )
- {
- }
-
- /**
- * Destructor
- */
- ~EventHandler()
- {
- if ( mWindowPropertyHandler )
- {
- ecore_event_handler_del( mWindowPropertyHandler );
- }
- if ( mClientMessagehandler )
- {
- ecore_event_handler_del( mClientMessagehandler );
- }
- }
-
- // Static methods
-
- /// Called when the window properties are changed.
- static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
- {
- return EINA_FALSE;
- }
-
- /// Called when the window properties are changed.
- static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
- {
- return EINA_FALSE;
- }
-
- // Data
- Window* mWindow;
- Ecore_Event_Handler* mWindowPropertyHandler;
- Ecore_Event_Handler* mClientMessagehandler;
- Ecore_Wl_Window* mEcoreWindow;
+ // place holder
};
-
-Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
+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);
+ window->Initialize(posSize, name, className);
return window;
}
mDragAndDropDetector = DragAndDropDetector::New();
mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
- if( mOrientation )
- {
- mOrientation->SetAdaptor(adaptor);
- }
- if( mIndicator != NULL )
- {
- mIndicator->SetAdaptor(mAdaptor);
- }
}
RenderSurface* Window::GetSurface()
void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
{
- DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
- DALI_ASSERT_DEBUG(mOverlay);
- DoShowIndicator( mIndicatorOrientation );
}
void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
{
- DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
-
- DoRotateIndicator( orientation );
}
void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
{
- mIndicatorOpacityMode = opacityMode;
-
- if( mIndicator != NULL )
- {
- mIndicator->SetOpacityMode( opacityMode );
- }
}
void Window::SetClass(std::string name, std::string klass)
mOverlay(NULL),
mAdaptor(NULL)
{
+ mEventHandler = NULL;
}
Window::~Window()
{
delete mEventHandler;
- if( mIndicator )
- {
- mIndicator->Close();
- delete mIndicator;
- }
-
if ( mAdaptor )
{
mAdaptor->RemoveObserver( *this );
delete mSurface;
}
-void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
+void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
{
// create an Wayland window by default
Any surface;
- ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( windowPosition, surface, name, mIsTransparent );
- windowSurface->Map();
+ Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
mSurface = windowSurface;
mOrientation = Orientation::New(this);
- // create event handler for Wayland window
- mEventHandler = new EventHandler( this );
}
void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
{
- if( mIndicator == NULL )
- {
- if( mIndicatorVisible != Dali::Window::INVISIBLE )
- {
- mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, this );
- mIndicator->SetOpacityMode( mIndicatorOpacityMode );
- Dali::Actor actor = mIndicator->GetActor();
- SetIndicatorActorRotation();
- mOverlay->Add(actor);
- }
- // else don't create a hidden indicator
- }
- else // Already have indicator
- {
- if( mIndicatorVisible == Dali::Window::VISIBLE )
- {
- // If we are resuming, and rotation has changed,
- if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
- {
- // then close current indicator and open new one
- mShowRotatedIndicatorOnClose = true;
- mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
- // Don't show actor - will contain indicator for old orientation.
- }
- }
- }
- // set indicator visible mode
- if( mIndicator != NULL )
- {
- mIndicator->SetVisible( mIndicatorVisible );
- }
-
- bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
- SetIndicatorProperties( show, lastOrientation );
- mIndicatorIsShown = show;
}
void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
{
- if( mIndicatorIsShown )
- {
- mShowRotatedIndicatorOnClose = true;
- mNextIndicatorOrientation = orientation;
- mIndicator->Close(); // May synchronously call IndicatorClosed() callback
- }
- else
- {
- // Save orientation for when the indicator is next shown
- mShowRotatedIndicatorOnClose = false;
- mNextIndicatorOrientation = orientation;
- }
+
}
void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
{
}
-void Window::IndicatorTypeChanged(Indicator::Type type)
+void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
{
}
-void Window::IndicatorClosed( Indicator* indicator )
+void Window::IndicatorClosed( IndicatorInterface* indicator )
{
- DALI_LOG_TRACE_METHOD( gWindowLogFilter );
- if( mShowRotatedIndicatorOnClose )
- {
- Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
- mIndicator->Open(mNextIndicatorOrientation);
- mIndicatorOrientation = mNextIndicatorOrientation;
- SetIndicatorActorRotation();
- DoShowIndicator(currentOrientation);
- }
}
void Window::IndicatorVisibilityChanged(bool isVisible)
{
- mIndicatorVisibilityChangedSignal.Emit(isVisible);
+
}
void Window::SetIndicatorActorRotation()
{
- DALI_LOG_TRACE_METHOD( gWindowLogFilter );
- DALI_ASSERT_DEBUG( mIndicator != NULL );
- Dali::Actor actor = mIndicator->GetActor();
- switch( mIndicatorOrientation )
- {
- case Dali::Window::PORTRAIT:
- actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
- actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- actor.SetOrientation( Degree(0), Vector3::ZAXIS );
- break;
- case Dali::Window::PORTRAIT_INVERSE:
- actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
- actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- actor.SetOrientation( Degree(180), Vector3::ZAXIS );
- break;
- case Dali::Window::LANDSCAPE:
- actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- actor.SetOrientation( Degree(270), Vector3::ZAXIS );
- break;
- case Dali::Window::LANDSCAPE_INVERSE:
- actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
- actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- actor.SetOrientation( Degree(90), Vector3::ZAXIS );
- break;
- }
}
void Window::Raise()
Dali::Any Window::GetNativeHandle() const
{
- if(mEventHandler)
- {
- return mEventHandler->mEcoreWindow;
- }
- else
- {
- return Dali::Any();
- }
+ Wayland::RenderSurface* surface = static_cast< Wayland::RenderSurface* >( mSurface );
+
+ return surface->GetWindow();
}
void Window::OnStart()
{
- DoShowIndicator( mIndicatorOrientation );
}
void Window::OnPause()
void Window::OnResume()
{
- // resume indicator status
- if( mIndicator != NULL )
- {
- // Restore own indicator opacity
- // Send opacity mode to indicator service when app resumed
- mIndicator->SetOpacityMode( mIndicatorOpacityMode );
- }
}
void Window::OnStop()
{
- if( mIndicator )
- {
- mIndicator->Close();
- }
-
- delete mIndicator;
- mIndicator = NULL;
}
void Window::OnDestroy()