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/common/window-system.h>
28 #include <dali/internal/window-system/common/window-render-surface.h>
29 #include <dali/internal/input/common/key-impl.h>
32 #include <dali/public-api/object/any.h>
33 #include <dali/integration-api/debug.h>
34 #include <Ecore_Input.h>
36 #include <vconf-keys.h>
50 #if defined(DEBUG_ENABLED)
51 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
54 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
55 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
57 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
60 const char* BUS = "org.enlightenment.wm-screen-reader";
61 const char* INTERFACE = "org.tizen.GestureNavigation";
62 const char* PATH = "/org/tizen/GestureNavigation";
65 * Get the device name from the provided ecore key event
67 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
69 const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
73 result = ecoreDeviceName;
78 * Get the device class from the provided ecore event
80 void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
82 switch( ecoreDeviceClass )
84 case ECORE_DEVICE_CLASS_SEAT:
86 deviceClass = Device::Class::USER;
89 case ECORE_DEVICE_CLASS_KEYBOARD:
91 deviceClass = Device::Class::KEYBOARD;
94 case ECORE_DEVICE_CLASS_MOUSE:
96 deviceClass = Device::Class::MOUSE;
99 case ECORE_DEVICE_CLASS_TOUCH:
101 deviceClass = Device::Class::TOUCH;
104 case ECORE_DEVICE_CLASS_PEN:
106 deviceClass = Device::Class::PEN;
109 case ECORE_DEVICE_CLASS_POINTER:
111 deviceClass = Device::Class::POINTER;
114 case ECORE_DEVICE_CLASS_GAMEPAD:
116 deviceClass = Device::Class::GAMEPAD;
121 deviceClass = Device::Class::NONE;
127 void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
129 switch( ecoreDeviceSubclass )
131 case ECORE_DEVICE_SUBCLASS_FINGER:
133 deviceSubclass = Device::Subclass::FINGER;
136 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
138 deviceSubclass = Device::Subclass::FINGERNAIL;
141 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
143 deviceSubclass = Device::Subclass::KNUCKLE;
146 case ECORE_DEVICE_SUBCLASS_PALM:
148 deviceSubclass = Device::Subclass::PALM;
151 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
153 deviceSubclass = Device::Subclass::HAND_SIDE;
156 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
158 deviceSubclass = Device::Subclass::HAND_FLAT;
161 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
163 deviceSubclass = Device::Subclass::PEN_TIP;
166 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
168 deviceSubclass = Device::Subclass::TRACKPAD;
171 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
173 deviceSubclass = Device::Subclass::TRACKPOINT;
176 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
178 deviceSubclass = Device::Subclass::TRACKBALL;
181 #ifdef OVER_TIZEN_VERSION_4
182 case ECORE_DEVICE_SUBCLASS_REMOCON:
184 deviceSubclass = Device::Subclass::REMOCON;
187 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
189 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
195 deviceSubclass = Device::Subclass::NONE;
201 /////////////////////////////////////////////////////////////////////////////////////////////////
203 /////////////////////////////////////////////////////////////////////////////////////////////////
205 /// Called when the window iconify state is changed.
206 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
208 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
211 return windowBase->OnIconifyStateChanged( data, type, event );
214 return ECORE_CALLBACK_PASS_ON;
217 /// Called when the window gains focus
218 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
220 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
223 return windowBase->OnFocusIn( data, type, event );
226 return ECORE_CALLBACK_PASS_ON;
229 /// Called when the window loses focus
230 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
232 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
235 return windowBase->OnFocusOut( data, type, event );
238 return ECORE_CALLBACK_PASS_ON;
241 /// Called when the output is transformed
242 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
244 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
247 return windowBase->OnOutputTransform( data, type, event );
250 return ECORE_CALLBACK_PASS_ON;
253 /// Called when the output transform should be ignored
254 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
256 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
259 return windowBase->OnIgnoreOutputTransform( data, type, event );
262 return ECORE_CALLBACK_PASS_ON;
266 * Called when rotate event is recevied.
268 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
270 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
273 windowBase->OnRotation( data, type, event );
275 return ECORE_CALLBACK_PASS_ON;
278 /////////////////////////////////////////////////////////////////////////////////////////////////
280 /////////////////////////////////////////////////////////////////////////////////////////////////
283 * Called when a touch down is received.
285 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
287 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
290 windowBase->OnMouseButtonDown( data, type, event );
292 return ECORE_CALLBACK_PASS_ON;
296 * Called when a touch up is received.
298 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
300 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
303 windowBase->OnMouseButtonUp( data, type, event );
305 return ECORE_CALLBACK_PASS_ON;
309 * Called when a touch motion is received.
311 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
313 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
316 windowBase->OnMouseButtonMove( data, type, event );
318 return ECORE_CALLBACK_PASS_ON;
322 * Called when a touch is canceled.
324 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
326 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
329 windowBase->OnMouseButtonCancel( data, type, event );
331 return ECORE_CALLBACK_PASS_ON;
335 * Called when a mouse wheel is received.
337 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
339 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
342 windowBase->OnMouseWheel( data, type, event );
344 return ECORE_CALLBACK_PASS_ON;
348 * Called when a detent rotation event is recevied.
350 static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
352 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
355 windowBase->OnDetentRotation( data, type, event );
357 return ECORE_CALLBACK_PASS_ON;
360 /////////////////////////////////////////////////////////////////////////////////////////////////
362 /////////////////////////////////////////////////////////////////////////////////////////////////
365 * Called when a key down is received.
367 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
369 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
372 windowBase->OnKeyDown( data, type, event );
374 return ECORE_CALLBACK_PASS_ON;
378 * Called when a key up is received.
380 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
382 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
385 windowBase->OnKeyUp( data, type, event );
387 return ECORE_CALLBACK_PASS_ON;
390 /////////////////////////////////////////////////////////////////////////////////////////////////
391 // Selection Callbacks
392 /////////////////////////////////////////////////////////////////////////////////////////////////
395 * Called when the source window notifies us the content in clipboard is selected.
397 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
399 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
402 windowBase->OnDataSend( data, type, event );
404 return ECORE_CALLBACK_PASS_ON;
408 * Called when the source window sends us about the selected content.
409 * For example, when item is selected in the clipboard.
411 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
413 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
416 windowBase->OnDataReceive( data, type, event );
418 return ECORE_CALLBACK_PASS_ON;
421 /////////////////////////////////////////////////////////////////////////////////////////////////
423 /////////////////////////////////////////////////////////////////////////////////////////////////
426 * Called when a font name is changed.
428 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
430 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
433 windowBase->OnFontNameChanged();
438 * Called when a font size is changed.
440 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
442 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
445 windowBase->OnFontSizeChanged();
449 /////////////////////////////////////////////////////////////////////////////////////////////////
450 // ElDBus Accessibility Callbacks
451 /////////////////////////////////////////////////////////////////////////////////////////////////
453 #ifdef DALI_ELDBUS_AVAILABLE
454 // Callback for Ecore ElDBus accessibility events.
455 static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
457 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( context );
460 windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
463 #endif // DALI_ELDBUS_AVAILABLE
465 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
467 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
470 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
474 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
476 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
479 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
483 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
487 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 )
491 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
493 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
496 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
500 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
504 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
506 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
509 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
513 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
517 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
521 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
525 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
529 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 )
533 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
535 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
538 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
542 const struct wl_registry_listener registryListener =
544 RegistryGlobalCallback,
545 RegistryGlobalCallbackRemove
548 const struct tizen_policy_listener tizenPolicyListener =
550 TizenPolicyConformant,
551 TizenPolicyConformantArea,
552 TizenPolicyNotificationChangeDone,
553 TizenPolicyTransientForDone,
554 TizenPolicyScreenModeChangeDone,
555 TizenPolicyIconifyStateChanged,
556 TizenPolicySupportedAuxiliaryHints,
557 TizenPolicyAllowedAuxiliaryHint,
558 TizenPolicyAuxiliaryMessage,
559 TizenPolicyConformantRegion
562 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
564 DisplayPolicyBrightnessChangeDone
567 } // unnamed namespace
569 WindowBaseEcoreWl::WindowBaseEcoreWl( Dali::PositionSize positionSize, Any surface, bool isTransparent )
570 : mEcoreEventHandler(),
571 mEcoreWindow( NULL ),
576 mTizenPolicy( NULL ),
577 mTizenDisplayPolicy( NULL ),
578 mSupportedAuxiliaryHints(),
580 mNotificationLevel( -1 ),
581 mNotificationChangeState( 0 ),
582 mNotificationLevelChangeDone( true ),
584 mScreenOffModeChangeState( 0 ),
585 mScreenOffModeChangeDone( true ),
587 mBrightnessChangeState( 0 ),
588 mBrightnessChangeDone( true ),
590 #ifdef DALI_ELDBUS_AVAILABLE
591 , mSystemConnection( NULL )
594 Initialize( positionSize, surface, isTransparent );
597 WindowBaseEcoreWl::~WindowBaseEcoreWl()
599 #ifdef DALI_ELDBUS_AVAILABLE
600 // Close down ElDBus connections.
601 if( mSystemConnection )
603 eldbus_connection_unref( mSystemConnection );
605 #endif // DALI_ELDBUS_AVAILABLE
607 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
608 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
610 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
612 ecore_event_handler_del( *iter );
614 mEcoreEventHandler.Clear();
618 wl_event_queue_destroy( mEventQueue );
621 mSupportedAuxiliaryHints.clear();
622 mAuxiliaryHints.clear();
624 if( mEglWindow != NULL )
626 wl_egl_window_destroy( mEglWindow );
632 ecore_wl_window_free( mEcoreWindow );
634 WindowSystem::Shutdown();
638 void WindowBaseEcoreWl::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
640 if( surface.Empty() == false )
642 // check we have a valid type
643 DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl_Window *) ) && "Surface type is invalid" );
645 mEcoreWindow = AnyCast< Ecore_Wl_Window* >( surface );
649 // we own the surface about to created
650 WindowSystem::Initialize();
653 CreateWindow( positionSize );
656 mWlSurface = ecore_wl_window_surface_create( mEcoreWindow );
658 SetTransparency( isTransparent );
660 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
661 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
662 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
663 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
664 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
666 // Register Rotate event
667 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
669 // Register Touch events
670 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
671 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
672 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
673 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
675 // Register Mouse wheel events
676 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
678 // Register Detent event
679 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
681 // Register Key events
682 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
683 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
685 // Register Selection event - clipboard selection
686 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
687 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
689 // Register Vconf notify - font name and size
690 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
691 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
693 InitializeEcoreElDBus();
695 mDisplay = ecore_wl_display_get();
699 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
702 mEventQueue = wl_display_create_queue( mDisplay );
705 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
707 wl_registry* registry = wl_display_get_registry( displayWrapper );
708 wl_registry_add_listener( registry, ®istryListener, this );
711 wl_proxy_wrapper_destroy( displayWrapper );
715 // get auxiliary hint
716 Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEcoreWindow );
722 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) ) ) )
724 mSupportedAuxiliaryHints.push_back( hint );
726 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint );
731 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event )
733 Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
734 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
736 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) )
738 if( iconifyChangedEvent->iconified == EINA_TRUE )
740 mIconifyChangedSignal.Emit( true );
744 mIconifyChangedSignal.Emit( false );
746 handled = ECORE_CALLBACK_DONE;
752 Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event )
754 Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
756 if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
758 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
760 mFocusChangedSignal.Emit( true );
763 return ECORE_CALLBACK_PASS_ON;
766 Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event )
768 Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
770 if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
772 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
774 mFocusChangedSignal.Emit( false );
777 return ECORE_CALLBACK_PASS_ON;
780 Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event )
782 Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) );
784 if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) )
786 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
788 mOutputTransformedSignal.Emit();
791 return ECORE_CALLBACK_PASS_ON;
794 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event )
796 Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) );
798 if( ignoreTransformEvent->win == mEcoreWindow )
800 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
802 mOutputTransformedSignal.Emit();
805 return ECORE_CALLBACK_PASS_ON;
808 void WindowBaseEcoreWl::OnRotation( void* data, int type, void* event )
810 Ecore_Wl_Event_Window_Rotate* ev( static_cast< Ecore_Wl_Event_Window_Rotate* >( event ) );
812 if( ev->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
814 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnRotation\n" );
816 RotationEvent rotationEvent;
817 rotationEvent.angle = ev->angle;
818 rotationEvent.winResize = 0;
820 if( ev->angle == 0 || ev->angle == 180 )
822 rotationEvent.width = ev->w;
823 rotationEvent.height = ev->h;
827 rotationEvent.width = ev->h;
828 rotationEvent.height = ev->w;
831 mRotationSignal.Emit( rotationEvent );
835 void WindowBaseEcoreWl::OnMouseButtonDown( void* data, int type, void* event )
837 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
839 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
841 PointState::Type state ( PointState::DOWN );
843 // Check if the buttons field is set and ensure it's the primary touch button.
844 // If this event was triggered by buttons other than the primary button (used for touch), then
845 // just send an interrupted event to Core.
846 if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
848 state = PointState::INTERRUPTED;
851 Device::Class::Type deviceClass;
852 Device::Subclass::Type deviceSubclass;
854 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
855 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
857 Integration::Point point;
858 point.SetDeviceId( touchEvent->multi.device );
859 point.SetState( state );
860 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
861 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
862 point.SetPressure( touchEvent->multi.pressure );
863 point.SetAngle( Degree( touchEvent->multi.angle ) );
864 point.SetDeviceClass( deviceClass );
865 point.SetDeviceSubclass( deviceSubclass );
867 mTouchEventSignal.Emit( point, touchEvent->timestamp );
871 void WindowBaseEcoreWl::OnMouseButtonUp( void* data, int type, void* event )
873 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
875 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
877 Device::Class::Type deviceClass;
878 Device::Subclass::Type deviceSubclass;
880 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
881 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
883 Integration::Point point;
884 point.SetDeviceId( touchEvent->multi.device );
885 point.SetState( PointState::UP );
886 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
887 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
888 point.SetPressure( touchEvent->multi.pressure );
889 point.SetAngle( Degree( touchEvent->multi.angle ) );
890 point.SetDeviceClass( deviceClass );
891 point.SetDeviceSubclass( deviceSubclass );
893 mTouchEventSignal.Emit( point, touchEvent->timestamp );
897 void WindowBaseEcoreWl::OnMouseButtonMove( void* data, int type, void* event )
899 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
901 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
903 Device::Class::Type deviceClass;
904 Device::Subclass::Type deviceSubclass;
906 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
907 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
909 Integration::Point point;
910 point.SetDeviceId( touchEvent->multi.device );
911 point.SetState( PointState::MOTION );
912 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
913 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
914 point.SetPressure( touchEvent->multi.pressure );
915 point.SetAngle( Degree( touchEvent->multi.angle ) );
916 point.SetDeviceClass( deviceClass );
917 point.SetDeviceSubclass( deviceSubclass );
919 mTouchEventSignal.Emit( point, touchEvent->timestamp );
923 void WindowBaseEcoreWl::OnMouseButtonCancel( void* data, int type, void* event )
925 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
927 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
929 Integration::Point point;
930 point.SetDeviceId( touchEvent->multi.device );
931 point.SetState( PointState::INTERRUPTED );
932 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
934 mTouchEventSignal.Emit( point, touchEvent->timestamp );
936 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" );
940 void WindowBaseEcoreWl::OnMouseWheel( void* data, int type, void* event )
942 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
944 if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
946 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
948 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
950 mWheelEventSignal.Emit( wheelEvent );
954 void WindowBaseEcoreWl::OnDetentRotation( void* data, int type, void* event )
956 Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
958 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" );
960 int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
961 int timeStamp = detentEvent->timestamp;
963 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2( 0.0f, 0.0f ), direction, timeStamp );
965 mWheelEventSignal.Emit( wheelEvent );
968 void WindowBaseEcoreWl::OnKeyDown( void* data, int type, void* event )
970 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
972 if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
974 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" );
976 std::string keyName( keyEvent->keyname );
977 std::string logicalKey( "" );
978 std::string keyString( "" );
979 std::string compose( "" );
981 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
982 if( keyEvent->compose )
984 compose = keyEvent->compose;
987 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
990 logicalKey = keyEvent->key;
993 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
994 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
995 int modifier( keyEvent->modifiers );
996 unsigned long time = keyEvent->timestamp;
997 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
999 keyCode = atoi( keyEvent->keyname + 8 );
1002 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1003 if( keyEvent->string )
1005 keyString = keyEvent->string;
1008 std::string deviceName;
1009 Device::Class::Type deviceClass;
1010 Device::Subclass::Type deviceSubclass;
1012 GetDeviceName( keyEvent, deviceName );
1013 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1014 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1016 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, deviceName, deviceClass, deviceSubclass );
1018 mKeyEventSignal.Emit( keyEvent );
1022 void WindowBaseEcoreWl::OnKeyUp( void* data, int type, void* event )
1024 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1026 if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
1028 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" );
1030 std::string keyName( keyEvent->keyname );
1031 std::string logicalKey( "" );
1032 std::string keyString( "" );
1033 std::string compose( "" );
1035 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1036 if( keyEvent->compose )
1038 compose = keyEvent->compose;
1041 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1044 logicalKey = keyEvent->key;
1047 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1048 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1049 int modifier( keyEvent->modifiers );
1050 unsigned long time = keyEvent->timestamp;
1051 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1053 keyCode = atoi( keyEvent->keyname + 8 );
1056 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1057 if( keyEvent->string )
1059 keyString = keyEvent->string;
1062 std::string deviceName;
1063 Device::Class::Type deviceClass;
1064 Device::Subclass::Type deviceSubclass;
1066 GetDeviceName( keyEvent, deviceName );
1067 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1068 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1070 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, deviceName, deviceClass, deviceSubclass );
1072 mKeyEventSignal.Emit( keyEvent );
1076 void WindowBaseEcoreWl::OnDataSend( void* data, int type, void* event )
1078 mSelectionDataSendSignal.Emit( event );
1081 void WindowBaseEcoreWl::OnDataReceive( void* data, int type, void* event )
1083 mSelectionDataReceivedSignal.Emit( event );
1086 void WindowBaseEcoreWl::OnFontNameChanged()
1088 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1091 void WindowBaseEcoreWl::OnFontSizeChanged()
1093 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1096 void WindowBaseEcoreWl::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1098 #ifdef DALI_ELDBUS_AVAILABLE
1099 AccessibilityInfo info;
1101 // The string defines the arg-list's respective types.
1102 if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1104 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1107 mAccessibilitySignal.Emit( info );
1111 void WindowBaseEcoreWl::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1113 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1115 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1117 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1120 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1124 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1126 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1128 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1130 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1131 if( !mTizenDisplayPolicy )
1133 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1137 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1139 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1143 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1145 mTizenPolicy = NULL;
1146 mTizenDisplayPolicy = NULL;
1149 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1151 mNotificationLevel = level;
1152 mNotificationChangeState = state;
1153 mNotificationLevelChangeDone = true;
1155 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1158 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1160 mScreenOffMode = mode;
1161 mScreenOffModeChangeState = state;
1162 mScreenOffModeChangeDone = true;
1164 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1167 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1169 mBrightness = brightness;
1170 mBrightnessChangeState = state;
1171 mBrightnessChangeDone = true;
1173 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1176 Any WindowBaseEcoreWl::GetNativeWindow()
1178 return mEcoreWindow;
1181 int WindowBaseEcoreWl::GetNativeWindowId()
1183 return ecore_wl_window_id_get( mEcoreWindow );
1186 EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow( int width, int height )
1188 mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1190 return static_cast< EGLNativeWindowType >( mEglWindow );
1193 void WindowBaseEcoreWl::DestroyEglWindow()
1195 if( mEglWindow != NULL )
1197 wl_egl_window_destroy( mEglWindow );
1202 void WindowBaseEcoreWl::SetEglWindowRotation( int angle )
1204 wl_egl_window_rotation rotation;
1210 rotation = ROTATION_0;
1215 rotation = ROTATION_270;
1220 rotation = ROTATION_180;
1225 rotation = ROTATION_90;
1230 rotation = ROTATION_0;
1235 wl_egl_window_set_rotation( mEglWindow, rotation );
1238 void WindowBaseEcoreWl::SetEglWindowBufferTransform( int angle )
1240 wl_output_transform bufferTransform;
1246 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1251 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1256 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1261 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1266 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1271 wl_egl_window_set_buffer_transform( mEglWindow, bufferTransform );
1274 void WindowBaseEcoreWl::SetEglWindowTransform( int angle )
1276 wl_output_transform windowTransform;
1282 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1287 windowTransform = WL_OUTPUT_TRANSFORM_90;
1292 windowTransform = WL_OUTPUT_TRANSFORM_180;
1297 windowTransform = WL_OUTPUT_TRANSFORM_270;
1302 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1307 wl_egl_window_set_window_transform( mEglWindow, windowTransform );
1310 void WindowBaseEcoreWl::ResizeEglWindow( PositionSize positionSize )
1312 wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1315 bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
1318 wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) );
1319 if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED )
1327 void WindowBaseEcoreWl::Move( PositionSize positionSize )
1329 ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1332 void WindowBaseEcoreWl::Resize( PositionSize positionSize )
1334 ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
1337 void WindowBaseEcoreWl::MoveResize( PositionSize positionSize )
1339 ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1340 ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
1343 void WindowBaseEcoreWl::SetClass( const std::string& name, const std::string& className )
1345 ecore_wl_window_title_set( mEcoreWindow, name.c_str() );
1346 ecore_wl_window_class_name_set( mEcoreWindow, className.c_str() );
1349 void WindowBaseEcoreWl::Raise()
1351 // Use ecore_wl_window_activate to prevent the window shown without rendering
1352 ecore_wl_window_activate( mEcoreWindow );
1355 void WindowBaseEcoreWl::Lower()
1357 ecore_wl_window_lower( mEcoreWindow );
1360 void WindowBaseEcoreWl::Activate()
1362 ecore_wl_window_activate( mEcoreWindow );
1365 void WindowBaseEcoreWl::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
1367 int rotations[4] = { 0 };
1368 for( std::size_t i = 0; i < orientations.size(); ++i )
1370 rotations[i] = static_cast< int >( orientations[i] );
1372 ecore_wl_window_rotation_available_rotations_set( mEcoreWindow, rotations, orientations.size() );
1375 void WindowBaseEcoreWl::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
1377 ecore_wl_window_rotation_preferred_rotation_set( mEcoreWindow, orientation );
1380 void WindowBaseEcoreWl::SetAcceptFocus( bool accept )
1382 ecore_wl_window_focus_skip_set( mEcoreWindow, !accept );
1385 void WindowBaseEcoreWl::Show()
1387 ecore_wl_window_show( mEcoreWindow );
1390 void WindowBaseEcoreWl::Hide()
1392 ecore_wl_window_hide( mEcoreWindow );
1395 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
1397 return mSupportedAuxiliaryHints.size();
1400 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint( unsigned int index ) const
1402 if( index >= GetSupportedAuxiliaryHintCount() )
1404 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1407 return mSupportedAuxiliaryHints[index];
1410 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1412 bool supported = false;
1414 // Check if the hint is suppported
1415 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1426 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1430 // Check if the hint is already added
1431 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1433 if( mAuxiliaryHints[i].first == hint )
1435 // Just change the value
1436 mAuxiliaryHints[i].second = value;
1438 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1440 return i + 1; // id is index + 1
1445 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1447 unsigned int id = mAuxiliaryHints.size();
1449 ecore_wl_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1451 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1456 bool WindowBaseEcoreWl::RemoveAuxiliaryHint( unsigned int id )
1458 if( id == 0 || id > mAuxiliaryHints.size() )
1460 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1464 mAuxiliaryHints[id - 1].second = std::string();
1466 ecore_wl_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1468 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1473 bool WindowBaseEcoreWl::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1475 if( id == 0 || id > mAuxiliaryHints.size() )
1477 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1481 mAuxiliaryHints[id - 1].second = value;
1483 ecore_wl_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1485 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() );
1490 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue( unsigned int id ) const
1492 if( id == 0 || id > mAuxiliaryHints.size() )
1494 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1495 return std::string();
1498 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() );
1500 return mAuxiliaryHints[id - 1].second;
1503 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId( const std::string& hint ) const
1505 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1507 if( mAuxiliaryHints[i].first == hint )
1509 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1514 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1519 void WindowBaseEcoreWl::SetInputRegion( const Rect< int >& inputRegion )
1521 ecore_wl_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1524 void WindowBaseEcoreWl::SetType( Dali::Window::Type type )
1526 Ecore_Wl_Window_Type windowType;
1530 case Dali::Window::NORMAL:
1532 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1535 case Dali::Window::NOTIFICATION:
1537 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1540 case Dali::Window::UTILITY:
1542 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1545 case Dali::Window::DIALOG:
1547 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1552 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1557 ecore_wl_window_type_set( mEcoreWindow, windowType );
1560 bool WindowBaseEcoreWl::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
1562 while( !mTizenPolicy )
1564 wl_display_dispatch_queue( mDisplay, mEventQueue );
1567 int notificationLevel;
1571 case Dali::Window::NotificationLevel::NONE:
1573 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1576 case Dali::Window::NotificationLevel::BASE:
1578 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1581 case Dali::Window::NotificationLevel::MEDIUM:
1583 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1586 case Dali::Window::NotificationLevel::HIGH:
1588 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1591 case Dali::Window::NotificationLevel::TOP:
1593 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1598 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level );
1599 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1604 mNotificationLevelChangeDone = false;
1605 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1607 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), notificationLevel );
1611 while( !mNotificationLevelChangeDone && count < 3 )
1614 wl_display_dispatch_queue( mDisplay, mEventQueue );
1618 if( !mNotificationLevelChangeDone )
1620 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1623 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1625 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level );
1629 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1634 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl::GetNotificationLevel() const
1636 while( !mTizenPolicy )
1638 wl_display_dispatch_queue( mDisplay, mEventQueue );
1643 while( !mNotificationLevelChangeDone && count < 3 )
1646 wl_display_dispatch_queue( mDisplay, mEventQueue );
1650 if( !mNotificationLevelChangeDone )
1652 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1653 return Dali::Window::NotificationLevel::NONE;
1656 Dali::Window::NotificationLevel::Type level;
1658 switch( mNotificationLevel )
1660 case TIZEN_POLICY_LEVEL_NONE:
1662 level = Dali::Window::NotificationLevel::NONE;
1665 case TIZEN_POLICY_LEVEL_DEFAULT:
1667 level = Dali::Window::NotificationLevel::BASE;
1670 case TIZEN_POLICY_LEVEL_MEDIUM:
1672 level = Dali::Window::NotificationLevel::MEDIUM;
1675 case TIZEN_POLICY_LEVEL_HIGH:
1677 level = Dali::Window::NotificationLevel::HIGH;
1680 case TIZEN_POLICY_LEVEL_TOP:
1682 level = Dali::Window::NotificationLevel::TOP;
1687 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1688 level = Dali::Window::NotificationLevel::NONE;
1693 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1698 void WindowBaseEcoreWl::SetOpaqueState( bool opaque )
1700 while( !mTizenPolicy )
1702 wl_display_dispatch_queue( mDisplay, mEventQueue );
1705 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1708 bool WindowBaseEcoreWl::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
1710 while( !mTizenPolicy )
1712 wl_display_dispatch_queue( mDisplay, mEventQueue );
1715 mScreenOffModeChangeDone = false;
1716 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1718 unsigned int mode = 0;
1720 switch( screenOffMode )
1722 case Dali::Window::ScreenOffMode::TIMEOUT:
1727 case Dali::Window::ScreenOffMode::NEVER:
1734 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), mode );
1738 while( !mScreenOffModeChangeDone && count < 3 )
1741 wl_display_dispatch_queue( mDisplay, mEventQueue );
1745 if( !mScreenOffModeChangeDone )
1747 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
1750 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1752 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
1756 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
1761 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl::GetScreenOffMode() const
1763 while( !mTizenPolicy )
1765 wl_display_dispatch_queue( mDisplay, mEventQueue );
1770 while( !mScreenOffModeChangeDone && count < 3 )
1773 wl_display_dispatch_queue( mDisplay, mEventQueue );
1777 if( !mScreenOffModeChangeDone )
1779 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
1780 return Dali::Window::ScreenOffMode::TIMEOUT;
1783 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1785 switch( mScreenOffMode )
1789 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1794 screenMode = Dali::Window::ScreenOffMode::NEVER;
1799 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
1804 bool WindowBaseEcoreWl::SetBrightness( int brightness )
1806 while( !mTizenDisplayPolicy )
1808 wl_display_dispatch_queue( mDisplay, mEventQueue );
1811 mBrightnessChangeDone = false;
1812 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1814 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl_window_surface_get( mEcoreWindow ), brightness );
1818 while( !mBrightnessChangeDone && count < 3 )
1821 wl_display_dispatch_queue( mDisplay, mEventQueue );
1825 if( !mBrightnessChangeDone )
1827 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
1830 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1832 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness );
1836 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness );
1841 int WindowBaseEcoreWl::GetBrightness() const
1843 while( !mTizenDisplayPolicy )
1845 wl_display_dispatch_queue( mDisplay, mEventQueue );
1850 while( !mBrightnessChangeDone && count < 3 )
1853 wl_display_dispatch_queue( mDisplay, mEventQueue );
1857 if( !mBrightnessChangeDone )
1859 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
1863 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness );
1868 bool WindowBaseEcoreWl::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
1870 Ecore_Wl_Window_Keygrab_Mode mode;
1874 case KeyGrab::TOPMOST:
1876 mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1879 case KeyGrab::SHARED:
1881 mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1884 case KeyGrab::OVERRIDE_EXCLUSIVE:
1886 mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1889 case KeyGrab::EXCLUSIVE:
1891 mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1900 return ecore_wl_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
1903 bool WindowBaseEcoreWl::UngrabKey( Dali::KEY key )
1905 return ecore_wl_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
1908 bool WindowBaseEcoreWl::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
1910 int keyCount = key.Count();
1911 int keyGrabModeCount = grabMode.Count();
1913 if( keyCount != keyGrabModeCount || keyCount == 0 )
1920 Eina_List* keyList = NULL;
1921 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1923 for( int index = 0; index < keyCount; ++index )
1925 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1927 switch( grabMode[index] )
1929 case KeyGrab::TOPMOST:
1931 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1934 case KeyGrab::SHARED:
1936 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1939 case KeyGrab::OVERRIDE_EXCLUSIVE:
1941 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1944 case KeyGrab::EXCLUSIVE:
1946 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1951 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1956 keyList = eina_list_append( keyList, &info );
1959 Eina_List* grabList = ecore_wl_window_keygrab_list_set( mEcoreWindow, keyList );
1961 result.Resize( keyCount, true );
1963 Eina_List* l = NULL;
1964 Eina_List* m = NULL;
1965 void* listData = NULL;
1967 if( grabList != NULL )
1969 EINA_LIST_FOREACH( grabList, m, data )
1972 EINA_LIST_FOREACH( keyList, l, listData )
1974 if( static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key == NULL )
1976 DALI_LOG_ERROR( "input key list has null data!" );
1980 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
1982 result[index] = false;
1991 eina_list_free( keyList );
1992 eina_list_free( grabList );
1998 bool WindowBaseEcoreWl::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2000 int keyCount = key.Count();
2008 Eina_List* keyList = NULL;
2009 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
2011 for( int index = 0; index < keyCount; ++index )
2013 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2014 keyList = eina_list_append( keyList, &info );
2017 Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset( mEcoreWindow, keyList );
2019 result.Resize( keyCount, true );
2021 Eina_List* l = NULL;
2022 Eina_List* m = NULL;
2023 void *listData = NULL;
2026 if( ungrabList != NULL )
2028 EINA_LIST_FOREACH( ungrabList, m, data )
2031 EINA_LIST_FOREACH( keyList, l, listData )
2033 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
2035 result[index] = false;
2044 eina_list_free( keyList );
2045 eina_list_free( ungrabList );
2051 void WindowBaseEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2056 // 1 inch = 25.4 millimeters
2057 xres = ecore_wl_dpi_get();
2058 yres = ecore_wl_dpi_get();
2060 dpiHorizontal = int( xres + 0.5f ); // rounding
2061 dpiVertical = int( yres + 0.5f );
2064 int WindowBaseEcoreWl::GetScreenRotationAngle()
2068 if( ecore_wl_window_ignore_output_transform_get( mEcoreWindow ) )
2074 transform = ecore_wl_output_transform_get( ecore_wl_window_output_find( mEcoreWindow ) );
2077 return transform * 90;
2080 void WindowBaseEcoreWl::SetWindowRotationAngle( int degree )
2082 ecore_wl_window_rotation_set( mEcoreWindow, degree );
2085 void WindowBaseEcoreWl::WindowRotationCompleted( int degree, int width, int height )
2087 ecore_wl_window_rotation_change_done_send( mEcoreWindow );
2090 void WindowBaseEcoreWl::SetTransparency( bool transparent )
2092 ecore_wl_window_alpha_set( mEcoreWindow, transparent );
2095 void WindowBaseEcoreWl::InitializeEcoreElDBus()
2097 #ifdef DALI_ELDBUS_AVAILABLE
2098 Eldbus_Object* object;
2099 Eldbus_Proxy* manager;
2101 if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2103 DALI_LOG_ERROR( "Unable to get system bus\n" );
2106 object = eldbus_object_get( mSystemConnection, BUS, PATH );
2109 DALI_LOG_ERROR( "Getting object failed\n" );
2113 manager = eldbus_proxy_get( object, INTERFACE );
2116 DALI_LOG_ERROR( "Getting proxy failed\n" );
2120 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2122 DALI_LOG_ERROR( "No signal handler returned\n" );
2127 void WindowBaseEcoreWl::CreateWindow( PositionSize positionSize )
2129 mEcoreWindow = ecore_wl_window_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW );
2131 if ( mEcoreWindow == 0 )
2133 DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2137 } // namespace Adaptor
2139 } // namespace Internal
2143 #pragma GCC diagnostic pop