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/ecore-wl/window-base-ecore-wl.h>
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/tizen-wayland/ecore-wl/window-render-surface-ecore-wl.h>
28 #include <dali/internal/input/common/key-impl.h>
31 #include <dali/public-api/object/any.h>
32 #include <dali/integration-api/debug.h>
46 #if defined(DEBUG_ENABLED)
47 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
50 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
52 /// Called when the window iconify state is changed.
53 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
55 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
58 return windowBase->OnIconifyStateChanged( data, type, event );
61 return ECORE_CALLBACK_PASS_ON;
64 /// Called when the window gains focus
65 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
67 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
70 return windowBase->OnFocusIn( data, type, event );
73 return ECORE_CALLBACK_PASS_ON;
76 /// Called when the window loses focus
77 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
79 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
82 return windowBase->OnFocusOut( data, type, event );
85 return ECORE_CALLBACK_PASS_ON;
88 /// Called when the output is transformed
89 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
91 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
94 return windowBase->OnOutputTransform( data, type, event );
97 return ECORE_CALLBACK_PASS_ON;
100 /// Called when the output transform should be ignored
101 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
103 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
106 return windowBase->OnIgnoreOutputTransform( data, type, event );
109 return ECORE_CALLBACK_PASS_ON;
112 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
114 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
117 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
121 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
123 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
126 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
130 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
134 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 )
138 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
140 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
143 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
147 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
151 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
153 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
156 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
160 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
164 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
168 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
172 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
176 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 )
180 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
182 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
185 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
189 const struct wl_registry_listener registryListener =
191 RegistryGlobalCallback,
192 RegistryGlobalCallbackRemove
195 const struct tizen_policy_listener tizenPolicyListener =
197 TizenPolicyConformant,
198 TizenPolicyConformantArea,
199 TizenPolicyNotificationChangeDone,
200 TizenPolicyTransientForDone,
201 TizenPolicyScreenModeChangeDone,
202 TizenPolicyIconifyStateChanged,
203 TizenPolicySupportedAuxiliaryHints,
204 TizenPolicyAllowedAuxiliaryHint,
205 TizenPolicyAuxiliaryMessage,
206 TizenPolicyConformantRegion
209 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
211 DisplayPolicyBrightnessChangeDone
214 } // unnamed namespace
216 WindowBaseEcoreWl::WindowBaseEcoreWl( Window* window, WindowRenderSurface* windowRenderSurface )
217 : mEcoreEventHandler(),
219 mWindowSurface( NULL ),
220 mEcoreWindow( NULL ),
223 mTizenPolicy( NULL ),
224 mTizenDisplayPolicy( NULL ),
225 mSupportedAuxiliaryHints(),
227 mNotificationLevel( -1 ),
228 mNotificationChangeState( 0 ),
229 mNotificationLevelChangeDone( true ),
231 mScreenOffModeChangeState( 0 ),
232 mScreenOffModeChangeDone( true ),
234 mBrightnessChangeState( 0 ),
235 mBrightnessChangeDone( true )
237 mWindowSurface = dynamic_cast< WindowRenderSurfaceEcoreWl* >( windowRenderSurface );
240 WindowBaseEcoreWl::~WindowBaseEcoreWl()
242 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
244 ecore_event_handler_del( *iter );
246 mEcoreEventHandler.Clear();
250 wl_event_queue_destroy( mEventQueue );
253 mSupportedAuxiliaryHints.clear();
254 mAuxiliaryHints.clear();
257 void WindowBaseEcoreWl::Initialize()
259 if( !mWindowSurface )
261 DALI_ASSERT_ALWAYS( "Invalid window surface" );
264 mEcoreWindow = mWindowSurface->GetWlWindow();
265 DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no EcoreWl window" );
267 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
268 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
269 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
270 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this) );
271 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this) );
273 mDisplay = ecore_wl_display_get();
277 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
280 mEventQueue = wl_display_create_queue( mDisplay );
283 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
285 wl_registry* registry = wl_display_get_registry( displayWrapper );
286 wl_registry_add_listener( registry, ®istryListener, this );
289 wl_proxy_wrapper_destroy( displayWrapper );
293 // get auxiliary hint
294 Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEcoreWindow );
300 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) ) ) )
302 mSupportedAuxiliaryHints.push_back( hint );
304 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint );
309 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event )
311 Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
312 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
314 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) )
316 if( iconifyChangedEvent->iconified == EINA_TRUE )
318 mWindow->OnIconifyChanged( true );
322 mWindow->OnIconifyChanged( false );
324 handled = ECORE_CALLBACK_DONE;
330 Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event )
332 Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
334 if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
336 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
338 mWindow->OnFocusChanged( true );
341 return ECORE_CALLBACK_PASS_ON;
344 Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event )
346 Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
348 if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
350 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
352 mWindow->OnFocusChanged( false );
355 return ECORE_CALLBACK_PASS_ON;
358 Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event )
360 Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) );
362 if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) )
364 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
366 mWindowSurface->OutputTransformed();
368 mWindow->OnOutputTransformed();
371 return ECORE_CALLBACK_PASS_ON;
374 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event )
376 Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) );
378 if( ignoreTransformEvent->win == mEcoreWindow )
380 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
382 mWindowSurface->OutputTransformed();
384 mWindow->OnOutputTransformed();
387 return ECORE_CALLBACK_PASS_ON;
390 void WindowBaseEcoreWl::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
392 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
394 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
396 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
399 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
403 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
405 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
407 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
409 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
410 if( !mTizenDisplayPolicy )
412 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
416 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
418 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
422 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
425 mTizenDisplayPolicy = NULL;
428 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
430 mNotificationLevel = level;
431 mNotificationChangeState = state;
432 mNotificationLevelChangeDone = true;
434 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
437 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
439 mScreenOffMode = mode;
440 mScreenOffModeChangeState = state;
441 mScreenOffModeChangeDone = true;
443 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
446 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
448 mBrightness = brightness;
449 mBrightnessChangeState = state;
450 mBrightnessChangeDone = true;
452 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
455 void WindowBaseEcoreWl::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
457 DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
459 if( visibleMode == Dali::Window::VISIBLE )
461 // when the indicator is visible, set proper mode for indicator server according to bg mode
462 if( opacityMode == Dali::Window::OPAQUE )
464 ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_OPAQUE );
466 else if( opacityMode == Dali::Window::TRANSLUCENT )
468 ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_TRANSLUCENT );
470 else if( opacityMode == Dali::Window::TRANSPARENT )
472 ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_OPAQUE );
477 // when the indicator is not visible, set TRANSPARENT mode for indicator server
478 ecore_wl_window_indicator_opacity_set( mEcoreWindow, ECORE_WL_INDICATOR_TRANSPARENT); // it means hidden indicator
482 void WindowBaseEcoreWl::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
486 ecore_wl_window_indicator_state_set( mEcoreWindow, ECORE_WL_INDICATOR_STATE_ON );
490 ecore_wl_window_indicator_state_set( mEcoreWindow, ECORE_WL_INDICATOR_STATE_OFF );
494 void WindowBaseEcoreWl::IndicatorTypeChanged( IndicatorInterface::Type type )
496 #if defined(DALI_PROFILE_MOBILE)
499 case IndicatorInterface::INDICATOR_TYPE_1:
501 ecore_wl_indicator_visible_type_set( mEcoreWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN );
504 case IndicatorInterface::INDICATOR_TYPE_2:
506 ecore_wl_indicator_visible_type_set( mEcoreWindow, ECORE_WL_INDICATOR_VISIBLE_TYPE_HIDDEN );
509 case IndicatorInterface::INDICATOR_TYPE_UNKNOWN:
518 void WindowBaseEcoreWl::SetClass( std::string name, std::string className )
520 ecore_wl_window_title_set( mEcoreWindow, name.c_str() );
521 ecore_wl_window_class_name_set( mEcoreWindow, className.c_str() );
524 void WindowBaseEcoreWl::Raise()
526 // Use ecore_wl_window_activate to prevent the window shown without rendering
527 ecore_wl_window_activate( mEcoreWindow );
530 void WindowBaseEcoreWl::Lower()
532 ecore_wl_window_lower( mEcoreWindow );
535 void WindowBaseEcoreWl::Activate()
537 ecore_wl_window_activate( mEcoreWindow );
540 void WindowBaseEcoreWl::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
542 int rotations[4] = { 0 };
543 for( std::size_t i = 0; i < orientations.size(); ++i )
545 rotations[i] = static_cast< int >( orientations[i] );
547 ecore_wl_window_rotation_available_rotations_set( mEcoreWindow, rotations, orientations.size() );
550 void WindowBaseEcoreWl::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
552 ecore_wl_window_rotation_preferred_rotation_set( mEcoreWindow, orientation );
555 void WindowBaseEcoreWl::SetAcceptFocus( bool accept )
557 ecore_wl_window_focus_skip_set( mEcoreWindow, !accept );
560 void WindowBaseEcoreWl::Show()
562 ecore_wl_window_show( mEcoreWindow );
565 void WindowBaseEcoreWl::Hide()
567 ecore_wl_window_hide( mEcoreWindow );
570 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
572 return mSupportedAuxiliaryHints.size();
575 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint( unsigned int index ) const
577 if( index >= GetSupportedAuxiliaryHintCount() )
579 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
582 return mSupportedAuxiliaryHints[index];
585 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint( const std::string& hint, const std::string& value )
587 bool supported = false;
589 // Check if the hint is suppported
590 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
601 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
605 // Check if the hint is already added
606 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
608 if( mAuxiliaryHints[i].first == hint )
610 // Just change the value
611 mAuxiliaryHints[i].second = value;
613 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
615 return i + 1; // id is index + 1
620 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
622 unsigned int id = mAuxiliaryHints.size();
624 ecore_wl_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
626 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
631 bool WindowBaseEcoreWl::RemoveAuxiliaryHint( unsigned int id )
633 if( id == 0 || id > mAuxiliaryHints.size() )
635 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
639 mAuxiliaryHints[id - 1].second = std::string();
641 ecore_wl_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
643 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
648 bool WindowBaseEcoreWl::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
650 if( id == 0 || id > mAuxiliaryHints.size() )
652 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
656 mAuxiliaryHints[id - 1].second = value;
658 ecore_wl_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
660 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() );
665 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue( unsigned int id ) const
667 if( id == 0 || id > mAuxiliaryHints.size() )
669 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
670 return std::string();
673 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() );
675 return mAuxiliaryHints[id - 1].second;
678 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId( const std::string& hint ) const
680 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
682 if( mAuxiliaryHints[i].first == hint )
684 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
689 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
694 void WindowBaseEcoreWl::SetInputRegion( const Rect< int >& inputRegion )
696 ecore_wl_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
699 void WindowBaseEcoreWl::SetType( Dali::Window::Type type )
701 Ecore_Wl_Window_Type windowType;
705 case Dali::Window::NORMAL:
707 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
710 case Dali::Window::NOTIFICATION:
712 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
715 case Dali::Window::UTILITY:
717 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
720 case Dali::Window::DIALOG:
722 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
727 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
732 ecore_wl_window_type_set( mEcoreWindow, windowType );
735 bool WindowBaseEcoreWl::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
737 while( !mTizenPolicy )
739 wl_display_dispatch_queue( mDisplay, mEventQueue );
742 int notificationLevel;
746 case Dali::Window::NotificationLevel::NONE:
748 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
751 case Dali::Window::NotificationLevel::BASE:
753 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
756 case Dali::Window::NotificationLevel::MEDIUM:
758 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
761 case Dali::Window::NotificationLevel::HIGH:
763 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
766 case Dali::Window::NotificationLevel::TOP:
768 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
773 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level );
774 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
779 mNotificationLevelChangeDone = false;
780 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
782 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), notificationLevel );
786 while( !mNotificationLevelChangeDone && count < 3 )
789 wl_display_dispatch_queue( mDisplay, mEventQueue );
793 if( !mNotificationLevelChangeDone )
795 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
798 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
800 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level );
804 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
809 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl::GetNotificationLevel() const
811 while( !mTizenPolicy )
813 wl_display_dispatch_queue( mDisplay, mEventQueue );
818 while( !mNotificationLevelChangeDone && count < 3 )
821 wl_display_dispatch_queue( mDisplay, mEventQueue );
825 if( !mNotificationLevelChangeDone )
827 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
828 return Dali::Window::NotificationLevel::NONE;
831 Dali::Window::NotificationLevel::Type level;
833 switch( mNotificationLevel )
835 case TIZEN_POLICY_LEVEL_NONE:
837 level = Dali::Window::NotificationLevel::NONE;
840 case TIZEN_POLICY_LEVEL_DEFAULT:
842 level = Dali::Window::NotificationLevel::BASE;
845 case TIZEN_POLICY_LEVEL_MEDIUM:
847 level = Dali::Window::NotificationLevel::MEDIUM;
850 case TIZEN_POLICY_LEVEL_HIGH:
852 level = Dali::Window::NotificationLevel::HIGH;
855 case TIZEN_POLICY_LEVEL_TOP:
857 level = Dali::Window::NotificationLevel::TOP;
862 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
863 level = Dali::Window::NotificationLevel::NONE;
868 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel );
873 void WindowBaseEcoreWl::SetOpaqueState( bool opaque )
875 while( !mTizenPolicy )
877 wl_display_dispatch_queue( mDisplay, mEventQueue );
880 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
883 bool WindowBaseEcoreWl::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
885 while( !mTizenPolicy )
887 wl_display_dispatch_queue( mDisplay, mEventQueue );
890 mScreenOffModeChangeDone = false;
891 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
893 unsigned int mode = 0;
895 switch( screenOffMode )
897 case Dali::Window::ScreenOffMode::TIMEOUT:
902 case Dali::Window::ScreenOffMode::NEVER:
909 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), mode );
913 while( !mScreenOffModeChangeDone && count < 3 )
916 wl_display_dispatch_queue( mDisplay, mEventQueue );
920 if( !mScreenOffModeChangeDone )
922 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
925 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
927 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
931 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
936 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl::GetScreenOffMode() const
938 while( !mTizenPolicy )
940 wl_display_dispatch_queue( mDisplay, mEventQueue );
945 while( !mScreenOffModeChangeDone && count < 3 )
948 wl_display_dispatch_queue( mDisplay, mEventQueue );
952 if( !mScreenOffModeChangeDone )
954 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
955 return Dali::Window::ScreenOffMode::TIMEOUT;
958 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
960 switch( mScreenOffMode )
964 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
969 screenMode = Dali::Window::ScreenOffMode::NEVER;
974 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
979 bool WindowBaseEcoreWl::SetBrightness( int brightness )
981 while( !mTizenDisplayPolicy )
983 wl_display_dispatch_queue( mDisplay, mEventQueue );
986 mBrightnessChangeDone = false;
987 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
989 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl_window_surface_get( mEcoreWindow ), brightness );
993 while( !mBrightnessChangeDone && count < 3 )
996 wl_display_dispatch_queue( mDisplay, mEventQueue );
1000 if( !mBrightnessChangeDone )
1002 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
1005 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1007 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness );
1011 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness );
1016 int WindowBaseEcoreWl::GetBrightness() const
1018 while( !mTizenDisplayPolicy )
1020 wl_display_dispatch_queue( mDisplay, mEventQueue );
1025 while( !mBrightnessChangeDone && count < 3 )
1028 wl_display_dispatch_queue( mDisplay, mEventQueue );
1032 if( !mBrightnessChangeDone )
1034 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
1038 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness );
1043 bool WindowBaseEcoreWl::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
1045 Ecore_Wl_Window_Keygrab_Mode mode;
1049 case KeyGrab::TOPMOST:
1051 mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1054 case KeyGrab::SHARED:
1056 mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1059 case KeyGrab::OVERRIDE_EXCLUSIVE:
1061 mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1064 case KeyGrab::EXCLUSIVE:
1066 mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1075 return ecore_wl_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
1078 bool WindowBaseEcoreWl::UngrabKey( Dali::KEY key )
1080 return ecore_wl_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
1083 bool WindowBaseEcoreWl::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
1085 int keyCount = key.Count();
1086 int keyGrabModeCount = grabMode.Count();
1088 if( keyCount != keyGrabModeCount || keyCount == 0 )
1095 Eina_List* keyList = NULL;
1096 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1098 for( int index = 0; index < keyCount; ++index )
1100 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1102 switch( grabMode[index] )
1104 case KeyGrab::TOPMOST:
1106 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1109 case KeyGrab::SHARED:
1111 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1114 case KeyGrab::OVERRIDE_EXCLUSIVE:
1116 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1119 case KeyGrab::EXCLUSIVE:
1121 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1126 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1131 keyList = eina_list_append( keyList, &info );
1134 Eina_List* grabList = ecore_wl_window_keygrab_list_set( mEcoreWindow, keyList );
1136 result.Resize( keyCount, true );
1138 Eina_List* l = NULL;
1139 Eina_List* m = NULL;
1140 void* listData = NULL;
1142 if( grabList != NULL )
1144 EINA_LIST_FOREACH( grabList, m, data )
1147 EINA_LIST_FOREACH( keyList, l, listData )
1149 if( static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key == NULL )
1151 DALI_LOG_ERROR( "input key list has null data!" );
1155 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
1157 result[index] = false;
1166 eina_list_free( keyList );
1167 eina_list_free( grabList );
1173 bool WindowBaseEcoreWl::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
1175 int keyCount = key.Count();
1183 Eina_List* keyList = NULL;
1184 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1186 for( int index = 0; index < keyCount; ++index )
1188 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1189 keyList = eina_list_append( keyList, &info );
1192 Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset( mEcoreWindow, keyList );
1194 result.Resize( keyCount, true );
1196 Eina_List* l = NULL;
1197 Eina_List* m = NULL;
1198 void *listData = NULL;
1201 if( ungrabList != NULL )
1203 EINA_LIST_FOREACH( ungrabList, m, data )
1206 EINA_LIST_FOREACH( keyList, l, listData )
1208 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
1210 result[index] = false;
1219 eina_list_free( keyList );
1220 eina_list_free( ungrabList );
1226 } // namespace Adaptor
1228 } // namespace Internal
1232 #pragma GCC diagnostic pop