#include <window-impl.h>
// EXTERNAL HEADERS
+// Ecore is littered with C style cast
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <Ecore.h>
#include <Ecore_Wayland.h>
#include <tizen-extension-client-protocol.h>
*/
EventHandler( Window* window )
: mWindow( window ),
- mWindowPropertyHandler( NULL ),
- mWindowIconifyStateHandler( NULL ),
- mWindowFocusInHandler( NULL ),
- mWindowFocusOutHandler( NULL ),
+ mEcoreEventHandler(),
mEcoreWindow( 0 ),
mDisplay( NULL ),
mEventQueue( NULL ),
mNotificationLevelChangeDone( true ),
mScreenMode( 0 ),
mScreenModeChangeState( 0 ),
- mScreenModeChangeDone( true )
+ mScreenModeChangeDone( true ),
+ mBrightness( 0 ),
+ mBrightnessChangeState( 0 ),
+ mBrightnessChangeDone( true )
{
// store ecore window handle
ECore::WindowRenderSurface* wlWindow( dynamic_cast< ECore::WindowRenderSurface * >( mWindow->mSurface ) );
if( mWindow->mEcoreEventHander )
{
- mWindowIconifyStateHandler = ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this );
- mWindowFocusInHandler = ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this );
- mWindowFocusOutHandler = ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this) );
+ mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this) );
}
mDisplay = ecore_wl_display_get();
*/
~EventHandler()
{
- if ( mWindowPropertyHandler )
+ for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
{
- ecore_event_handler_del( mWindowPropertyHandler );
- }
- if ( mWindowIconifyStateHandler )
- {
- ecore_event_handler_del( mWindowIconifyStateHandler );
- }
- if( mWindowFocusInHandler )
- {
- ecore_event_handler_del( mWindowFocusInHandler );
- }
- if( mWindowFocusOutHandler )
- {
- ecore_event_handler_del( mWindowFocusOutHandler );
+ ecore_event_handler_del( *iter );
}
+ mEcoreEventHandler.Clear();
+
if( mEventQueue )
{
wl_event_queue_destroy( mEventQueue );
// 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 iconify state is changed.
static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
{
return ECORE_CALLBACK_PASS_ON;
}
+ /// Called when the output is transformed
+ static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
+ {
+ Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) );
+ EventHandler* handler( static_cast< EventHandler* >( data ) );
+
+ if ( handler && handler->mWindow && transformEvent->output == ecore_wl_window_output_find( handler->mEcoreWindow ) )
+ {
+ ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( handler->mWindow->mSurface ) );
+ wlSurface->OutputTransformed();
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /// Called when the output transform should be ignored
+ static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
+ {
+ Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) );
+ EventHandler* handler( static_cast< EventHandler* >( data ) );
+
+ if ( handler && handler->mWindow && ignoreTransformEvent->win == handler->mEcoreWindow )
+ {
+ ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( handler->mWindow->mSurface ) );
+ wlSurface->OutputTransformed();
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
{
Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
// Data
Window* mWindow;
- Ecore_Event_Handler* mWindowPropertyHandler;
- Ecore_Event_Handler* mWindowIconifyStateHandler;
- Ecore_Event_Handler* mWindowFocusInHandler;
- Ecore_Event_Handler* mWindowFocusOutHandler;
+ Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
Ecore_Wl_Window* mEcoreWindow;
wl_display* mDisplay;
bool mBrightnessChangeDone;
};
-Window* Window::New(const PositionSize& posSize, 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 )
{
Window* window = new Window();
window->mIsTransparent = isTransparent;
- window->Initialize(posSize, name, className);
+ window->Initialize( positionSize, name, className );
return window;
}
mIsFocusAcceptable( true ),
mVisible( true ),
mOpaqueState( false ),
+ mResizeEnabled( false ),
mIndicator( NULL ),
mIndicatorOrientation( Dali::Window::PORTRAIT ),
mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
mEventHandler( NULL ),
mPreferredOrientation( Dali::Window::PORTRAIT ),
mSupportedAuxiliaryHints(),
- mAuxiliaryHints()
+ mAuxiliaryHints(),
+ mIndicatorVisibilityChangedSignal(),
+ mFocusChangedSignal(),
+ mResizedSignal(),
+ mDeleteRequestSignal()
{
}
mAuxiliaryHints.clear();
}
-void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
+void Window::Initialize(const PositionSize& positionSize, 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 );
+ ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( positionSize, surface, name, mIsTransparent );
mSurface = windowSurface;
- SetClass( name, className );
- windowSurface->Map();
-
- mOrientation = Orientation::New(this);
// create event handler for Wayland window
mEventHandler = new EventHandler( this );
DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::Initialize: %s\n", hint );
}
}
+
+ if( !positionSize.IsEmpty() )
+ {
+ AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ mResizeEnabled = true;
+ }
+
+ SetClass( name, className );
+ windowSurface->Map();
+
+ mOrientation = Orientation::New(this);
}
void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
void Window::RotationDone( int orientation, int width, int height )
{
- ecore_wl_window_rotation_change_done_send( mEventHandler->mEcoreWindow );
+ ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
+ wlSurface->RequestRotation( orientation, width, height );
+
+ mAdaptor->SurfaceResizePrepare( Dali::Adaptor::SurfaceSize( width, height ) );
+
+ // Emit signal
+ mResizedSignal.Emit( Dali::DevelWindow::WindowSize( width, height ) );
+
+ mAdaptor->SurfaceResizeComplete( Dali::Adaptor::SurfaceSize( width, height ) );
}
unsigned int Window::GetSupportedAuxiliaryHintCount()
return mEventHandler->mBrightness;
}
+void Window::SetSize( Dali::DevelWindow::WindowSize size )
+{
+ if( !mResizeEnabled )
+ {
+ AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ mResizeEnabled = true;
+ }
+
+ PositionSize positionSize = mSurface->GetPositionSize();
+
+ if( positionSize.width != size.GetWidth() || positionSize.height != size.GetHeight() )
+ {
+ positionSize.width = size.GetWidth();
+ positionSize.height = size.GetHeight();
+
+ mSurface->MoveResize( positionSize );
+
+ mAdaptor->SurfaceResizePrepare( Dali::Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
+
+ // Emit signal
+ mResizedSignal.Emit( Dali::DevelWindow::WindowSize( positionSize.width, positionSize.height ) );
+
+ mAdaptor->SurfaceResizeComplete( Dali::Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
+ }
+}
+
+Dali::DevelWindow::WindowSize Window::GetSize()
+{
+ PositionSize positionSize = mSurface->GetPositionSize();
+
+ return Dali::DevelWindow::WindowSize( positionSize.width, positionSize.height );
+}
+
+void Window::SetPosition( Dali::DevelWindow::WindowPosition position )
+{
+ if( !mResizeEnabled )
+ {
+ AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ mResizeEnabled = true;
+ }
+
+ PositionSize positionSize = mSurface->GetPositionSize();
+
+ if( positionSize.x != position.GetX() || positionSize.y != position.GetY() )
+ {
+ positionSize.x = position.GetX();
+ positionSize.y = position.GetY();
+
+ mSurface->MoveResize( positionSize );
+ }
+}
+
+Dali::DevelWindow::WindowPosition Window::GetPosition()
+{
+ PositionSize positionSize = mSurface->GetPositionSize();
+
+ return Dali::DevelWindow::WindowPosition( positionSize.x, positionSize.y );
+}
+
+void Window::SetTransparency( bool transparent )
+{
+ ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
+ wlSurface->SetTransparency( transparent );
+}
+
} // Adaptor
+
} // Internal
+
} // Dali
+
+#pragma GCC diagnostic pop