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 if ( mIndicatorVisible == Dali::Window::VISIBLE )
480 // when the indicator is visible, set proper mode for indicator server according to bg mode
481 if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
483 ecore_wl2_window_indicator_opacity_set(wlWindow, ECORE_WL2_INDICATOR_OPAQUE);
485 else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
487 ecore_wl2_window_indicator_opacity_set(wlWindow, ECORE_WL2_INDICATOR_TRANSLUCENT);
489 else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
491 ecore_wl2_window_indicator_opacity_set(wlWindow, ECORE_WL2_INDICATOR_OPAQUE);
496 // when the indicator is not visible, set TRANSPARENT mode for indicator server
497 ecore_wl2_window_indicator_opacity_set(wlWindow, ECORE_WL2_INDICATOR_TRANSPARENT); // it means hidden indicator
501 DoShowIndicator( mIndicatorOrientation );
504 void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
506 DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
508 DoRotateIndicator( orientation );
511 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
513 mIndicatorOpacityMode = opacityMode;
515 if( mIndicator != NULL )
517 mIndicator->SetOpacityMode( opacityMode );
521 void Window::SetClass(std::string name, std::string klass)
523 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
527 Ecore_Wl2_Window* wlWindow = wlSurface->GetWlWindow();
528 ecore_wl2_window_title_set( wlWindow, name.c_str() );
529 ecore_wl2_window_class_set( wlWindow, klass.c_str() );
533 DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window has no surface\n" );
539 mIndicatorVisible( Dali::Window::VISIBLE ),
540 mIndicatorIsShown( false ),
541 mShowRotatedIndicatorOnClose( false ),
543 mIsTransparent( false ),
544 mWMRotationAppSet( false ),
545 mEcoreEventHander( true ),
546 mIsFocusAcceptable( true ),
549 mOpaqueState( false ),
550 mResizeEnabled( false ),
552 mIndicatorOrientation( Dali::Window::PORTRAIT ),
553 mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
554 mIndicatorOpacityMode( Dali::Window::OPAQUE ),
557 mType( Dali::Window::NORMAL ),
558 mEventHandler( NULL ),
559 mPreferredOrientation( Dali::Window::PORTRAIT ),
560 mSupportedAuxiliaryHints(),
562 mIndicatorVisibilityChangedSignal(),
563 mFocusChangedSignal(),
565 mDeleteRequestSignal()
571 delete mEventHandler;
581 mAdaptor->RemoveObserver( *this );
582 mAdaptor->SetDragAndDropDetector( NULL );
588 mSupportedAuxiliaryHints.clear();
589 mAuxiliaryHints.clear();
592 void Window::Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className)
594 // create an Wayland window by default
596 ECore::WindowRenderSurface* windowSurface = new ECore::WindowRenderSurface( positionSize, surface, name, mIsTransparent );
598 mSurface = windowSurface;
600 // create event handler for Wayland window
601 mEventHandler = new EventHandler( this );
603 // get auxiliary hint
604 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEventHandler->mEcoreWindow );
610 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) ) ) )
612 mSupportedAuxiliaryHints.push_back( hint );
614 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::Initialize: %s\n", hint );
618 if( !positionSize.IsEmpty() )
620 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
621 mResizeEnabled = true;
624 SetClass( name, className );
625 windowSurface->Map();
627 mOrientation = Orientation::New(this);
630 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
632 if( mIndicator == NULL )
634 if( mIndicatorVisible != Dali::Window::INVISIBLE )
636 mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, this );
637 mIndicator->SetOpacityMode( mIndicatorOpacityMode );
638 Dali::Actor actor = mIndicator->GetActor();
639 SetIndicatorActorRotation();
640 mOverlay->Add(actor);
642 // else don't create a hidden indicator
644 else // Already have indicator
646 if( mIndicatorVisible == Dali::Window::VISIBLE )
648 // If we are resuming, and rotation has changed,
649 if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
651 // then close current indicator and open new one
652 mShowRotatedIndicatorOnClose = true;
653 mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
654 // Don't show actor - will contain indicator for old orientation.
659 // set indicator visible mode
660 if( mIndicator != NULL )
662 mIndicator->SetVisible( mIndicatorVisible );
665 bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
666 SetIndicatorProperties( show, lastOrientation );
667 mIndicatorIsShown = show;
670 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
672 if( mIndicatorIsShown )
674 mShowRotatedIndicatorOnClose = true;
675 mNextIndicatorOrientation = orientation;
676 mIndicator->Close(); // May synchronously call IndicatorClosed() callback
680 // Save orientation for when the indicator is next shown
681 mShowRotatedIndicatorOnClose = false;
682 mNextIndicatorOrientation = orientation;
686 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
688 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
692 Ecore_Wl2_Window* wlWindow = wlSurface->GetWlWindow();
695 ecore_wl2_window_indicator_state_set(wlWindow, ECORE_WL2_INDICATOR_STATE_ON);
699 ecore_wl2_window_indicator_state_set(wlWindow, ECORE_WL2_INDICATOR_STATE_OFF);
704 void Window::IndicatorTypeChanged(Indicator::Type type)
706 #if defined(DALI_PROFILE_MOBILE)
707 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
711 Ecore_Wl2_Window* wlWindow = wlSurface->GetWlWindow();
714 case Indicator::INDICATOR_TYPE_1:
715 ecore_wl2_indicator_visible_type_set(wlWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN);
718 case Indicator::INDICATOR_TYPE_2:
719 ecore_wl2_indicator_visible_type_set(wlWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_HIDDEN);
722 case Indicator::INDICATOR_TYPE_UNKNOWN:
730 void Window::IndicatorClosed( IndicatorInterface* indicator )
732 DALI_LOG_TRACE_METHOD( gWindowLogFilter );
734 if( mShowRotatedIndicatorOnClose )
736 Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
737 mIndicator->Open(mNextIndicatorOrientation);
738 mIndicatorOrientation = mNextIndicatorOrientation;
739 SetIndicatorActorRotation();
740 DoShowIndicator(currentOrientation);
744 void Window::IndicatorVisibilityChanged(bool isVisible)
746 mIndicatorVisibilityChangedSignal.Emit(isVisible);
749 void Window::SetIndicatorActorRotation()
751 DALI_LOG_TRACE_METHOD( gWindowLogFilter );
752 DALI_ASSERT_DEBUG( mIndicator != NULL );
754 Dali::Actor actor = mIndicator->GetActor();
755 switch( mIndicatorOrientation )
757 case Dali::Window::PORTRAIT:
758 actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
759 actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
760 actor.SetOrientation( Degree(0), Vector3::ZAXIS );
762 case Dali::Window::PORTRAIT_INVERSE:
763 actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
764 actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
765 actor.SetOrientation( Degree(180), Vector3::ZAXIS );
767 case Dali::Window::LANDSCAPE:
768 actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
769 actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
770 actor.SetOrientation( Degree(270), Vector3::ZAXIS );
772 case Dali::Window::LANDSCAPE_INVERSE:
773 actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
774 actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
775 actor.SetOrientation( Degree(90), Vector3::ZAXIS );
782 // Use ecore_wl2_window_activate to prevent the window shown without rendering
783 ecore_wl2_window_activate( mEventHandler->mEcoreWindow );
788 ecore_wl2_window_lower( mEventHandler->mEcoreWindow );
791 void Window::Activate()
793 ecore_wl2_window_activate( mEventHandler->mEcoreWindow );
796 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
798 return mDragAndDropDetector;
801 Dali::Any Window::GetNativeHandle() const
805 return mEventHandler->mEcoreWindow;
813 void Window::OnStart()
815 DoShowIndicator( mIndicatorOrientation );
818 void Window::OnPause()
822 void Window::OnResume()
824 // resume indicator status
825 if( mIndicator != NULL )
827 // Restore own indicator opacity
828 // Send opacity mode to indicator service when app resumed
829 mIndicator->SetOpacityMode( mIndicatorOpacityMode );
833 void Window::OnStop()
844 void Window::OnDestroy()
849 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
853 if ( orientation <= Dali::Window::LANDSCAPE_INVERSE )
855 for( std::size_t i = 0; i < mAvailableOrientations.size(); i++ )
857 if( mAvailableOrientations[i] == orientation )
866 mAvailableOrientations.push_back(orientation);
867 SetAvailableOrientations( mAvailableOrientations );
872 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
874 for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
875 iter != mAvailableOrientations.end(); ++iter )
877 if( *iter == orientation )
879 mAvailableOrientations.erase( iter );
883 SetAvailableOrientations( mAvailableOrientations );
886 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
889 for( std::size_t i = 0; i < mAvailableOrientations.size(); ++i )
891 rotations[i] = static_cast< int >( mAvailableOrientations[i] );
893 ecore_wl2_window_available_rotations_set( mEventHandler->mEcoreWindow, rotations, mAvailableOrientations.size() );
896 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
898 return mAvailableOrientations;
901 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
903 mPreferredOrientation = orientation;
905 ecore_wl2_window_preferred_rotation_set( mEventHandler->mEcoreWindow, orientation );
908 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
910 return mPreferredOrientation;
913 void Window::SetAcceptFocus( bool accept )
915 mIsFocusAcceptable = accept;
917 ecore_wl2_window_focus_skip_set( mEventHandler->mEcoreWindow, !accept );
920 bool Window::IsFocusAcceptable() const
922 return mIsFocusAcceptable;
928 ecore_wl2_window_show( mEventHandler->mEcoreWindow );
934 WindowVisibilityObserver* observer( mAdaptor );
935 observer->OnWindowShown();
936 DALI_LOG_RELEASE_INFO( "Window (%p) ::Show() \n", mEventHandler->mEcoreWindow);
944 ecore_wl2_window_hide( mEventHandler->mEcoreWindow );
950 WindowVisibilityObserver* observer( mAdaptor );
951 observer->OnWindowHidden();
952 DALI_LOG_RELEASE_INFO( "Window (%p) ::Hide() \n", mEventHandler->mEcoreWindow);
957 bool Window::IsVisible() const
962 void Window::RotationDone( int orientation, int width, int height )
964 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
967 wlSurface->RequestRotation( orientation, width, height );
970 mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( width, height ) );
973 mResizedSignal.Emit( Dali::Window::WindowSize( width, height ) );
975 mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( width, height ) );
978 void Window::SetIndicatorVisibleMode( Dali::Window::IndicatorVisibleMode mode )
980 mIndicatorVisible = mode;
983 unsigned int Window::GetSupportedAuxiliaryHintCount() const
985 return mSupportedAuxiliaryHints.size();
988 std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
990 if( index >= GetSupportedAuxiliaryHintCount() )
992 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
995 return mSupportedAuxiliaryHints[index];
998 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1000 bool supported = false;
1002 // Check if the hint is suppported
1003 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1014 DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1018 // Check if the hint is already added
1019 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1021 if( mAuxiliaryHints[i].first == hint )
1023 // Just change the value
1024 mAuxiliaryHints[i].second = value;
1026 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1028 return i + 1; // id is index + 1
1033 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1035 unsigned int id = mAuxiliaryHints.size();
1037 ecore_wl2_window_aux_hint_add( mEventHandler->mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1039 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1044 bool Window::RemoveAuxiliaryHint( unsigned int id )
1046 if( id == 0 || id > mAuxiliaryHints.size() )
1048 DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1052 mAuxiliaryHints[id - 1].second = std::string();
1054 ecore_wl2_window_aux_hint_del( mEventHandler->mEcoreWindow, static_cast< int >( id ) );
1056 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1061 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1063 if( id == 0 || id > mAuxiliaryHints.size() )
1065 DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1069 mAuxiliaryHints[id - 1].second = value;
1071 ecore_wl2_window_aux_hint_change( mEventHandler->mEcoreWindow, static_cast< int >( id ), value.c_str() );
1073 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() );
1078 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
1080 if( id == 0 || id > mAuxiliaryHints.size() )
1082 DALI_LOG_INFO( gWindowLogFilter, Debug::Concise, "Window::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1083 return std::string();
1086 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() );
1088 return mAuxiliaryHints[id - 1].second;
1091 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
1093 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1095 if( mAuxiliaryHints[i].first == hint )
1097 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1102 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1107 void Window::SetInputRegion( const Rect< int >& inputRegion )
1109 ecore_wl2_window_input_region_set( mEventHandler->mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1111 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 );
1114 void Window::SetType( Dali::Window::Type type )
1116 Ecore_Wl2_Window_Type windowType;
1122 case Dali::Window::NORMAL:
1124 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1127 case Dali::Window::NOTIFICATION:
1129 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1132 case Dali::Window::UTILITY:
1134 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1137 case Dali::Window::DIALOG:
1139 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1144 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1149 ecore_wl2_window_type_set( mEventHandler->mEcoreWindow, windowType );
1155 Dali::Window::Type Window::GetType() const
1160 bool Window::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
1162 if( mType != Dali::Window::NOTIFICATION )
1164 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
1168 while( !mEventHandler->mTizenPolicy )
1170 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1173 int notificationLevel;
1177 case Dali::Window::NotificationLevel::NONE:
1179 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1182 case Dali::Window::NotificationLevel::BASE:
1184 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1187 case Dali::Window::NotificationLevel::MEDIUM:
1189 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1192 case Dali::Window::NotificationLevel::HIGH:
1194 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1197 case Dali::Window::NotificationLevel::TOP:
1199 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1204 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: invalid level [%d]\n", level );
1205 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1210 mEventHandler->mNotificationLevelChangeDone = false;
1211 mEventHandler->mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1213 tizen_policy_set_notification_level( mEventHandler->mTizenPolicy, ecore_wl2_window_surface_get( mEventHandler->mEcoreWindow ), notificationLevel );
1217 while( !mEventHandler->mNotificationLevelChangeDone && count < 3 )
1219 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1220 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1224 if( !mEventHandler->mNotificationLevelChangeDone )
1226 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mEventHandler->mNotificationChangeState );
1229 else if( mEventHandler->mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1231 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Permission denied! [%d]\n", level );
1235 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Level is changed [%d]\n", mEventHandler->mNotificationLevel );
1240 Dali::Window::NotificationLevel::Type Window::GetNotificationLevel() const
1242 if( mType != Dali::Window::NOTIFICATION )
1244 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
1245 return Dali::Window::NotificationLevel::NONE;
1248 while( !mEventHandler->mTizenPolicy )
1250 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1255 while( !mEventHandler->mNotificationLevelChangeDone && count < 3 )
1257 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1258 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1262 if( !mEventHandler->mNotificationLevelChangeDone )
1264 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Error! [%d]\n", mEventHandler->mNotificationChangeState );
1265 return Dali::Window::NotificationLevel::NONE;
1268 Dali::Window::NotificationLevel::Type level;
1270 switch( mEventHandler->mNotificationLevel )
1272 case TIZEN_POLICY_LEVEL_NONE:
1274 level = Dali::Window::NotificationLevel::NONE;
1277 case TIZEN_POLICY_LEVEL_DEFAULT:
1279 level = Dali::Window::NotificationLevel::BASE;
1282 case TIZEN_POLICY_LEVEL_MEDIUM:
1284 level = Dali::Window::NotificationLevel::MEDIUM;
1287 case TIZEN_POLICY_LEVEL_HIGH:
1289 level = Dali::Window::NotificationLevel::HIGH;
1292 case TIZEN_POLICY_LEVEL_TOP:
1294 level = Dali::Window::NotificationLevel::TOP;
1299 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: invalid level [%d]\n", mEventHandler->mNotificationLevel );
1300 level = Dali::Window::NotificationLevel::NONE;
1305 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: level [%d]\n", mEventHandler->mNotificationLevel );
1310 void Window::SetOpaqueState( bool opaque )
1312 while( !mEventHandler->mTizenPolicy )
1314 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1317 tizen_policy_set_opaque_state( mEventHandler->mTizenPolicy, ecore_wl2_window_surface_get( mEventHandler->mEcoreWindow ), ( opaque ? 1 : 0 ) );
1319 mOpaqueState = opaque;
1321 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
1324 bool Window::IsOpaqueState() const
1326 return mOpaqueState;
1329 bool Window::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
1331 while( !mEventHandler->mTizenPolicy )
1333 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1336 mEventHandler->mScreenOffModeChangeDone = false;
1337 mEventHandler->mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1339 unsigned int mode = 0;
1341 switch( screenOffMode )
1343 case Dali::Window::ScreenOffMode::TIMEOUT:
1348 case Dali::Window::ScreenOffMode::NEVER:
1355 tizen_policy_set_window_screen_mode( mEventHandler->mTizenPolicy, ecore_wl2_window_surface_get( mEventHandler->mEcoreWindow ), mode );
1359 while( !mEventHandler->mScreenOffModeChangeDone && count < 3 )
1361 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1362 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1366 if( !mEventHandler->mScreenOffModeChangeDone )
1368 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mEventHandler->mScreenOffModeChangeState );
1371 else if( mEventHandler->mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1373 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
1377 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetScreenOffMode: Screen mode is changed [%d]\n", mEventHandler->mScreenOffMode );
1382 Dali::Window::ScreenOffMode::Type Window::GetScreenOffMode() const
1384 while( !mEventHandler->mTizenPolicy )
1386 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1391 while( !mEventHandler->mScreenOffModeChangeDone && count < 3 )
1393 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1394 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1398 if( !mEventHandler->mScreenOffModeChangeDone )
1400 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetScreenOffMode: Error! [%d]\n", mEventHandler->mScreenOffModeChangeState );
1401 return Dali::Window::ScreenOffMode::TIMEOUT;
1404 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1406 switch( mEventHandler->mScreenOffMode )
1410 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1415 screenMode = Dali::Window::ScreenOffMode::NEVER;
1420 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetScreenOffMode: screen mode [%d]\n", mEventHandler->mScreenOffMode );
1425 bool Window::SetBrightness( int brightness )
1427 if( brightness < 0 || brightness > 100 )
1429 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
1433 while( !mEventHandler->mTizenDisplayPolicy )
1435 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1438 mEventHandler->mBrightnessChangeDone = false;
1439 mEventHandler->mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1441 tizen_display_policy_set_window_brightness( mEventHandler->mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEventHandler->mEcoreWindow ), brightness );
1445 while( !mEventHandler->mBrightnessChangeDone && count < 3 )
1447 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1448 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1452 if( !mEventHandler->mBrightnessChangeDone )
1454 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mEventHandler->mBrightnessChangeState );
1457 else if( mEventHandler->mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1459 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Permission denied! [%d]\n", brightness );
1463 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Brightness is changed [%d]\n", mEventHandler->mBrightness );
1468 int Window::GetBrightness() const
1470 while( !mEventHandler->mTizenDisplayPolicy )
1472 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1477 while( !mEventHandler->mBrightnessChangeDone && count < 3 )
1479 ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
1480 wl_display_dispatch_queue( mEventHandler->mDisplay, mEventHandler->mEventQueue );
1484 if( !mEventHandler->mBrightnessChangeDone )
1486 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetBrightness: Error! [%d]\n", mEventHandler->mBrightnessChangeState );
1490 DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetBrightness: Brightness [%d]\n", mEventHandler->mBrightness );
1492 return mEventHandler->mBrightness;
1495 void Window::SetSize( Dali::Window::WindowSize size )
1497 if( !mResizeEnabled )
1499 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
1500 mResizeEnabled = true;
1503 PositionSize positionSize = mSurface->GetPositionSize();
1505 if( positionSize.width != size.GetWidth() || positionSize.height != size.GetHeight() )
1507 positionSize.width = size.GetWidth();
1508 positionSize.height = size.GetHeight();
1510 mSurface->MoveResize( positionSize );
1512 mAdaptor->SurfaceResizePrepare( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
1515 mResizedSignal.Emit( Dali::Window::WindowSize( positionSize.width, positionSize.height ) );
1517 mAdaptor->SurfaceResizeComplete( Adaptor::SurfaceSize( positionSize.width, positionSize.height ) );
1521 Dali::Window::WindowSize Window::GetSize() const
1523 PositionSize positionSize = mSurface->GetPositionSize();
1525 return Dali::Window::WindowSize( positionSize.width, positionSize.height );
1528 void Window::SetPosition( Dali::Window::WindowPosition position )
1530 if( !mResizeEnabled )
1532 AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
1533 mResizeEnabled = true;
1536 PositionSize positionSize = mSurface->GetPositionSize();
1538 if( positionSize.x != position.GetX() || positionSize.y != position.GetY() )
1540 positionSize.x = position.GetX();
1541 positionSize.y = position.GetY();
1543 mSurface->MoveResize( positionSize );
1547 Dali::Window::WindowPosition Window::GetPosition() const
1549 PositionSize positionSize = mSurface->GetPositionSize();
1551 return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
1554 void Window::SetTransparency( bool transparent )
1556 ECore::WindowRenderSurface* wlSurface( dynamic_cast< ECore::WindowRenderSurface * >( mSurface ) );
1559 wlSurface->SetTransparency( transparent );
1569 #pragma GCC diagnostic pop