+void Window::SetType( Dali::DevelWindow::Type type )
+{
+ Ecore_Wl_Window_Type windowType;
+
+ if( type != mType )
+ {
+ switch( type )
+ {
+ case Dali::DevelWindow::NORMAL:
+ {
+ windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
+ break;
+ }
+ case Dali::DevelWindow::NOTIFICATION:
+ {
+ windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
+ break;
+ }
+ case Dali::DevelWindow::UTILITY:
+ {
+ windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
+ break;
+ }
+ case Dali::DevelWindow::DIALOG:
+ {
+ windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
+ break;
+ }
+ default:
+ {
+ windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
+ break;
+ }
+ }
+
+ ecore_wl_window_type_set( mEventHandler->mEcoreWindow, windowType );
+ }
+
+ mType = type;
+}
+
+Dali::DevelWindow::Type Window::GetType() const
+{
+ return mType;
+}
+
+bool Window::SetNotificationLevel( Dali::DevelWindow::NotificationLevel::Type level )
+{
+ if( mType != Dali::DevelWindow::NOTIFICATION )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
+ return false;
+ }
+
+ while( !mEventHandler->mTizenPolicy )
+ {
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ }
+
+ int notificationLevel;
+
+ switch( level )
+ {
+ case Dali::DevelWindow::NotificationLevel::NONE:
+ {
+ notificationLevel = TIZEN_POLICY_LEVEL_NONE;
+ break;
+ }
+ case Dali::DevelWindow::NotificationLevel::BASE:
+ {
+ notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
+ break;
+ }
+ case Dali::DevelWindow::NotificationLevel::MEDIUM:
+ {
+ notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
+ break;
+ }
+ case Dali::DevelWindow::NotificationLevel::HIGH:
+ {
+ notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
+ break;
+ }
+ case Dali::DevelWindow::NotificationLevel::TOP:
+ {
+ notificationLevel = TIZEN_POLICY_LEVEL_TOP;
+ break;
+ }
+ default:
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: invalid level [%d]\n", level );
+ notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
+ break;
+ }
+ }
+
+ mEventHandler->mNotificationLevelChangeDone = false;
+ mEventHandler->mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
+
+ tizen_policy_set_notification_level( mEventHandler->mTizenPolicy, ecore_wl_window_surface_get( mEventHandler->mEcoreWindow ), notificationLevel );
+
+ int count = 0;
+
+ while( !mEventHandler->mNotificationLevelChangeDone && count < 3 )
+ {
+ ecore_wl_flush();
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ count++;
+ }
+
+ if( !mEventHandler->mNotificationLevelChangeDone )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mEventHandler->mNotificationChangeState );
+ return false;
+ }
+ else if( mEventHandler->mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Permission denied! [%d]\n", level );
+ return false;
+ }
+
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Level is changed [%d]\n", mEventHandler->mNotificationLevel );
+
+ return true;
+}
+
+Dali::DevelWindow::NotificationLevel::Type Window::GetNotificationLevel()
+{
+ if( mType != Dali::DevelWindow::NOTIFICATION )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
+ return Dali::DevelWindow::NotificationLevel::NONE;
+ }
+
+ while( !mEventHandler->mTizenPolicy )
+ {
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ }
+
+ int count = 0;
+
+ while( !mEventHandler->mNotificationLevelChangeDone && count < 3 )
+ {
+ ecore_wl_flush();
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ count++;
+ }
+
+ if( !mEventHandler->mNotificationLevelChangeDone )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Error! [%d]\n", mEventHandler->mNotificationChangeState );
+ return Dali::DevelWindow::NotificationLevel::NONE;
+ }
+
+ Dali::DevelWindow::NotificationLevel::Type level;
+
+ switch( mEventHandler->mNotificationLevel )
+ {
+ case TIZEN_POLICY_LEVEL_NONE:
+ {
+ level = Dali::DevelWindow::NotificationLevel::NONE;
+ break;
+ }
+ case TIZEN_POLICY_LEVEL_DEFAULT:
+ {
+ level = Dali::DevelWindow::NotificationLevel::BASE;
+ break;
+ }
+ case TIZEN_POLICY_LEVEL_MEDIUM:
+ {
+ level = Dali::DevelWindow::NotificationLevel::MEDIUM;
+ break;
+ }
+ case TIZEN_POLICY_LEVEL_HIGH:
+ {
+ level = Dali::DevelWindow::NotificationLevel::HIGH;
+ break;
+ }
+ case TIZEN_POLICY_LEVEL_TOP:
+ {
+ level = Dali::DevelWindow::NotificationLevel::TOP;
+ break;
+ }
+ default:
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: invalid level [%d]\n", mEventHandler->mNotificationLevel );
+ level = Dali::DevelWindow::NotificationLevel::NONE;
+ break;
+ }
+ }
+
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: level [%d]\n", mEventHandler->mNotificationLevel );
+
+ return level;
+}
+
+void Window::SetOpaqueState( bool opaque )
+{
+ while( !mEventHandler->mTizenPolicy )
+ {
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ }
+
+ tizen_policy_set_opaque_state( mEventHandler->mTizenPolicy, ecore_wl_window_surface_get( mEventHandler->mEcoreWindow ), ( opaque ? 1 : 0 ) );
+
+ mOpaqueState = opaque;
+
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
+}
+
+bool Window::IsOpaqueState()
+{
+ return mOpaqueState;
+}
+
+bool Window::SetScreenMode( Dali::DevelWindow::ScreenMode::Type screenMode )
+{
+ while( !mEventHandler->mTizenPolicy )
+ {
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ }
+
+ mEventHandler->mScreenModeChangeDone = false;
+ mEventHandler->mScreenModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
+
+ unsigned int mode = 0;
+
+ switch( screenMode )
+ {
+ case Dali::DevelWindow::ScreenMode::DEFAULT:
+ {
+ mode = 0;
+ break;
+ }
+ case Dali::DevelWindow::ScreenMode::ALWAYS_ON:
+ {
+ mode = 1;
+ break;
+ }
+ }
+
+ tizen_policy_set_window_screen_mode( mEventHandler->mTizenPolicy, ecore_wl_window_surface_get( mEventHandler->mEcoreWindow ), mode );
+
+ int count = 0;
+
+ while( !mEventHandler->mScreenModeChangeDone && count < 3 )
+ {
+ ecore_wl_flush();
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ count++;
+ }
+
+ if( !mEventHandler->mScreenModeChangeDone )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenMode: Screen mode change is failed [%d, %d]\n", screenMode, mEventHandler->mScreenModeChangeState );
+ return false;
+ }
+ else if( mEventHandler->mScreenModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenMode: Permission denied! [%d]\n", screenMode );
+ return false;
+ }
+
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenMode: Screen mode is changed [%d]\n", mEventHandler->mScreenMode );
+
+ return true;
+}
+
+Dali::DevelWindow::ScreenMode::Type Window::GetScreenMode()
+{
+ while( !mEventHandler->mTizenPolicy )
+ {
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ }
+
+ int count = 0;
+
+ while( !mEventHandler->mScreenModeChangeDone && count < 3 )
+ {
+ ecore_wl_flush();
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ count++;
+ }
+
+ if( !mEventHandler->mScreenModeChangeDone )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetScreenMode: Error! [%d]\n", mEventHandler->mScreenModeChangeState );
+ return Dali::DevelWindow::ScreenMode::DEFAULT;
+ }
+
+ Dali::DevelWindow::ScreenMode::Type screenMode = Dali::DevelWindow::ScreenMode::DEFAULT;
+
+ switch( mEventHandler->mScreenMode )
+ {
+ case 0:
+ {
+ screenMode = Dali::DevelWindow::ScreenMode::DEFAULT;
+ break;
+ }
+ case 1:
+ {
+ screenMode = Dali::DevelWindow::ScreenMode::ALWAYS_ON;
+ break;
+ }
+ }
+
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetScreenMode: screen mode [%d]\n", mEventHandler->mScreenMode );
+
+ return screenMode;
+}
+
+bool Window::SetBrightness( int brightness )
+{
+ if( brightness < 0 || brightness > 100 )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
+ return false;
+ }
+
+ while( !mEventHandler->mTizenDisplayPolicy )
+ {
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ }
+
+ mEventHandler->mBrightnessChangeDone = false;
+ mEventHandler->mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
+
+ tizen_display_policy_set_window_brightness( mEventHandler->mTizenDisplayPolicy, ecore_wl_window_surface_get( mEventHandler->mEcoreWindow ), brightness );
+
+ int count = 0;
+
+ while( !mEventHandler->mBrightnessChangeDone && count < 3 )
+ {
+ ecore_wl_flush();
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ count++;
+ }
+
+ if( !mEventHandler->mBrightnessChangeDone )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mEventHandler->mBrightnessChangeState );
+ return false;
+ }
+ else if( mEventHandler->mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Permission denied! [%d]\n", brightness );
+ return false;
+ }
+
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Brightness is changed [%d]\n", mEventHandler->mBrightness );
+
+ return true;
+}
+
+int Window::GetBrightness()
+{
+ while( !mEventHandler->mTizenDisplayPolicy )
+ {
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ }
+
+ int count = 0;
+
+ while( !mEventHandler->mBrightnessChangeDone && count < 3 )
+ {
+ ecore_wl_flush();
+ wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
+ count++;
+ }
+
+ if( !mEventHandler->mBrightnessChangeDone )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetBrightness: Error! [%d]\n", mEventHandler->mBrightnessChangeState );
+ return 0;
+ }
+
+ DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetBrightness: Brightness [%d]\n", mEventHandler->mBrightness );
+
+ 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 ) );
+ if( wlSurface )
+ {
+ wlSurface->SetTransparency( transparent );
+ }
+}