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-wl2/window-base-ecore-wl2.h>
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-render-surface-ecore-wl2.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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
117 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
121 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
123 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( 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 WindowBaseEcoreWl2::WindowBaseEcoreWl2( 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< WindowRenderSurfaceEcoreWl2* >( windowRenderSurface );
240 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
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 WindowBaseEcoreWl2::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_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
268 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
269 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
270 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this) );
271 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this) );
273 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
274 mDisplay = ecore_wl2_display_get( display );
278 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
281 mEventQueue = wl_display_create_queue( mDisplay );
284 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
286 wl_registry* registry = wl_display_get_registry( displayWrapper );
287 wl_registry_add_listener( registry, ®istryListener, this );
290 wl_proxy_wrapper_destroy( displayWrapper );
294 // get auxiliary hint
295 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
301 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) ) ) )
303 mSupportedAuxiliaryHints.push_back( hint );
305 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
310 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
312 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
313 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
315 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
317 if( iconifyChangedEvent->iconified == EINA_TRUE )
319 mWindow->OnIconifyChanged( true );
323 mWindow->OnIconifyChanged( false );
325 handled = ECORE_CALLBACK_DONE;
331 Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
333 Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
335 if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
337 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
339 mWindow->OnFocusChanged( true );
342 return ECORE_CALLBACK_PASS_ON;
345 Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
347 Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
349 if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
351 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
353 mWindow->OnFocusChanged( false );
356 return ECORE_CALLBACK_PASS_ON;
359 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
361 Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
363 if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
365 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
367 mWindowSurface->OutputTransformed();
369 mWindow->OnOutputTransformed();
372 return ECORE_CALLBACK_PASS_ON;
375 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
377 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
379 if( ignoreTransformEvent->win == mEcoreWindow )
381 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
383 mWindowSurface->OutputTransformed();
385 mWindow->OnOutputTransformed();
388 return ECORE_CALLBACK_PASS_ON;
391 void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
393 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
395 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
397 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
400 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
404 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
406 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
408 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
410 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
411 if( !mTizenDisplayPolicy )
413 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
417 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
419 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
423 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
426 mTizenDisplayPolicy = NULL;
429 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
431 mNotificationLevel = level;
432 mNotificationChangeState = state;
433 mNotificationLevelChangeDone = true;
435 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
438 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
440 mScreenOffMode = mode;
441 mScreenOffModeChangeState = state;
442 mScreenOffModeChangeDone = true;
444 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
447 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
449 mBrightness = brightness;
450 mBrightnessChangeState = state;
451 mBrightnessChangeDone = true;
453 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
456 void WindowBaseEcoreWl2::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
458 DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
460 if( visibleMode == Dali::Window::VISIBLE )
462 // when the indicator is visible, set proper mode for indicator server according to bg mode
463 if( opacityMode == Dali::Window::OPAQUE )
465 ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_OPAQUE );
467 else if( opacityMode == Dali::Window::TRANSLUCENT )
469 ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_TRANSLUCENT );
471 else if( opacityMode == Dali::Window::TRANSPARENT )
473 ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_OPAQUE );
478 // when the indicator is not visible, set TRANSPARENT mode for indicator server
479 ecore_wl2_window_indicator_opacity_set( mEcoreWindow, ECORE_WL2_INDICATOR_TRANSPARENT); // it means hidden indicator
483 void WindowBaseEcoreWl2::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
487 ecore_wl2_window_indicator_state_set( mEcoreWindow, ECORE_WL2_INDICATOR_STATE_ON );
491 ecore_wl2_window_indicator_state_set( mEcoreWindow, ECORE_WL2_INDICATOR_STATE_OFF );
495 void WindowBaseEcoreWl2::IndicatorTypeChanged( IndicatorInterface::Type type )
497 #if defined(DALI_PROFILE_MOBILE)
500 case IndicatorInterface::INDICATOR_TYPE_1:
502 ecore_wl2_indicator_visible_type_set( mEcoreWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN );
505 case IndicatorInterface::INDICATOR_TYPE_2:
507 ecore_wl2_indicator_visible_type_set( mEcoreWindow, ECORE_WL2_INDICATOR_VISIBLE_TYPE_HIDDEN );
510 case IndicatorInterface::INDICATOR_TYPE_UNKNOWN:
519 void WindowBaseEcoreWl2::SetClass( std::string name, std::string className )
521 ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
522 ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
525 void WindowBaseEcoreWl2::Raise()
527 // Use ecore_wl2_window_activate to prevent the window shown without rendering
528 ecore_wl2_window_activate( mEcoreWindow );
531 void WindowBaseEcoreWl2::Lower()
533 ecore_wl2_window_lower( mEcoreWindow );
536 void WindowBaseEcoreWl2::Activate()
538 ecore_wl2_window_activate( mEcoreWindow );
541 void WindowBaseEcoreWl2::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
543 int rotations[4] = { 0 };
544 for( std::size_t i = 0; i < orientations.size(); ++i )
546 rotations[i] = static_cast< int >( orientations[i] );
548 ecore_wl2_window_available_rotations_set( mEcoreWindow, rotations, orientations.size() );
551 void WindowBaseEcoreWl2::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
553 ecore_wl2_window_preferred_rotation_set( mEcoreWindow, orientation );
556 void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
558 ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
561 void WindowBaseEcoreWl2::Show()
563 ecore_wl2_window_show( mEcoreWindow );
566 void WindowBaseEcoreWl2::Hide()
568 ecore_wl2_window_hide( mEcoreWindow );
571 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
573 return mSupportedAuxiliaryHints.size();
576 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
578 if( index >= GetSupportedAuxiliaryHintCount() )
580 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
583 return mSupportedAuxiliaryHints[index];
586 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
588 bool supported = false;
590 // Check if the hint is suppported
591 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
602 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
606 // Check if the hint is already added
607 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
609 if( mAuxiliaryHints[i].first == hint )
611 // Just change the value
612 mAuxiliaryHints[i].second = value;
614 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
616 return i + 1; // id is index + 1
621 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
623 unsigned int id = mAuxiliaryHints.size();
625 ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
627 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
632 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
634 if( id == 0 || id > mAuxiliaryHints.size() )
636 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
640 mAuxiliaryHints[id - 1].second = std::string();
642 ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
644 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
649 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
651 if( id == 0 || id > mAuxiliaryHints.size() )
653 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
657 mAuxiliaryHints[id - 1].second = value;
659 ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
661 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
666 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
668 if( id == 0 || id > mAuxiliaryHints.size() )
670 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
671 return std::string();
674 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
676 return mAuxiliaryHints[id - 1].second;
679 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
681 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
683 if( mAuxiliaryHints[i].first == hint )
685 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
690 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
695 void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
697 ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
700 void WindowBaseEcoreWl2::SetType( Dali::Window::Type type )
702 Ecore_Wl2_Window_Type windowType;
706 case Dali::Window::NORMAL:
708 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
711 case Dali::Window::NOTIFICATION:
713 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
716 case Dali::Window::UTILITY:
718 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
721 case Dali::Window::DIALOG:
723 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
728 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
733 ecore_wl2_window_type_set( mEcoreWindow, windowType );
736 bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
738 while( !mTizenPolicy )
740 wl_display_dispatch_queue( mDisplay, mEventQueue );
743 int notificationLevel;
747 case Dali::Window::NotificationLevel::NONE:
749 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
752 case Dali::Window::NotificationLevel::BASE:
754 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
757 case Dali::Window::NotificationLevel::MEDIUM:
759 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
762 case Dali::Window::NotificationLevel::HIGH:
764 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
767 case Dali::Window::NotificationLevel::TOP:
769 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
774 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
775 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
780 mNotificationLevelChangeDone = false;
781 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
783 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
787 while( !mNotificationLevelChangeDone && count < 3 )
789 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
790 wl_display_dispatch_queue( mDisplay, mEventQueue );
794 if( !mNotificationLevelChangeDone )
796 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
799 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
801 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
805 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
810 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl2::GetNotificationLevel() const
812 while( !mTizenPolicy )
814 wl_display_dispatch_queue( mDisplay, mEventQueue );
819 while( !mNotificationLevelChangeDone && count < 3 )
821 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
822 wl_display_dispatch_queue( mDisplay, mEventQueue );
826 if( !mNotificationLevelChangeDone )
828 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
829 return Dali::Window::NotificationLevel::NONE;
832 Dali::Window::NotificationLevel::Type level;
834 switch( mNotificationLevel )
836 case TIZEN_POLICY_LEVEL_NONE:
838 level = Dali::Window::NotificationLevel::NONE;
841 case TIZEN_POLICY_LEVEL_DEFAULT:
843 level = Dali::Window::NotificationLevel::BASE;
846 case TIZEN_POLICY_LEVEL_MEDIUM:
848 level = Dali::Window::NotificationLevel::MEDIUM;
851 case TIZEN_POLICY_LEVEL_HIGH:
853 level = Dali::Window::NotificationLevel::HIGH;
856 case TIZEN_POLICY_LEVEL_TOP:
858 level = Dali::Window::NotificationLevel::TOP;
863 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
864 level = Dali::Window::NotificationLevel::NONE;
869 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
874 void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
876 while( !mTizenPolicy )
878 wl_display_dispatch_queue( mDisplay, mEventQueue );
881 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
884 bool WindowBaseEcoreWl2::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
886 while( !mTizenPolicy )
888 wl_display_dispatch_queue( mDisplay, mEventQueue );
891 mScreenOffModeChangeDone = false;
892 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
894 unsigned int mode = 0;
896 switch( screenOffMode )
898 case Dali::Window::ScreenOffMode::TIMEOUT:
903 case Dali::Window::ScreenOffMode::NEVER:
910 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
914 while( !mScreenOffModeChangeDone && count < 3 )
916 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
917 wl_display_dispatch_queue( mDisplay, mEventQueue );
921 if( !mScreenOffModeChangeDone )
923 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
926 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
928 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
932 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
937 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl2::GetScreenOffMode() const
939 while( !mTizenPolicy )
941 wl_display_dispatch_queue( mDisplay, mEventQueue );
946 while( !mScreenOffModeChangeDone && count < 3 )
948 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
949 wl_display_dispatch_queue( mDisplay, mEventQueue );
953 if( !mScreenOffModeChangeDone )
955 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
956 return Dali::Window::ScreenOffMode::TIMEOUT;
959 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
961 switch( mScreenOffMode )
965 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
970 screenMode = Dali::Window::ScreenOffMode::NEVER;
975 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
980 bool WindowBaseEcoreWl2::SetBrightness( int brightness )
982 while( !mTizenDisplayPolicy )
984 wl_display_dispatch_queue( mDisplay, mEventQueue );
987 mBrightnessChangeDone = false;
988 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
990 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
994 while( !mBrightnessChangeDone && count < 3 )
996 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
997 wl_display_dispatch_queue( mDisplay, mEventQueue );
1001 if( !mBrightnessChangeDone )
1003 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
1006 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1008 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
1012 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
1017 int WindowBaseEcoreWl2::GetBrightness() const
1019 while( !mTizenDisplayPolicy )
1021 wl_display_dispatch_queue( mDisplay, mEventQueue );
1026 while( !mBrightnessChangeDone && count < 3 )
1028 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1029 wl_display_dispatch_queue( mDisplay, mEventQueue );
1033 if( !mBrightnessChangeDone )
1035 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
1039 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
1044 bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
1046 Ecore_Wl2_Window_Keygrab_Mode mode;
1050 case KeyGrab::TOPMOST:
1052 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
1055 case KeyGrab::SHARED:
1057 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
1060 case KeyGrab::OVERRIDE_EXCLUSIVE:
1062 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1065 case KeyGrab::EXCLUSIVE:
1067 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
1076 return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
1079 bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
1081 return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
1084 bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
1086 int keyCount = key.Count();
1087 int keyGrabModeCount = grabMode.Count();
1089 if( keyCount != keyGrabModeCount || keyCount == 0 )
1096 Eina_List* keyList = NULL;
1097 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
1099 for( int index = 0; index < keyCount; ++index )
1101 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1103 switch( grabMode[index] )
1105 case KeyGrab::TOPMOST:
1107 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
1110 case KeyGrab::SHARED:
1112 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
1115 case KeyGrab::OVERRIDE_EXCLUSIVE:
1117 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1120 case KeyGrab::EXCLUSIVE:
1122 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
1127 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
1132 keyList = eina_list_append( keyList, &info );
1135 Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
1137 result.Resize( keyCount, true );
1139 Eina_List* l = NULL;
1140 Eina_List* m = NULL;
1141 void* listData = NULL;
1143 if( grabList != NULL )
1145 EINA_LIST_FOREACH( grabList, m, data )
1148 EINA_LIST_FOREACH( keyList, l, listData )
1150 if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
1152 DALI_LOG_ERROR( "input key list has null data!" );
1156 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
1158 result[index] = false;
1167 eina_list_free( keyList );
1168 eina_list_free( grabList );
1174 bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
1176 int keyCount = key.Count();
1184 Eina_List* keyList = NULL;
1185 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
1187 for( int index = 0; index < keyCount; ++index )
1189 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1190 keyList = eina_list_append( keyList, &info );
1193 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
1195 result.Resize( keyCount, true );
1197 Eina_List* l = NULL;
1198 Eina_List* m = NULL;
1199 void *listData = NULL;
1202 if( ungrabList != NULL )
1204 EINA_LIST_FOREACH( ungrabList, m, data )
1207 EINA_LIST_FOREACH( keyList, l, listData )
1209 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
1211 result[index] = false;
1220 eina_list_free( keyList );
1221 eina_list_free( ungrabList );
1227 } // namespace Adaptor
1229 } // namespace Internal
1233 #pragma GCC diagnostic pop