2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/window-system/common/window-impl.h>
22 // Ecore is littered with C style cast
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wold-style-cast"
26 #include <Ecore_Wl2.h>
27 #include <tizen-extension-client-protocol.h>
29 #include <dali/integration-api/core.h>
30 #include <dali/integration-api/system-overlay.h>
31 #include <dali/public-api/render-tasks/render-task.h>
32 #include <dali/public-api/render-tasks/render-task-list.h>
33 #include <dali/devel-api/adaptor-framework/orientation.h>
36 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-render-surface-ecore-wl2.h>
37 #include <dali/internal/input/common/drag-and-drop-detector-impl.h>
38 #include <dali/internal/window-system/common/ecore-indicator-impl.h>
39 #include <dali/internal/window-system/common/window-visibility-observer.h>
40 #include <dali/internal/window-system/common/orientation-impl.h>
45 const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
46 const float INDICATOR_SHOW_Y_POSITION( 0.0f );
47 const float INDICATOR_HIDE_Y_POSITION( -52.0f );
49 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
60 #if defined(DEBUG_ENABLED)
61 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
65 * TODO: Abstract Window class out and move this into a window implementation for Ecore
67 struct Window::EventHandler
71 * @param[in] window A pointer to the window class.
73 EventHandler( Window* window )
80 mTizenDisplayPolicy( NULL ),
81 mNotificationLevel( -1 ),
82 mNotificationChangeState( 0 ),
83 mNotificationLevelChangeDone( true ),
85 mScreenOffModeChangeState( 0 ),
86 mScreenOffModeChangeDone( true ),
88 mBrightnessChangeState( 0 ),
89 mBrightnessChangeDone( true )
91 // store ecore window handle
92 ECore::WindowRenderSurface* wlWindow( dynamic_cast< ECore::WindowRenderSurface * >( mWindow->mSurface ) );
95 mEcoreWindow = wlWindow->GetWlWindow();
97 DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore Wl window");
99 if( mWindow->mEcoreEventHander )
101 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
102 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
103 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
104 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this) );
105 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this) );
108 Ecore_Wl2_Display *ecore_wl2_display = ecore_wl2_connected_display_get(NULL);
109 mDisplay = ecore_wl2_display_get(ecore_wl2_display);
113 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
116 mEventQueue = wl_display_create_queue( mDisplay );
119 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
121 wl_registry* registry = wl_display_get_registry( displayWrapper );
122 wl_registry_add_listener( registry, &mRegistryListener, this );
125 wl_proxy_wrapper_destroy( displayWrapper );
135 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
137 ecore_event_handler_del( *iter );
139 mEcoreEventHandler.Clear();
143 wl_event_queue_destroy( mEventQueue );
149 /// Called when the window iconify state is changed.
150 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
152 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
153 EventHandler* handler( static_cast< EventHandler* >( data ) );
154 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
156 if ( handler && handler->mWindow )
158 WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
159 if ( observer && ( iconifyChangedEvent->win == static_cast< unsigned int> ( ecore_wl2_window_id_get( handler->mEcoreWindow ) ) ) )
161 if( iconifyChangedEvent->iconified == EINA_TRUE )
163 handler->mWindow->mIconified = true;
164 if( handler->mWindow->mVisible )
166 observer->OnWindowHidden();
168 DALI_LOG_RELEASE_INFO( "Window (%p) Iconified\n", handler->mEcoreWindow);
172 handler->mWindow->mIconified = false;
173 if( handler->mWindow->mVisible )
175 observer->OnWindowShown();
177 DALI_LOG_RELEASE_INFO( "Window (%p) Deiconified\n", handler->mEcoreWindow );
179 handled = ECORE_CALLBACK_DONE;
186 /// Called when the window gains focus
187 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
189 Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
190 EventHandler* handler( static_cast< EventHandler* >( data ) );
192 if ( handler && handler->mWindow && focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( handler->mEcoreWindow ) ) )
194 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
196 handler->mWindow->mFocusChangedSignal.Emit( true );
199 return ECORE_CALLBACK_PASS_ON;
202 /// Called when the window loses focus
203 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
205 Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
206 EventHandler* handler( static_cast< EventHandler* >( data ) );
208 if ( handler && handler->mWindow && focusOutEvent->window == static_cast< unsigned int >(ecore_wl2_window_id_get( handler->mEcoreWindow ) ) )
210 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
212 handler->mWindow->mFocusChangedSignal.Emit( false );
215 return ECORE_CALLBACK_PASS_ON;
218 /// Called when the output is transformed
219 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
221 Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
222 EventHandler* handler( static_cast< EventHandler* >( data ) );
224 if ( handler && handler->mWindow && transformEvent->output == ecore_wl2_window_output_find( handler->mEcoreWindow ) )
226 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", handler->mEcoreWindow );
228 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( handler->mWindow->mSurface ) );
231 wlSurface->OutputTransformed();
233 PositionSize positionSize = wlSurface->GetPositionSize();
234 handler->mWindow->mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
235 handler->mWindow->mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
239 return ECORE_CALLBACK_PASS_ON;
242 /// Called when the output transform should be ignored
243 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
245 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
246 EventHandler* handler( static_cast< EventHandler* >( data ) );
248 if ( handler && handler->mWindow && ignoreTransformEvent->win == handler->mEcoreWindow )
250 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", handler->mEcoreWindow );
252 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( handler->mWindow->mSurface ) );
255 wlSurface->OutputTransformed();
257 PositionSize positionSize = wlSurface->GetPositionSize();
258 handler->mWindow->mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
259 handler->mWindow->mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
263 return ECORE_CALLBACK_PASS_ON;
266 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
268 Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
270 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
272 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
274 eventHandler->mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
275 if( !eventHandler->mTizenPolicy )
277 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
281 tizen_policy_add_listener( eventHandler->mTizenPolicy, &eventHandler->mTizenPolicyListener, data );
283 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
285 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
287 eventHandler->mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
288 if( !eventHandler->mTizenDisplayPolicy )
290 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
294 tizen_display_policy_add_listener( eventHandler->mTizenDisplayPolicy, &eventHandler->mTizenDisplayPolicyListener, data );
296 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
300 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
302 Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
303 eventHandler->mTizenPolicy = NULL;
304 eventHandler->mTizenDisplayPolicy = NULL;
307 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
311 static void TizenPolicyConformantArea( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h )
315 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
317 Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
319 eventHandler->mNotificationLevel = level;
320 eventHandler->mNotificationChangeState = state;
321 eventHandler->mNotificationLevelChangeDone = true;
323 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
326 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
330 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
332 Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
334 eventHandler->mScreenOffMode = mode;
335 eventHandler->mScreenOffModeChangeState = state;
336 eventHandler->mScreenOffModeChangeDone = true;
338 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
341 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
345 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
349 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
353 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
357 static void TizenPolicyConformantRegion( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial )
361 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
363 Window::EventHandler* eventHandler = static_cast< Window::EventHandler* >( data );
365 eventHandler->mBrightness = brightness;
366 eventHandler->mBrightnessChangeState = state;
367 eventHandler->mBrightnessChangeDone = true;
369 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window::EventHandler::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
372 const struct wl_registry_listener mRegistryListener =
374 RegistryGlobalCallback,
375 RegistryGlobalCallbackRemove
378 const struct tizen_policy_listener mTizenPolicyListener =
380 TizenPolicyConformant,
381 TizenPolicyConformantArea,
382 TizenPolicyNotificationChangeDone,
383 TizenPolicyTransientForDone,
384 TizenPolicyScreenModeChangeDone,
385 TizenPolicyIconifyStateChanged,
386 TizenPolicySupportedAuxiliaryHints,
387 TizenPolicyAllowedAuxiliaryHint,
388 TizenPolicyAuxiliaryMessage,
389 TizenPolicyConformantRegion
392 const struct tizen_display_policy_listener mTizenDisplayPolicyListener =
394 DisplayPolicyBrightnessChangeDone
399 Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
400 Ecore_Wl2_Window* mEcoreWindow;
402 wl_display* mDisplay;
403 wl_event_queue* mEventQueue;
404 tizen_policy* mTizenPolicy;
405 tizen_display_policy* mTizenDisplayPolicy;
407 int mNotificationLevel;
408 uint32_t mNotificationChangeState;
409 bool mNotificationLevelChangeDone;
412 uint32_t mScreenOffModeChangeState;
413 bool mScreenOffModeChangeDone;
416 uint32_t mBrightnessChangeState;
417 bool mBrightnessChangeDone;
420 Window* Window::New( const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent )
422 Window* window = new Window();
423 window->mIsTransparent = isTransparent;
424 window->Initialize( positionSize, name, className );
428 void Window::SetAdaptor(Dali::Adaptor& adaptor)
430 DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
433 // Only create one overlay per window
434 Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
435 Integration::Core& core = adaptorImpl.GetCore();
436 mOverlay = &core.GetSystemOverlay();
438 Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
439 taskList.CreateTask();
441 mAdaptor = &adaptorImpl;
442 mAdaptor->AddObserver( *this );
444 // Can only create the detector when we know the Core has been instantiated.
445 mDragAndDropDetector = DragAndDropDetector::New();
446 mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
450 mOrientation->SetAdaptor(adaptor);
453 if( mIndicator != NULL )
455 mIndicator->SetAdaptor(mAdaptor);
459 RenderSurface* Window::GetSurface()
464 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
466 DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
467 DALI_ASSERT_DEBUG(mOverlay);
469 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
470 DALI_ASSERT_DEBUG(wlSurface);
474 Ecore_Wl2_Window* wlWindow = wlSurface->GetWlWindow();
476 mIndicatorVisible = visibleMode;
478 //temp code TODO : need to re-imple dali indicator for EFL 1.20
479 mIndicatorVisible = Dali::Window::INVISIBLE;
481 if ( mIndicatorVisible == Dali::Window::VISIBLE )
483 // when the indicator is visible, set proper mode for indicator server according to bg mode
484 if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
486 ecore_wl2_window_indicator_opacity_set(wlWindow, ECORE_WL2_INDICATOR_OPAQUE);
488 else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
490 ecore_wl2_window_indicator_opacity_set(wlWindow, ECORE_WL2_INDICATOR_TRANSLUCENT);
492 else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
494 ecore_wl2_window_indicator_opacity_set(wlWindow, ECORE_WL2_INDICATOR_OPAQUE);
499 // when the indicator is not visible, set TRANSPARENT mode for indicator server
500 ecore_wl2_window_indicator_opacity_set(wlWindow, ECORE_WL2_INDICATOR_TRANSPARENT); // it means hidden indicator
504 DoShowIndicator( mIndicatorOrientation );
507 void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
509 DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
511 DoRotateIndicator( orientation );
514 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
516 mIndicatorOpacityMode = opacityMode;
518 if( mIndicator != NULL )
520 mIndicator->SetOpacityMode( opacityMode );
524 void Window::SetClass(std::string name, std::string klass)
526 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
530 Ecore_Wl2_Window* wlWindow = wlSurface->GetWlWindow();
531 ecore_wl2_window_title_set( wlWindow, name.c_str() );
532 ecore_wl2_window_class_set( wlWindow, klass.c_str() );
536 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window has no surface\n" );
542 //temp code TODO : need to re-imple dali indicator for EFL 1.20
543 mIndicatorVisible( Dali::Window::INVISIBLE ),
544 mIndicatorIsShown( false ),
545 mShowRotatedIndicatorOnClose( false ),
547 mIsTransparent( false ),
548 mWMRotationAppSet( false ),
549 mEcoreEventHander( true ),
550 mIsFocusAcceptable( true ),
553 mOpaqueState( false ),
554 mResizeEnabled( false ),
556 mIndicatorOrientation( Dali::Window::PORTRAIT ),
557 mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
558 mIndicatorOpacityMode( Dali::Window::OPAQUE ),
561 mType( Dali::Window::NORMAL ),
562 mEventHandler( NULL ),
563 mPreferredOrientation( Dali::Window::PORTRAIT ),
564 mSupportedAuxiliaryHints(),
566 mIndicatorVisibilityChangedSignal(),
567 mFocusChangedSignal(),
569 mDeleteRequestSignal()
575 delete mEventHandler;
585 mAdaptor->RemoveObserver( *this );
586 mAdaptor->SetDragAndDropDetector( NULL );
592 mSupportedAuxiliaryHints.clear();
593 mAuxiliaryHints.clear();
596 void Window::Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className)
598 // create an Wayland window by default
600 ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( positionSize, surface, name, mIsTransparent );
602 mSurface = windowSurface;
604 // create event handler for Wayland window
605 mEventHandler = new EventHandler( this );
607 // get auxiliary hint
608 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEventHandler->mEcoreWindow );
614 for( l = hints, ( hint = static_cast< char* >( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( hint = static_cast< char* >( eina_list_data_get(l) ) ) )
616 mSupportedAuxiliaryHints.push_back( hint );
618 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::Initialize: %s\n", hint );
622 if( !positionSize.IsEmpty() )
624 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
625 mResizeEnabled = true;
628 SetClass( name, className );
629 windowSurface->Map();
631 mOrientation = Orientation::New(this);
634 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
636 // temp code TODO : to implementation for EFL 1.20
637 if ( mIndicatorVisible == Dali::Window::INVISIBLE )
640 if( mIndicator == NULL )
642 if( mIndicatorVisible != Dali::Window::INVISIBLE )
644 mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, this );
645 mIndicator->SetOpacityMode( mIndicatorOpacityMode );
646 Dali::Actor actor = mIndicator->GetActor();
647 SetIndicatorActorRotation();
648 mOverlay->Add(actor);
650 // else don't create a hidden indicator
652 else // Already have indicator
654 if( mIndicatorVisible == Dali::Window::VISIBLE )
656 // If we are resuming, and rotation has changed,
657 if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
659 // then close current indicator and open new one
660 mShowRotatedIndicatorOnClose = true;
661 mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
662 // Don't show actor - will contain indicator for old orientation.
667 // set indicator visible mode
668 if( mIndicator != NULL )
670 mIndicator->SetVisible( mIndicatorVisible );
673 bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
674 SetIndicatorProperties( show, lastOrientation );
675 mIndicatorIsShown = show;
678 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
680 if( mIndicatorIsShown )
682 mShowRotatedIndicatorOnClose = true;
683 mNextIndicatorOrientation = orientation;
684 mIndicator->Close(); // May synchronously call IndicatorClosed() callback
688 // Save orientation for when the indicator is next shown
689 mShowRotatedIndicatorOnClose = false;
690 mNextIndicatorOrientation = orientation;
694 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
696 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
700 Ecore_Wl2_Window* wlWindow = wlSurface->GetWlWindow();
703 ecore_wl2_window_indicator_state_set(wlWindow, ECORE_WL2_INDICATOR_STATE_ON);
707 ecore_wl2_window_indicator_state_set(wlWindow, ECORE_WL2_INDICATOR_STATE_OFF);
712 void Window::IndicatorTypeChanged(Indicator::Type type)
714 #if defined(DALI_PROFILE_MOBILE)
715 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
719 Ecore_Wl2_Window* wlWindow = wlSurface->GetWlWindow();
722 case Indicator::INDICATOR_TYPE_1:
723 ecore_wl2_indicator_visible_type_set(wlWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN);
726 case Indicator::INDICATOR_TYPE_2:
727 ecore_wl2_indicator_visible_type_set(wlWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_HIDDEN);
730 case Indicator::INDICATOR_TYPE_UNKNOWN:
738 void Window::IndicatorClosed( IndicatorInterface* indicator )
740 DALI_LOG_TRACE_METHOD( gWindowLogFilter );
742 if( mShowRotatedIndicatorOnClose )
744 Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
745 mIndicator->Open(mNextIndicatorOrientation);
746 mIndicatorOrientation = mNextIndicatorOrientation;
747 SetIndicatorActorRotation();
748 DoShowIndicator(currentOrientation);
752 void Window::IndicatorVisibilityChanged(bool isVisible)
754 mIndicatorVisibilityChangedSignal.Emit(isVisible);
757 void Window::SetIndicatorActorRotation()
759 DALI_LOG_TRACE_METHOD( gWindowLogFilter );
760 DALI_ASSERT_DEBUG( mIndicator != NULL );
762 Dali::Actor actor = mIndicator->GetActor();
763 switch( mIndicatorOrientation )
765 case Dali::Window::PORTRAIT:
766 actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
767 actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
768 actor.SetOrientation( Degree(0), Vector3::ZAXIS );
770 case Dali::Window::PORTRAIT_INVERSE:
771 actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
772 actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
773 actor.SetOrientation( Degree(180), Vector3::ZAXIS );
775 case Dali::Window::LANDSCAPE:
776 actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
777 actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
778 actor.SetOrientation( Degree(270), Vector3::ZAXIS );
780 case Dali::Window::LANDSCAPE_INVERSE:
781 actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
782 actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
783 actor.SetOrientation( Degree(90), Vector3::ZAXIS );
790 // Use ecore_wl2_window_activate to prevent the window shown without rendering
791 ecore_wl2_window_activate( mEventHandler->mEcoreWindow );
796 ecore_wl2_window_lower( mEventHandler->mEcoreWindow );
799 void Window::Activate()
801 ecore_wl2_window_activate( mEventHandler->mEcoreWindow );
804 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
806 return mDragAndDropDetector;
809 Dali::Any Window::GetNativeHandle() const
813 return mEventHandler->mEcoreWindow;
821 void Window::OnStart()
823 DoShowIndicator( mIndicatorOrientation );
826 void Window::OnPause()
830 void Window::OnResume()
832 // resume indicator status
833 if( mIndicator != NULL )
835 // Restore own indicator opacity
836 // Send opacity mode to indicator service when app resumed
837 mIndicator->SetOpacityMode( mIndicatorOpacityMode );
841 void Window::OnStop()
852 void Window::OnDestroy()
857 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
861 if ( orientation <= Dali::Window::LANDSCAPE_INVERSE )
863 for( std::size_t i = 0; i < mAvailableOrientations.size(); i++ )
865 if( mAvailableOrientations[i] == orientation )
874 mAvailableOrientations.push_back(orientation);
875 SetAvailableOrientations( mAvailableOrientations );
880 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
882 for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
883 iter != mAvailableOrientations.end(); ++iter )
885 if( *iter == orientation )
887 mAvailableOrientations.erase( iter );
891 SetAvailableOrientations( mAvailableOrientations );
894 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
897 for( std::size_t i = 0; i < mAvailableOrientations.size(); ++i )
899 rotations[i] = static_cast< int >( mAvailableOrientations[i] );
901 ecore_wl2_window_available_rotations_set( mEventHandler->mEcoreWindow, rotations, mAvailableOrientations.size() );
904 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
906 return mAvailableOrientations;
909 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
911 mPreferredOrientation = orientation;
913 ecore_wl2_window_preferred_rotation_set( mEventHandler->mEcoreWindow, orientation );
916 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
918 return mPreferredOrientation;
921 void Window::SetAcceptFocus( bool accept )
923 mIsFocusAcceptable = accept;
925 ecore_wl2_window_focus_skip_set( mEventHandler->mEcoreWindow, !accept );
928 bool Window::IsFocusAcceptable() const
930 return mIsFocusAcceptable;
936 ecore_wl2_window_show( mEventHandler->mEcoreWindow );
942 WindowVisibilityObserver* observer( mAdaptor );
943 observer->OnWindowShown();
944 DALI_LOG_RELEASE_INFO( "Window (%p) ::Show() \n", mEventHandler->mEcoreWindow);
952 ecore_wl2_window_hide( mEventHandler->mEcoreWindow );
958 WindowVisibilityObserver* observer( mAdaptor );
959 observer->OnWindowHidden();
960 DALI_LOG_RELEASE_INFO( "Window (%p) ::Hide() \n", mEventHandler->mEcoreWindow);
965 bool Window::IsVisible() const
970 void Window::RotationDone( int orientation, int width, int height )
972 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
975 wlSurface->RequestRotation( orientation, width, height );
978 mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( width, height ) );
981 mResizedSignal.Emit( Dali::Window::WindowSize( width, height ) );
983 mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( width, height ) );
986 void Window::SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode )
988 // temp code TODO : need to re-imple dali indicator for EFL 1.20
989 //mIndicatorVisible = mode;
990 mIndicatorVisible = Dali::Window::INVISIBLE ;
993 unsigned int Window::GetSupportedAuxiliaryHintCount() const
995 return mSupportedAuxiliaryHints.size();
998 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
1000 if( index >= GetSupportedAuxiliaryHintCount() )
1002 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1005 return mSupportedAuxiliaryHints[index];
1008 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1010 bool supported = false;
1012 // Check if the hint is suppported
1013 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1024 DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1028 // Check if the hint is already added
1029 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1031 if( mAuxiliaryHints[i].first == hint )
1033 // Just change the value
1034 mAuxiliaryHints[i].second = value;
1036 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1038 return i + 1; // id is index + 1
1043 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1045 unsigned int id = mAuxiliaryHints.size();
1047 ecore_wl2_window_aux_hint_add( mEventHandler->mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1049 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1054 bool Window::RemoveAuxiliaryHint( unsigned int id )
1056 if( id == 0 || id > mAuxiliaryHints.size() )
1058 DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1062 mAuxiliaryHints[id - 1].second = std::string();
1064 ecore_wl2_window_aux_hint_del( mEventHandler->mEcoreWindow, static_cast< int >( id ) );
1066 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1071 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1073 if( id == 0 || id > mAuxiliaryHints.size() )
1075 DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1079 mAuxiliaryHints[id - 1].second = value;
1081 ecore_wl2_window_aux_hint_change( mEventHandler->mEcoreWindow, static_cast< int >( id ), value.c_str() );
1083 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
1088 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
1090 if( id == 0 || id > mAuxiliaryHints.size() )
1092 DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1093 return std::string();
1096 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
1098 return mAuxiliaryHints[id - 1].second;
1101 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
1103 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1105 if( mAuxiliaryHints[i].first == hint )
1107 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1112 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1117 void Window::SetInputRegion( const Rect< int >& inputRegion )
1119 ecore_wl2_window_input_region_set( mEventHandler->mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1121 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 );
1124 void Window::SetType( Dali::Window::Type type )
1126 Ecore_Wl2_Window_Type windowType;
1132 case Dali::Window::NORMAL:
1134 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1137 case Dali::Window::NOTIFICATION:
1139 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1142 case Dali::Window::UTILITY:
1144 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1147 case Dali::Window::DIALOG:
1149 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1154 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1159 ecore_wl2_window_type_set( mEventHandler->mEcoreWindow, windowType );
1165 Dali::Window::Type Window::GetType() const
1170 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
1172 if( mType != Dali::Window::NOTIFICATION )
1174 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
1178 while( !mEventHandler->mTizenPolicy )
1180 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1183 int notificationLevel;
1187 case Dali::Window::NotificationLevel::NONE:
1189 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1192 case Dali::Window::NotificationLevel::BASE:
1194 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1197 case Dali::Window::NotificationLevel::MEDIUM:
1199 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1202 case Dali::Window::NotificationLevel::HIGH:
1204 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1207 case Dali::Window::NotificationLevel::TOP:
1209 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1214 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: invalid level [%d]\n", level );
1215 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1220 mEventHandler->mNotificationLevelChangeDone = false;
1221 mEventHandler->mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1223 tizen_policy_set_notification_level( mEventHandler->mTizenPolicy, ecore_wl2_window_surface_get( mEventHandler->mEcoreWindow ), notificationLevel );
1227 while( !mEventHandler->mNotificationLevelChangeDone && count < 3 )
1229 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1230 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1234 if( !mEventHandler->mNotificationLevelChangeDone )
1236 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mEventHandler->mNotificationChangeState );
1239 else if( mEventHandler->mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1241 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Permission denied! [%d]\n", level );
1245 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Level is changed [%d]\n", mEventHandler->mNotificationLevel );
1250 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
1252 if( mType != Dali::Window::NOTIFICATION )
1254 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
1255 return Dali::Window::NotificationLevel::NONE;
1258 while( !mEventHandler->mTizenPolicy )
1260 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1265 while( !mEventHandler->mNotificationLevelChangeDone && count < 3 )
1267 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1268 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1272 if( !mEventHandler->mNotificationLevelChangeDone )
1274 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Error! [%d]\n", mEventHandler->mNotificationChangeState );
1275 return Dali::Window::NotificationLevel::NONE;
1278 Dali::Window::NotificationLevel::Type level;
1280 switch( mEventHandler->mNotificationLevel )
1282 case TIZEN_POLICY_LEVEL_NONE:
1284 level = Dali::Window::NotificationLevel::NONE;
1287 case TIZEN_POLICY_LEVEL_DEFAULT:
1289 level = Dali::Window::NotificationLevel::BASE;
1292 case TIZEN_POLICY_LEVEL_MEDIUM:
1294 level = Dali::Window::NotificationLevel::MEDIUM;
1297 case TIZEN_POLICY_LEVEL_HIGH:
1299 level = Dali::Window::NotificationLevel::HIGH;
1302 case TIZEN_POLICY_LEVEL_TOP:
1304 level = Dali::Window::NotificationLevel::TOP;
1309 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: invalid level [%d]\n", mEventHandler->mNotificationLevel );
1310 level = Dali::Window::NotificationLevel::NONE;
1315 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: level [%d]\n", mEventHandler->mNotificationLevel );
1320 void Window::SetOpaqueState( bool opaque )
1322 while( !mEventHandler->mTizenPolicy )
1324 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1327 tizen_policy_set_opaque_state( mEventHandler->mTizenPolicy, ecore_wl2_window_surface_get( mEventHandler->mEcoreWindow ), ( opaque ? 1 : 0 ) );
1329 mOpaqueState = opaque;
1331 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
1334 bool Window::IsOpaqueState() const
1336 return mOpaqueState;
1339 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
1341 while( !mEventHandler->mTizenPolicy )
1343 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1346 mEventHandler->mScreenOffModeChangeDone = false;
1347 mEventHandler->mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1349 unsigned int mode = 0;
1351 switch( screenOffMode )
1353 case Dali::Window::ScreenOffMode::TIMEOUT:
1358 case Dali::Window::ScreenOffMode::NEVER:
1365 tizen_policy_set_window_screen_mode( mEventHandler->mTizenPolicy, ecore_wl2_window_surface_get( mEventHandler->mEcoreWindow ), mode );
1369 while( !mEventHandler->mScreenOffModeChangeDone && count < 3 )
1371 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1372 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1376 if( !mEventHandler->mScreenOffModeChangeDone )
1378 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mEventHandler->mScreenOffModeChangeState );
1381 else if( mEventHandler->mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1383 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
1387 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenOffMode: Screen mode is changed [%d]\n", mEventHandler->mScreenOffMode );
1392 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
1394 while( !mEventHandler->mTizenPolicy )
1396 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1401 while( !mEventHandler->mScreenOffModeChangeDone && count < 3 )
1403 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1404 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1408 if( !mEventHandler->mScreenOffModeChangeDone )
1410 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetScreenOffMode: Error! [%d]\n", mEventHandler->mScreenOffModeChangeState );
1411 return Dali::Window::ScreenOffMode::TIMEOUT;
1414 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1416 switch( mEventHandler->mScreenOffMode )
1420 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1425 screenMode = Dali::Window::ScreenOffMode::NEVER;
1430 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetScreenOffMode: screen mode [%d]\n", mEventHandler->mScreenOffMode );
1435 bool Window::SetBrightness( int brightness )
1437 if( brightness < 0 || brightness > 100 )
1439 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
1443 while( !mEventHandler->mTizenDisplayPolicy )
1445 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1448 mEventHandler->mBrightnessChangeDone = false;
1449 mEventHandler->mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1451 tizen_display_policy_set_window_brightness( mEventHandler->mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEventHandler->mEcoreWindow ), brightness );
1455 while( !mEventHandler->mBrightnessChangeDone && count < 3 )
1457 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1458 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1462 if( !mEventHandler->mBrightnessChangeDone )
1464 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mEventHandler->mBrightnessChangeState );
1467 else if( mEventHandler->mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1469 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Permission denied! [%d]\n", brightness );
1473 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Brightness is changed [%d]\n", mEventHandler->mBrightness );
1478 int Window::GetBrightness() const
1480 while( !mEventHandler->mTizenDisplayPolicy )
1482 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1487 while( !mEventHandler->mBrightnessChangeDone && count < 3 )
1489 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1490 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1494 if( !mEventHandler->mBrightnessChangeDone )
1496 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetBrightness: Error! [%d]\n", mEventHandler->mBrightnessChangeState );
1500 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetBrightness: Brightness [%d]\n", mEventHandler->mBrightness );
1502 return mEventHandler->mBrightness;
1505 void Window::SetSize( Dali::Window::WindowSize size )
1507 if( !mResizeEnabled )
1509 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
1510 mResizeEnabled = true;
1513 PositionSize positionSize = mSurface->GetPositionSize();
1515 if( positionSize.width != size.GetWidth() || positionSize.height != size.GetHeight() )
1517 positionSize.width = size.GetWidth();
1518 positionSize.height = size.GetHeight();
1520 mSurface->MoveResize( positionSize );
1522 mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
1525 mResizedSignal.Emit( Dali::Window::WindowSize( positionSize.width, positionSize.height ) );
1527 mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
1531 Dali::Window::WindowSize Window::GetSize() const
1533 PositionSize positionSize = mSurface->GetPositionSize();
1535 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
1538 void Window::SetPosition( Dali::Window::WindowPosition position )
1540 if( !mResizeEnabled )
1542 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
1543 mResizeEnabled = true;
1546 PositionSize positionSize = mSurface->GetPositionSize();
1548 if( positionSize.x != position.GetX() || positionSize.y != position.GetY() )
1550 positionSize.x = position.GetX();
1551 positionSize.y = position.GetY();
1553 mSurface->MoveResize( positionSize );
1557 Dali::Window::WindowPosition Window::GetPosition() const
1559 PositionSize positionSize = mSurface->GetPositionSize();
1561 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
1564 void Window::SetTransparency( bool transparent )
1566 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
1569 wlSurface->SetTransparency( transparent );
1579 #pragma GCC diagnostic pop