2 * Copyright (c) 2019 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 case ECORE_DEVICE_SUBCLASS_REMOCON:
183 deviceSubclass = Device::Subclass::REMOCON;
186 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
188 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
193 deviceSubclass = Device::Subclass::NONE;
199 /////////////////////////////////////////////////////////////////////////////////////////////////
201 /////////////////////////////////////////////////////////////////////////////////////////////////
203 /// Called when the window iconify state is changed.
204 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
206 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
209 return windowBase->OnIconifyStateChanged( data, type, event );
212 return ECORE_CALLBACK_PASS_ON;
215 /// Called when the window gains focus
216 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
218 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
221 return windowBase->OnFocusIn( data, type, event );
224 return ECORE_CALLBACK_PASS_ON;
227 /// Called when the window loses focus
228 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
230 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
233 return windowBase->OnFocusOut( data, type, event );
236 return ECORE_CALLBACK_PASS_ON;
239 /// Called when the output is transformed
240 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
242 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
245 return windowBase->OnOutputTransform( data, type, event );
248 return ECORE_CALLBACK_PASS_ON;
251 /// Called when the output transform should be ignored
252 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
254 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
257 return windowBase->OnIgnoreOutputTransform( data, type, event );
260 return ECORE_CALLBACK_PASS_ON;
264 * Called when rotate event is recevied.
266 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
268 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
271 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl::EcoreEventRotate\n" );
272 windowBase->OnRotation( data, type, event );
274 return ECORE_CALLBACK_PASS_ON;
277 /////////////////////////////////////////////////////////////////////////////////////////////////
279 /////////////////////////////////////////////////////////////////////////////////////////////////
282 * Called when a touch down is received.
284 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
286 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
289 windowBase->OnMouseButtonDown( data, type, event );
291 return ECORE_CALLBACK_PASS_ON;
295 * Called when a touch up is received.
297 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
299 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
302 windowBase->OnMouseButtonUp( data, type, event );
304 return ECORE_CALLBACK_PASS_ON;
308 * Called when a touch motion is received.
310 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
312 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
315 windowBase->OnMouseButtonMove( data, type, event );
317 return ECORE_CALLBACK_PASS_ON;
321 * Called when a touch is canceled.
323 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
325 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
328 windowBase->OnMouseButtonCancel( data, type, event );
330 return ECORE_CALLBACK_PASS_ON;
334 * Called when a mouse wheel is received.
336 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
338 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
341 windowBase->OnMouseWheel( data, type, event );
343 return ECORE_CALLBACK_PASS_ON;
347 * Called when a detent rotation event is recevied.
349 static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
351 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
354 windowBase->OnDetentRotation( data, type, event );
356 return ECORE_CALLBACK_PASS_ON;
359 /////////////////////////////////////////////////////////////////////////////////////////////////
361 /////////////////////////////////////////////////////////////////////////////////////////////////
364 * Called when a key down is received.
366 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
368 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
371 windowBase->OnKeyDown( data, type, event );
373 return ECORE_CALLBACK_PASS_ON;
377 * Called when a key up is received.
379 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
381 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
384 windowBase->OnKeyUp( data, type, event );
386 return ECORE_CALLBACK_PASS_ON;
389 /////////////////////////////////////////////////////////////////////////////////////////////////
390 // Selection Callbacks
391 /////////////////////////////////////////////////////////////////////////////////////////////////
394 * Called when the source window notifies us the content in clipboard is selected.
396 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
398 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
401 windowBase->OnDataSend( data, type, event );
403 return ECORE_CALLBACK_PASS_ON;
407 * Called when the source window sends us about the selected content.
408 * For example, when item is selected in the clipboard.
410 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
412 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
415 windowBase->OnDataReceive( data, type, event );
417 return ECORE_CALLBACK_PASS_ON;
420 /////////////////////////////////////////////////////////////////////////////////////////////////
422 /////////////////////////////////////////////////////////////////////////////////////////////////
425 * Called when a font name is changed.
427 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
429 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
432 windowBase->OnFontNameChanged();
437 * Called when a font size is changed.
439 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
441 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
444 windowBase->OnFontSizeChanged();
448 /////////////////////////////////////////////////////////////////////////////////////////////////
449 // ElDBus Accessibility Callbacks
450 /////////////////////////////////////////////////////////////////////////////////////////////////
452 #ifdef DALI_ELDBUS_AVAILABLE
453 // Callback for Ecore ElDBus accessibility events.
454 static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
456 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( context );
459 windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
462 #endif // DALI_ELDBUS_AVAILABLE
464 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
466 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
469 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
473 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
475 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
478 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
482 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
486 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 )
490 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
492 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
495 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
499 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
503 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
505 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
508 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
512 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
516 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
520 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
524 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
528 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 )
532 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
534 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
537 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
541 const struct wl_registry_listener registryListener =
543 RegistryGlobalCallback,
544 RegistryGlobalCallbackRemove
547 const struct tizen_policy_listener tizenPolicyListener =
549 TizenPolicyConformant,
550 TizenPolicyConformantArea,
551 TizenPolicyNotificationChangeDone,
552 TizenPolicyTransientForDone,
553 TizenPolicyScreenModeChangeDone,
554 TizenPolicyIconifyStateChanged,
555 TizenPolicySupportedAuxiliaryHints,
556 TizenPolicyAllowedAuxiliaryHint,
557 TizenPolicyAuxiliaryMessage,
558 TizenPolicyConformantRegion
561 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
563 DisplayPolicyBrightnessChangeDone
566 } // unnamed namespace
568 WindowBaseEcoreWl::WindowBaseEcoreWl( Dali::PositionSize positionSize, Any surface, bool isTransparent )
569 : mEcoreEventHandler(),
570 mEcoreWindow( NULL ),
575 mTizenPolicy( NULL ),
576 mTizenDisplayPolicy( NULL ),
577 mSupportedAuxiliaryHints(),
579 mNotificationLevel( -1 ),
580 mNotificationChangeState( 0 ),
581 mNotificationLevelChangeDone( true ),
583 mScreenOffModeChangeState( 0 ),
584 mScreenOffModeChangeDone( true ),
586 mBrightnessChangeState( 0 ),
587 mBrightnessChangeDone( true ),
588 mOwnSurface( false ),
589 mWindowRotationAngle( 0 ),
590 mScreenRotationAngle( 0 ),
591 mSupportedPreProtation( 0 )
592 #ifdef DALI_ELDBUS_AVAILABLE
593 , mSystemConnection( NULL )
596 Initialize( positionSize, surface, isTransparent );
599 WindowBaseEcoreWl::~WindowBaseEcoreWl()
601 #ifdef DALI_ELDBUS_AVAILABLE
602 // Close down ElDBus connections.
603 if( mSystemConnection )
605 eldbus_connection_unref( mSystemConnection );
607 #endif // DALI_ELDBUS_AVAILABLE
609 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
610 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
612 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
614 ecore_event_handler_del( *iter );
616 mEcoreEventHandler.Clear();
620 wl_event_queue_destroy( mEventQueue );
623 mSupportedAuxiliaryHints.clear();
624 mAuxiliaryHints.clear();
626 if( mEglWindow != NULL )
628 wl_egl_window_destroy( mEglWindow );
634 ecore_wl_window_free( mEcoreWindow );
636 WindowSystem::Shutdown();
640 void WindowBaseEcoreWl::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
642 if( surface.Empty() == false )
644 // check we have a valid type
645 DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl_Window *) ) && "Surface type is invalid" );
647 mEcoreWindow = AnyCast< Ecore_Wl_Window* >( surface );
651 // we own the surface about to created
652 WindowSystem::Initialize();
655 CreateWindow( positionSize );
658 mWlSurface = ecore_wl_window_surface_create( mEcoreWindow );
660 SetTransparency( isTransparent );
662 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
663 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
664 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
665 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
666 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
668 // Register Rotate event
669 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
671 // Register Touch events
672 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
673 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
674 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
675 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
677 // Register Mouse wheel events
678 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
680 // Register Detent event
681 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
683 // Register Key events
684 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
685 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
687 // Register Selection event - clipboard selection
688 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
689 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
691 // Register Vconf notify - font name and size
692 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
693 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
695 InitializeEcoreElDBus();
697 mDisplay = ecore_wl_display_get();
701 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
704 mEventQueue = wl_display_create_queue( mDisplay );
707 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
709 wl_registry* registry = wl_display_get_registry( displayWrapper );
710 wl_registry_add_listener( registry, ®istryListener, this );
713 wl_proxy_wrapper_destroy( displayWrapper );
717 // get auxiliary hint
718 Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEcoreWindow );
724 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) ) ) )
726 mSupportedAuxiliaryHints.push_back( hint );
728 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint );
733 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event )
735 Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
736 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
738 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) )
740 if( iconifyChangedEvent->iconified == EINA_TRUE )
742 mIconifyChangedSignal.Emit( true );
746 mIconifyChangedSignal.Emit( false );
748 handled = ECORE_CALLBACK_DONE;
754 Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event )
756 Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
758 if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
760 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
762 mFocusChangedSignal.Emit( true );
765 return ECORE_CALLBACK_PASS_ON;
768 Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event )
770 Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
772 if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
774 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
776 mFocusChangedSignal.Emit( false );
779 return ECORE_CALLBACK_PASS_ON;
782 Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event )
784 Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) );
786 if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) )
788 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
790 mOutputTransformedSignal.Emit();
793 return ECORE_CALLBACK_PASS_ON;
796 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event )
798 Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) );
800 if( ignoreTransformEvent->win == mEcoreWindow )
802 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
804 mOutputTransformedSignal.Emit();
807 return ECORE_CALLBACK_PASS_ON;
810 void WindowBaseEcoreWl::OnRotation( void* data, int type, void* event )
812 Ecore_Wl_Event_Window_Rotate* ev( static_cast< Ecore_Wl_Event_Window_Rotate* >( event ) );
814 if( ev->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
816 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h );
818 RotationEvent rotationEvent;
819 rotationEvent.angle = ev->angle;
820 rotationEvent.winResize = 0;
822 if( ev->angle == 0 || ev->angle == 180 )
824 rotationEvent.width = ev->w;
825 rotationEvent.height = ev->h;
829 rotationEvent.width = ev->h;
830 rotationEvent.height = ev->w;
833 mRotationSignal.Emit( rotationEvent );
837 void WindowBaseEcoreWl::OnMouseButtonDown( void* data, int type, void* event )
839 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
841 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
843 PointState::Type state ( PointState::DOWN );
845 // Check if the buttons field is set and ensure it's the primary touch button.
846 // If this event was triggered by buttons other than the primary button (used for touch), then
847 // just send an interrupted event to Core.
848 if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
850 state = PointState::INTERRUPTED;
853 Device::Class::Type deviceClass;
854 Device::Subclass::Type deviceSubclass;
856 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
857 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
859 Integration::Point point;
860 point.SetDeviceId( touchEvent->multi.device );
861 point.SetState( state );
862 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
863 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
864 point.SetPressure( touchEvent->multi.pressure );
865 point.SetAngle( Degree( touchEvent->multi.angle ) );
866 point.SetDeviceClass( deviceClass );
867 point.SetDeviceSubclass( deviceSubclass );
869 mTouchEventSignal.Emit( point, touchEvent->timestamp );
873 void WindowBaseEcoreWl::OnMouseButtonUp( void* data, int type, void* event )
875 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
877 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
879 Device::Class::Type deviceClass;
880 Device::Subclass::Type deviceSubclass;
882 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
883 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
885 Integration::Point point;
886 point.SetDeviceId( touchEvent->multi.device );
887 point.SetState( PointState::UP );
888 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
889 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
890 point.SetPressure( touchEvent->multi.pressure );
891 point.SetAngle( Degree( touchEvent->multi.angle ) );
892 point.SetDeviceClass( deviceClass );
893 point.SetDeviceSubclass( deviceSubclass );
895 mTouchEventSignal.Emit( point, touchEvent->timestamp );
899 void WindowBaseEcoreWl::OnMouseButtonMove( void* data, int type, void* event )
901 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
903 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
905 Device::Class::Type deviceClass;
906 Device::Subclass::Type deviceSubclass;
908 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
909 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
911 Integration::Point point;
912 point.SetDeviceId( touchEvent->multi.device );
913 point.SetState( PointState::MOTION );
914 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
915 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
916 point.SetPressure( touchEvent->multi.pressure );
917 point.SetAngle( Degree( touchEvent->multi.angle ) );
918 point.SetDeviceClass( deviceClass );
919 point.SetDeviceSubclass( deviceSubclass );
921 mTouchEventSignal.Emit( point, touchEvent->timestamp );
925 void WindowBaseEcoreWl::OnMouseButtonCancel( void* data, int type, void* event )
927 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
929 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
931 Integration::Point point;
932 point.SetDeviceId( touchEvent->multi.device );
933 point.SetState( PointState::INTERRUPTED );
934 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
936 mTouchEventSignal.Emit( point, touchEvent->timestamp );
938 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" );
942 void WindowBaseEcoreWl::OnMouseWheel( void* data, int type, void* event )
944 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
946 if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
948 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 );
950 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
952 mWheelEventSignal.Emit( wheelEvent );
956 void WindowBaseEcoreWl::OnDetentRotation( void* data, int type, void* event )
958 Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
960 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" );
962 int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
963 int timeStamp = detentEvent->timestamp;
965 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2( 0.0f, 0.0f ), direction, timeStamp );
967 mWheelEventSignal.Emit( wheelEvent );
970 void WindowBaseEcoreWl::OnKeyDown( void* data, int type, void* event )
972 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
974 if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
976 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" );
978 std::string keyName( keyEvent->keyname );
979 std::string logicalKey( "" );
980 std::string keyString( "" );
981 std::string compose( "" );
983 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
984 if( keyEvent->compose )
986 compose = keyEvent->compose;
989 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
992 logicalKey = keyEvent->key;
995 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
996 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
997 int modifier( keyEvent->modifiers );
998 unsigned long time = keyEvent->timestamp;
999 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1001 keyCode = atoi( keyEvent->keyname + 8 );
1004 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1005 if( keyEvent->string )
1007 keyString = keyEvent->string;
1010 std::string deviceName;
1011 Device::Class::Type deviceClass;
1012 Device::Subclass::Type deviceSubclass;
1014 GetDeviceName( keyEvent, deviceName );
1015 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1016 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1018 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, deviceName, deviceClass, deviceSubclass );
1020 mKeyEventSignal.Emit( keyEvent );
1024 void WindowBaseEcoreWl::OnKeyUp( void* data, int type, void* event )
1026 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1028 if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
1030 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" );
1032 std::string keyName( keyEvent->keyname );
1033 std::string logicalKey( "" );
1034 std::string keyString( "" );
1035 std::string compose( "" );
1037 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1038 if( keyEvent->compose )
1040 compose = keyEvent->compose;
1043 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1046 logicalKey = keyEvent->key;
1049 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1050 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1051 int modifier( keyEvent->modifiers );
1052 unsigned long time = keyEvent->timestamp;
1053 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1055 keyCode = atoi( keyEvent->keyname + 8 );
1058 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1059 if( keyEvent->string )
1061 keyString = keyEvent->string;
1064 std::string deviceName;
1065 Device::Class::Type deviceClass;
1066 Device::Subclass::Type deviceSubclass;
1068 GetDeviceName( keyEvent, deviceName );
1069 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1070 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1072 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, deviceName, deviceClass, deviceSubclass );
1074 mKeyEventSignal.Emit( keyEvent );
1078 void WindowBaseEcoreWl::OnDataSend( void* data, int type, void* event )
1080 mSelectionDataSendSignal.Emit( event );
1083 void WindowBaseEcoreWl::OnDataReceive( void* data, int type, void* event )
1085 mSelectionDataReceivedSignal.Emit( event );
1088 void WindowBaseEcoreWl::OnFontNameChanged()
1090 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1093 void WindowBaseEcoreWl::OnFontSizeChanged()
1095 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1098 void WindowBaseEcoreWl::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1100 #ifdef DALI_ELDBUS_AVAILABLE
1101 AccessibilityInfo info;
1103 // The string defines the arg-list's respective types.
1104 if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1106 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1109 mAccessibilitySignal.Emit( info );
1113 void WindowBaseEcoreWl::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1115 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1117 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1119 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1122 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1126 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1128 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1130 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1132 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1133 if( !mTizenDisplayPolicy )
1135 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1139 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1141 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1145 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1147 mTizenPolicy = NULL;
1148 mTizenDisplayPolicy = NULL;
1151 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1153 mNotificationLevel = level;
1154 mNotificationChangeState = state;
1155 mNotificationLevelChangeDone = true;
1157 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1160 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1162 mScreenOffMode = mode;
1163 mScreenOffModeChangeState = state;
1164 mScreenOffModeChangeDone = true;
1166 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1169 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1171 mBrightness = brightness;
1172 mBrightnessChangeState = state;
1173 mBrightnessChangeDone = true;
1175 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1178 Any WindowBaseEcoreWl::GetNativeWindow()
1180 return mEcoreWindow;
1183 int WindowBaseEcoreWl::GetNativeWindowId()
1185 return ecore_wl_window_id_get( mEcoreWindow );
1188 EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow( int width, int height )
1190 mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1192 return static_cast< EGLNativeWindowType >( mEglWindow );
1195 void WindowBaseEcoreWl::DestroyEglWindow()
1197 if( mEglWindow != NULL )
1199 wl_egl_window_destroy( mEglWindow );
1204 void WindowBaseEcoreWl::SetEglWindowRotation( int angle )
1206 wl_egl_window_rotation rotation;
1212 rotation = ROTATION_0;
1217 rotation = ROTATION_270;
1222 rotation = ROTATION_180;
1227 rotation = ROTATION_90;
1232 rotation = ROTATION_0;
1237 wl_egl_window_set_rotation( mEglWindow, rotation );
1240 void WindowBaseEcoreWl::SetEglWindowBufferTransform( int angle )
1242 wl_output_transform bufferTransform;
1248 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1253 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1258 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1263 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1268 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1273 wl_egl_window_set_buffer_transform( mEglWindow, bufferTransform );
1276 void WindowBaseEcoreWl::SetEglWindowTransform( int angle )
1278 wl_output_transform windowTransform;
1284 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1289 windowTransform = WL_OUTPUT_TRANSFORM_90;
1294 windowTransform = WL_OUTPUT_TRANSFORM_180;
1299 windowTransform = WL_OUTPUT_TRANSFORM_270;
1304 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1309 wl_egl_window_set_window_transform( mEglWindow, windowTransform );
1312 void WindowBaseEcoreWl::ResizeEglWindow( PositionSize positionSize )
1314 wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1317 bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
1320 wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) );
1321 if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED )
1323 mSupportedPreProtation = true;
1326 mSupportedPreProtation = false;
1330 void WindowBaseEcoreWl::Move( PositionSize positionSize )
1332 ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1335 void WindowBaseEcoreWl::Resize( PositionSize positionSize )
1337 ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
1340 void WindowBaseEcoreWl::MoveResize( PositionSize positionSize )
1342 ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1343 ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
1346 void WindowBaseEcoreWl::SetClass( const std::string& name, const std::string& className )
1348 ecore_wl_window_title_set( mEcoreWindow, name.c_str() );
1349 ecore_wl_window_class_name_set( mEcoreWindow, className.c_str() );
1352 void WindowBaseEcoreWl::Raise()
1354 // Use ecore_wl_window_activate to prevent the window shown without rendering
1355 ecore_wl_window_activate( mEcoreWindow );
1358 void WindowBaseEcoreWl::Lower()
1360 ecore_wl_window_lower( mEcoreWindow );
1363 void WindowBaseEcoreWl::Activate()
1365 ecore_wl_window_activate( mEcoreWindow );
1368 void WindowBaseEcoreWl::SetAvailableAnlges( const std::vector< int >& angles )
1370 int rotations[4] = { 0 };
1371 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl::SetAvailableAnlges, angle's count: %d\n", angles.size() );
1372 for( std::size_t i = 0; i < angles.size(); ++i )
1374 rotations[i] = static_cast< int >( angles[i] );
1375 DALI_LOG_RELEASE_INFO( "%d ", rotations[i] );
1377 ecore_wl_window_rotation_available_rotations_set( mEcoreWindow, rotations, angles.size() );
1380 void WindowBaseEcoreWl::SetPreferredAngle( int angle )
1382 ecore_wl_window_rotation_preferred_rotation_set( mEcoreWindow, angle );
1385 void WindowBaseEcoreWl::SetAcceptFocus( bool accept )
1387 ecore_wl_window_focus_skip_set( mEcoreWindow, !accept );
1390 void WindowBaseEcoreWl::Show()
1392 ecore_wl_window_show( mEcoreWindow );
1395 void WindowBaseEcoreWl::Hide()
1397 ecore_wl_window_hide( mEcoreWindow );
1400 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
1402 return mSupportedAuxiliaryHints.size();
1405 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint( unsigned int index ) const
1407 if( index >= GetSupportedAuxiliaryHintCount() )
1409 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1412 return mSupportedAuxiliaryHints[index];
1415 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1417 bool supported = false;
1419 // Check if the hint is suppported
1420 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1431 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1435 // Check if the hint is already added
1436 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1438 if( mAuxiliaryHints[i].first == hint )
1440 // Just change the value
1441 mAuxiliaryHints[i].second = value;
1443 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1445 return i + 1; // id is index + 1
1450 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1452 unsigned int id = mAuxiliaryHints.size();
1454 ecore_wl_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1456 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1461 bool WindowBaseEcoreWl::RemoveAuxiliaryHint( unsigned int id )
1463 if( id == 0 || id > mAuxiliaryHints.size() )
1465 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1469 mAuxiliaryHints[id - 1].second = std::string();
1471 ecore_wl_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1473 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1478 bool WindowBaseEcoreWl::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1480 if( id == 0 || id > mAuxiliaryHints.size() )
1482 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1486 mAuxiliaryHints[id - 1].second = value;
1488 ecore_wl_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1490 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() );
1495 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue( unsigned int id ) const
1497 if( id == 0 || id > mAuxiliaryHints.size() )
1499 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1500 return std::string();
1503 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() );
1505 return mAuxiliaryHints[id - 1].second;
1508 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId( const std::string& hint ) const
1510 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1512 if( mAuxiliaryHints[i].first == hint )
1514 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1519 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1524 void WindowBaseEcoreWl::SetInputRegion( const Rect< int >& inputRegion )
1526 ecore_wl_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1529 void WindowBaseEcoreWl::SetType( Dali::Window::Type type )
1531 Ecore_Wl_Window_Type windowType;
1535 case Dali::Window::NORMAL:
1537 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1540 case Dali::Window::NOTIFICATION:
1542 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1545 case Dali::Window::UTILITY:
1547 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1550 case Dali::Window::DIALOG:
1552 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1557 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1562 ecore_wl_window_type_set( mEcoreWindow, windowType );
1565 bool WindowBaseEcoreWl::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
1567 while( !mTizenPolicy )
1569 wl_display_dispatch_queue( mDisplay, mEventQueue );
1572 int notificationLevel;
1576 case Dali::Window::NotificationLevel::NONE:
1578 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1581 case Dali::Window::NotificationLevel::BASE:
1583 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1586 case Dali::Window::NotificationLevel::MEDIUM:
1588 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1591 case Dali::Window::NotificationLevel::HIGH:
1593 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1596 case Dali::Window::NotificationLevel::TOP:
1598 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1603 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level );
1604 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1609 mNotificationLevelChangeDone = false;
1610 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1612 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), notificationLevel );
1616 while( !mNotificationLevelChangeDone && count < 3 )
1619 wl_display_dispatch_queue( mDisplay, mEventQueue );
1623 if( !mNotificationLevelChangeDone )
1625 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1628 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1630 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level );
1634 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1639 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl::GetNotificationLevel() const
1641 while( !mTizenPolicy )
1643 wl_display_dispatch_queue( mDisplay, mEventQueue );
1648 while( !mNotificationLevelChangeDone && count < 3 )
1651 wl_display_dispatch_queue( mDisplay, mEventQueue );
1655 if( !mNotificationLevelChangeDone )
1657 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1658 return Dali::Window::NotificationLevel::NONE;
1661 Dali::Window::NotificationLevel::Type level;
1663 switch( mNotificationLevel )
1665 case TIZEN_POLICY_LEVEL_NONE:
1667 level = Dali::Window::NotificationLevel::NONE;
1670 case TIZEN_POLICY_LEVEL_DEFAULT:
1672 level = Dali::Window::NotificationLevel::BASE;
1675 case TIZEN_POLICY_LEVEL_MEDIUM:
1677 level = Dali::Window::NotificationLevel::MEDIUM;
1680 case TIZEN_POLICY_LEVEL_HIGH:
1682 level = Dali::Window::NotificationLevel::HIGH;
1685 case TIZEN_POLICY_LEVEL_TOP:
1687 level = Dali::Window::NotificationLevel::TOP;
1692 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1693 level = Dali::Window::NotificationLevel::NONE;
1698 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1703 void WindowBaseEcoreWl::SetOpaqueState( bool opaque )
1705 while( !mTizenPolicy )
1707 wl_display_dispatch_queue( mDisplay, mEventQueue );
1710 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1713 bool WindowBaseEcoreWl::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
1715 while( !mTizenPolicy )
1717 wl_display_dispatch_queue( mDisplay, mEventQueue );
1720 mScreenOffModeChangeDone = false;
1721 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1723 unsigned int mode = 0;
1725 switch( screenOffMode )
1727 case Dali::Window::ScreenOffMode::TIMEOUT:
1732 case Dali::Window::ScreenOffMode::NEVER:
1739 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), mode );
1743 while( !mScreenOffModeChangeDone && count < 3 )
1746 wl_display_dispatch_queue( mDisplay, mEventQueue );
1750 if( !mScreenOffModeChangeDone )
1752 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
1755 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1757 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
1761 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
1766 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl::GetScreenOffMode() const
1768 while( !mTizenPolicy )
1770 wl_display_dispatch_queue( mDisplay, mEventQueue );
1775 while( !mScreenOffModeChangeDone && count < 3 )
1778 wl_display_dispatch_queue( mDisplay, mEventQueue );
1782 if( !mScreenOffModeChangeDone )
1784 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
1785 return Dali::Window::ScreenOffMode::TIMEOUT;
1788 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1790 switch( mScreenOffMode )
1794 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1799 screenMode = Dali::Window::ScreenOffMode::NEVER;
1804 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
1809 bool WindowBaseEcoreWl::SetBrightness( int brightness )
1811 while( !mTizenDisplayPolicy )
1813 wl_display_dispatch_queue( mDisplay, mEventQueue );
1816 mBrightnessChangeDone = false;
1817 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1819 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl_window_surface_get( mEcoreWindow ), brightness );
1823 while( !mBrightnessChangeDone && count < 3 )
1826 wl_display_dispatch_queue( mDisplay, mEventQueue );
1830 if( !mBrightnessChangeDone )
1832 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
1835 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1837 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness );
1841 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness );
1846 int WindowBaseEcoreWl::GetBrightness() const
1848 while( !mTizenDisplayPolicy )
1850 wl_display_dispatch_queue( mDisplay, mEventQueue );
1855 while( !mBrightnessChangeDone && count < 3 )
1858 wl_display_dispatch_queue( mDisplay, mEventQueue );
1862 if( !mBrightnessChangeDone )
1864 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
1868 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness );
1873 bool WindowBaseEcoreWl::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
1875 Ecore_Wl_Window_Keygrab_Mode mode;
1879 case KeyGrab::TOPMOST:
1881 mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1884 case KeyGrab::SHARED:
1886 mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1889 case KeyGrab::OVERRIDE_EXCLUSIVE:
1891 mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1894 case KeyGrab::EXCLUSIVE:
1896 mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1905 return ecore_wl_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
1908 bool WindowBaseEcoreWl::UngrabKey( Dali::KEY key )
1910 return ecore_wl_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
1913 bool WindowBaseEcoreWl::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
1915 int keyCount = key.Count();
1916 int keyGrabModeCount = grabMode.Count();
1918 if( keyCount != keyGrabModeCount || keyCount == 0 )
1925 Eina_List* keyList = NULL;
1926 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1928 for( int index = 0; index < keyCount; ++index )
1930 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1932 switch( grabMode[index] )
1934 case KeyGrab::TOPMOST:
1936 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1939 case KeyGrab::SHARED:
1941 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1944 case KeyGrab::OVERRIDE_EXCLUSIVE:
1946 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1949 case KeyGrab::EXCLUSIVE:
1951 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1956 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1961 keyList = eina_list_append( keyList, &info );
1964 Eina_List* grabList = ecore_wl_window_keygrab_list_set( mEcoreWindow, keyList );
1966 result.Resize( keyCount, true );
1968 Eina_List* l = NULL;
1969 Eina_List* m = NULL;
1970 void* listData = NULL;
1972 if( grabList != NULL )
1974 EINA_LIST_FOREACH( grabList, m, data )
1977 EINA_LIST_FOREACH( keyList, l, listData )
1979 if( static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key == NULL )
1981 DALI_LOG_ERROR( "input key list has null data!" );
1985 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
1987 result[index] = false;
1996 eina_list_free( keyList );
1997 eina_list_free( grabList );
2003 bool WindowBaseEcoreWl::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2005 int keyCount = key.Count();
2013 Eina_List* keyList = NULL;
2014 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
2016 for( int index = 0; index < keyCount; ++index )
2018 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2019 keyList = eina_list_append( keyList, &info );
2022 Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset( mEcoreWindow, keyList );
2024 result.Resize( keyCount, true );
2026 Eina_List* l = NULL;
2027 Eina_List* m = NULL;
2028 void *listData = NULL;
2031 if( ungrabList != NULL )
2033 EINA_LIST_FOREACH( ungrabList, m, data )
2036 EINA_LIST_FOREACH( keyList, l, listData )
2038 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
2040 result[index] = false;
2049 eina_list_free( keyList );
2050 eina_list_free( ungrabList );
2056 void WindowBaseEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2061 // 1 inch = 25.4 millimeters
2062 xres = ecore_wl_dpi_get();
2063 yres = ecore_wl_dpi_get();
2065 dpiHorizontal = int( xres + 0.5f ); // rounding
2066 dpiVertical = int( yres + 0.5f );
2069 int WindowBaseEcoreWl::GetOrientation() const
2071 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2072 if( mSupportedPreProtation )
2079 int WindowBaseEcoreWl::GetScreenRotationAngle()
2083 if( ecore_wl_window_ignore_output_transform_get( mEcoreWindow ) )
2089 transform = ecore_wl_output_transform_get( ecore_wl_window_output_find( mEcoreWindow ) );
2092 mScreenRotationAngle = transform * 90;
2093 return mScreenRotationAngle;
2096 void WindowBaseEcoreWl::SetWindowRotationAngle( int degree )
2098 mWindowRotationAngle = degree;
2099 ecore_wl_window_rotation_set( mEcoreWindow, degree );
2102 int WindowBaseEcoreWl::GetWindowRotationAngle()
2104 return mWindowRotationAngle;
2107 void WindowBaseEcoreWl::WindowRotationCompleted( int degree, int width, int height )
2109 ecore_wl_window_rotation_change_done_send( mEcoreWindow );
2112 void WindowBaseEcoreWl::SetTransparency( bool transparent )
2114 ecore_wl_window_alpha_set( mEcoreWindow, transparent );
2117 void WindowBaseEcoreWl::InitializeEcoreElDBus()
2119 #ifdef DALI_ELDBUS_AVAILABLE
2120 Eldbus_Object* object;
2121 Eldbus_Proxy* manager;
2123 if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2125 DALI_LOG_ERROR( "Unable to get system bus\n" );
2128 object = eldbus_object_get( mSystemConnection, BUS, PATH );
2131 DALI_LOG_ERROR( "Getting object failed\n" );
2135 manager = eldbus_proxy_get( object, INTERFACE );
2138 DALI_LOG_ERROR( "Getting proxy failed\n" );
2142 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2144 DALI_LOG_ERROR( "No signal handler returned\n" );
2149 void WindowBaseEcoreWl::CreateWindow( PositionSize positionSize )
2151 mEcoreWindow = ecore_wl_window_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW );
2153 if ( mEcoreWindow == 0 )
2155 DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2159 void WindowBaseEcoreWl::SetParent( WindowBase* parentWinBase )
2161 Ecore_Wl_Window* ecoreParent = NULL;
2164 WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>( parentWinBase );
2165 ecoreParent = winBaseEcore->mEcoreWindow;
2167 ecore_wl_window_parent_set( mEcoreWindow, ecoreParent );
2170 int WindowBaseEcoreWl::CreateFrameRenderedSyncFence()
2175 int WindowBaseEcoreWl::CreateFramePresentedSyncFence()
2180 } // namespace Adaptor
2182 } // namespace Internal
2186 #pragma GCC diagnostic pop