2 * Copyright (c) 2018 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.
18 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
23 #include <dali/internal/window-system/tizen-wayland/window-base-ecore-wl.h>
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/tizen-wayland/window-render-surface-ecore-wl.h>
30 #include <dali/public-api/object/any.h>
31 #include <dali/integration-api/debug.h>
45 #if defined(DEBUG_ENABLED)
46 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
49 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
51 /// Called when the window iconify state is changed.
52 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
54 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
57 return windowBase->OnIconifyStateChanged( data, type, event );
60 return ECORE_CALLBACK_PASS_ON;
63 /// Called when the window gains focus
64 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
66 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
69 return windowBase->OnFocusIn( data, type, event );
72 return ECORE_CALLBACK_PASS_ON;
75 /// Called when the window loses focus
76 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
78 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
81 return windowBase->OnFocusOut( data, type, event );
84 return ECORE_CALLBACK_PASS_ON;
87 /// Called when the output is transformed
88 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
90 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
93 return windowBase->OnOutputTransform( data, type, event );
96 return ECORE_CALLBACK_PASS_ON;
99 /// Called when the output transform should be ignored
100 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
102 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
105 return windowBase->OnIgnoreOutputTransform( data, type, event );
108 return ECORE_CALLBACK_PASS_ON;
111 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
113 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
116 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
120 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
122 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
125 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
129 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
133 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 )
137 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
139 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
142 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
146 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
150 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
152 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
155 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
159 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
163 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
167 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
171 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
175 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 )
179 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
181 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
184 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
188 const struct wl_registry_listener registryListener =
190 RegistryGlobalCallback,
191 RegistryGlobalCallbackRemove
194 const struct tizen_policy_listener tizenPolicyListener =
196 TizenPolicyConformant,
197 TizenPolicyConformantArea,
198 TizenPolicyNotificationChangeDone,
199 TizenPolicyTransientForDone,
200 TizenPolicyScreenModeChangeDone,
201 TizenPolicyIconifyStateChanged,
202 TizenPolicySupportedAuxiliaryHints,
203 TizenPolicyAllowedAuxiliaryHint,
204 TizenPolicyAuxiliaryMessage,
205 TizenPolicyConformantRegion
208 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
210 DisplayPolicyBrightnessChangeDone
213 } // unnamed namespace
215 WindowBaseEcoreWl::WindowBaseEcoreWl( Window* window, WindowRenderSurface* windowRenderSurface )
216 : mEcoreEventHandler(),
218 mWindowSurface( NULL ),
219 mEcoreWindow( NULL ),
222 mTizenPolicy( NULL ),
223 mTizenDisplayPolicy( NULL ),
224 mSupportedAuxiliaryHints(),
226 mNotificationLevel( -1 ),
227 mNotificationChangeState( 0 ),
228 mNotificationLevelChangeDone( true ),
230 mScreenOffModeChangeState( 0 ),
231 mScreenOffModeChangeDone( true ),
233 mBrightnessChangeState( 0 ),
234 mBrightnessChangeDone( true )
236 mWindowSurface = dynamic_cast< WindowRenderSurfaceEcoreWl* >( windowRenderSurface );
239 WindowBaseEcoreWl::~WindowBaseEcoreWl()
241 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
243 ecore_event_handler_del( *iter );
245 mEcoreEventHandler.Clear();
249 wl_event_queue_destroy( mEventQueue );
252 mSupportedAuxiliaryHints.clear();
253 mAuxiliaryHints.clear();
256 void WindowBaseEcoreWl::Initialize()
258 if( !mWindowSurface )
260 DALI_ASSERT_ALWAYS( "Invalid window surface" );
263 mEcoreWindow = mWindowSurface->GetWlWindow();
264 DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no EcoreWl window" );
266 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
267 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
268 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
269 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this) );
270 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this) );
272 mDisplay = ecore_wl_display_get();
276 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
279 mEventQueue = wl_display_create_queue( mDisplay );
282 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
284 wl_registry* registry = wl_display_get_registry( displayWrapper );
285 wl_registry_add_listener( registry, ®istryListener, this );
288 wl_proxy_wrapper_destroy( displayWrapper );
292 // get auxiliary hint
293 Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEcoreWindow );
299 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) ) ) )
301 mSupportedAuxiliaryHints.push_back( hint );
303 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint );
308 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event )
310 Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
311 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
313 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) )
315 if( iconifyChangedEvent->iconified == EINA_TRUE )
317 mWindow->OnIconifyChanged( true );
321 mWindow->OnIconifyChanged( false );
323 handled = ECORE_CALLBACK_DONE;
329 Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event )
331 Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
333 if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
335 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
337 mWindow->OnFocusChanged( true );
340 return ECORE_CALLBACK_PASS_ON;
343 Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event )
345 Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
347 if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
349 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
351 mWindow->OnFocusChanged( false );
354 return ECORE_CALLBACK_PASS_ON;
357 Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event )
359 Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) );
361 if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) )
363 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
365 mWindowSurface->OutputTransformed();
367 mWindow->OnOutputTransformed();
370 return ECORE_CALLBACK_PASS_ON;
373 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event )
375 Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) );
377 if( ignoreTransformEvent->win == mEcoreWindow )
379 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
381 mWindowSurface->OutputTransformed();
383 mWindow->OnOutputTransformed();
386 return ECORE_CALLBACK_PASS_ON;
389 void WindowBaseEcoreWl::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
391 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
393 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
395 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
398 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
402 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
404 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
406 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
408 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
409 if( !mTizenDisplayPolicy )
411 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
415 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
417 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
421 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
424 mTizenDisplayPolicy = NULL;
427 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
429 mNotificationLevel = level;
430 mNotificationChangeState = state;
431 mNotificationLevelChangeDone = true;
433 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
436 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
438 mScreenOffMode = mode;
439 mScreenOffModeChangeState = state;
440 mScreenOffModeChangeDone = true;
442 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
445 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
447 mBrightness = brightness;
448 mBrightnessChangeState = state;
449 mBrightnessChangeDone = true;
451 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
454 void WindowBaseEcoreWl::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
456 DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
458 if( visibleMode == Dali::Window::VISIBLE )
460 // when the indicator is visible, set proper mode for indicator server according to bg mode
461 if( opacityMode == Dali::Window::OPAQUE )
463 ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_OPAQUE );
465 else if( opacityMode == Dali::Window::TRANSLUCENT )
467 ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_TRANSLUCENT );
469 else if( opacityMode == Dali::Window::TRANSPARENT )
471 ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_OPAQUE );
476 // when the indicator is not visible, set TRANSPARENT mode for indicator server
477 ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_TRANSPARENT); // it means hidden indicator
481 void WindowBaseEcoreWl::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
485 ecore_wl_window_indicator_state_set( mEcoreWindow, ECORE_WL_INDICATOR_STATE_ON );
489 ecore_wl_window_indicator_state_set( mEcoreWindow, ECORE_WL_INDICATOR_STATE_OFF );
493 void WindowBaseEcoreWl::IndicatorTypeChanged( IndicatorInterface::Type type )
495 #if defined(DALI_PROFILE_MOBILE)
498 case IndicatorInterface::INDICATOR_TYPE_1:
500 ecore_wl_indicator_visible_type_set( mEcoreWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN );
503 case IndicatorInterface::INDICATOR_TYPE_2:
505 ecore_wl_indicator_visible_type_set( mEcoreWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_HIDDEN );
508 case IndicatorInterface::INDICATOR_TYPE_UNKNOWN:
517 void WindowBaseEcoreWl::SetClass( std::string name, std::string className )
519 ecore_wl_window_title_set( mEcoreWindow, name.c_str() );
520 ecore_wl_window_class_name_set( mEcoreWindow, className.c_str() );
523 void WindowBaseEcoreWl::Raise()
525 // Use ecore_wl_window_activate to prevent the window shown without rendering
526 ecore_wl_window_activate( mEcoreWindow );
529 void WindowBaseEcoreWl::Lower()
531 ecore_wl_window_lower( mEcoreWindow );
534 void WindowBaseEcoreWl::Activate()
536 ecore_wl_window_activate( mEcoreWindow );
539 void WindowBaseEcoreWl::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
541 int rotations[4] = { 0 };
542 for( std::size_t i = 0; i < orientations.size(); ++i )
544 rotations[i] = static_cast< int >( orientations[i] );
546 ecore_wl_window_rotation_available_rotations_set( mEcoreWindow, rotations, orientations.size() );
549 void WindowBaseEcoreWl::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
551 ecore_wl_window_rotation_preferred_rotation_set( mEcoreWindow, orientation );
554 void WindowBaseEcoreWl::SetAcceptFocus( bool accept )
556 ecore_wl_window_focus_skip_set( mEcoreWindow, !accept );
559 void WindowBaseEcoreWl::Show()
561 ecore_wl_window_show( mEcoreWindow );
564 void WindowBaseEcoreWl::Hide()
566 ecore_wl_window_hide( mEcoreWindow );
569 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
571 return mSupportedAuxiliaryHints.size();
574 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint( unsigned int index ) const
576 if( index >= GetSupportedAuxiliaryHintCount() )
578 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
581 return mSupportedAuxiliaryHints[index];
584 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint( const std::string& hint, const std::string& value )
586 bool supported = false;
588 // Check if the hint is suppported
589 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
600 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
604 // Check if the hint is already added
605 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
607 if( mAuxiliaryHints[i].first == hint )
609 // Just change the value
610 mAuxiliaryHints[i].second = value;
612 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
614 return i + 1; // id is index + 1
619 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
621 unsigned int id = mAuxiliaryHints.size();
623 ecore_wl_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
625 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
630 bool WindowBaseEcoreWl::RemoveAuxiliaryHint( unsigned int id )
632 if( id == 0 || id > mAuxiliaryHints.size() )
634 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
638 mAuxiliaryHints[id - 1].second = std::string();
640 ecore_wl_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
642 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
647 bool WindowBaseEcoreWl::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
649 if( id == 0 || id > mAuxiliaryHints.size() )
651 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
655 mAuxiliaryHints[id - 1].second = value;
657 ecore_wl_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
659 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
664 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue( unsigned int id ) const
666 if( id == 0 || id > mAuxiliaryHints.size() )
668 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
669 return std::string();
672 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
674 return mAuxiliaryHints[id - 1].second;
677 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId( const std::string& hint ) const
679 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
681 if( mAuxiliaryHints[i].first == hint )
683 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
688 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
693 void WindowBaseEcoreWl::SetInputRegion( const Rect< int >& inputRegion )
695 ecore_wl_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
698 void WindowBaseEcoreWl::SetType( Dali::Window::Type type )
700 Ecore_Wl_Window_Type windowType;
704 case Dali::Window::NORMAL:
706 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
709 case Dali::Window::NOTIFICATION:
711 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
714 case Dali::Window::UTILITY:
716 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
719 case Dali::Window::DIALOG:
721 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
726 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
731 ecore_wl_window_type_set( mEcoreWindow, windowType );
734 bool WindowBaseEcoreWl::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
736 while( !mTizenPolicy )
738 wl_display_dispatch_queue( mDisplay, mEventQueue );
741 int notificationLevel;
745 case Dali::Window::NotificationLevel::NONE:
747 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
750 case Dali::Window::NotificationLevel::BASE:
752 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
755 case Dali::Window::NotificationLevel::MEDIUM:
757 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
760 case Dali::Window::NotificationLevel::HIGH:
762 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
765 case Dali::Window::NotificationLevel::TOP:
767 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
772 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level );
773 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
778 mNotificationLevelChangeDone = false;
779 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
781 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), notificationLevel );
785 while( !mNotificationLevelChangeDone && count < 3 )
788 wl_display_dispatch_queue( mDisplay, mEventQueue );
792 if( !mNotificationLevelChangeDone )
794 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
797 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
799 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level );
803 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
808 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl::GetNotificationLevel() const
810 while( !mTizenPolicy )
812 wl_display_dispatch_queue( mDisplay, mEventQueue );
817 while( !mNotificationLevelChangeDone && count < 3 )
820 wl_display_dispatch_queue( mDisplay, mEventQueue );
824 if( !mNotificationLevelChangeDone )
826 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
827 return Dali::Window::NotificationLevel::NONE;
830 Dali::Window::NotificationLevel::Type level;
832 switch( mNotificationLevel )
834 case TIZEN_POLICY_LEVEL_NONE:
836 level = Dali::Window::NotificationLevel::NONE;
839 case TIZEN_POLICY_LEVEL_DEFAULT:
841 level = Dali::Window::NotificationLevel::BASE;
844 case TIZEN_POLICY_LEVEL_MEDIUM:
846 level = Dali::Window::NotificationLevel::MEDIUM;
849 case TIZEN_POLICY_LEVEL_HIGH:
851 level = Dali::Window::NotificationLevel::HIGH;
854 case TIZEN_POLICY_LEVEL_TOP:
856 level = Dali::Window::NotificationLevel::TOP;
861 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
862 level = Dali::Window::NotificationLevel::NONE;
867 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel );
872 void WindowBaseEcoreWl::SetOpaqueState( bool opaque )
874 while( !mTizenPolicy )
876 wl_display_dispatch_queue( mDisplay, mEventQueue );
879 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
882 bool WindowBaseEcoreWl::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
884 while( !mTizenPolicy )
886 wl_display_dispatch_queue( mDisplay, mEventQueue );
889 mScreenOffModeChangeDone = false;
890 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
892 unsigned int mode = 0;
894 switch( screenOffMode )
896 case Dali::Window::ScreenOffMode::TIMEOUT:
901 case Dali::Window::ScreenOffMode::NEVER:
908 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), mode );
912 while( !mScreenOffModeChangeDone && count < 3 )
915 wl_display_dispatch_queue( mDisplay, mEventQueue );
919 if( !mScreenOffModeChangeDone )
921 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
924 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
926 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
930 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
935 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl::GetScreenOffMode() const
937 while( !mTizenPolicy )
939 wl_display_dispatch_queue( mDisplay, mEventQueue );
944 while( !mScreenOffModeChangeDone && count < 3 )
947 wl_display_dispatch_queue( mDisplay, mEventQueue );
951 if( !mScreenOffModeChangeDone )
953 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
954 return Dali::Window::ScreenOffMode::TIMEOUT;
957 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
959 switch( mScreenOffMode )
963 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
968 screenMode = Dali::Window::ScreenOffMode::NEVER;
973 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
978 bool WindowBaseEcoreWl::SetBrightness( int brightness )
980 while( !mTizenDisplayPolicy )
982 wl_display_dispatch_queue( mDisplay, mEventQueue );
985 mBrightnessChangeDone = false;
986 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
988 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl_window_surface_get( mEcoreWindow ), brightness );
992 while( !mBrightnessChangeDone && count < 3 )
995 wl_display_dispatch_queue( mDisplay, mEventQueue );
999 if( !mBrightnessChangeDone )
1001 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
1004 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1006 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness );
1010 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness );
1015 int WindowBaseEcoreWl::GetBrightness() const
1017 while( !mTizenDisplayPolicy )
1019 wl_display_dispatch_queue( mDisplay, mEventQueue );
1024 while( !mBrightnessChangeDone && count < 3 )
1027 wl_display_dispatch_queue( mDisplay, mEventQueue );
1031 if( !mBrightnessChangeDone )
1033 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
1037 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness );
1042 } // namespace Adaptor
1044 } // namespace Internal
1048 #pragma GCC diagnostic pop