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(nullptr),
574 mEventQueue(nullptr),
575 mTizenPolicy(nullptr),
576 mTizenDisplayPolicy(nullptr),
577 mSupportedAuxiliaryHints(),
579 mNotificationLevel(-1),
580 mNotificationChangeState(0),
581 mNotificationLevelChangeDone(true),
583 mScreenOffModeChangeState(0),
584 mScreenOffModeChangeDone(true),
586 mBrightnessChangeState(0),
587 mBrightnessChangeDone(true),
589 mWindowRotationAngle(0),
590 mScreenRotationAngle(0),
591 mSupportedPreProtation(0)
592 #ifdef DALI_ELDBUS_AVAILABLE
594 mSystemConnection(NULL)
597 Initialize(positionSize, surface, isTransparent);
600 WindowBaseEcoreWl::~WindowBaseEcoreWl()
602 #ifdef DALI_ELDBUS_AVAILABLE
603 // Close down ElDBus connections.
604 if( mSystemConnection )
606 eldbus_connection_unref( mSystemConnection );
608 #endif // DALI_ELDBUS_AVAILABLE
610 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
611 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
613 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
615 ecore_event_handler_del( *iter );
617 mEcoreEventHandler.Clear();
621 wl_event_queue_destroy( mEventQueue );
624 mSupportedAuxiliaryHints.clear();
625 mAuxiliaryHints.clear();
627 if( mEglWindow != NULL )
629 wl_egl_window_destroy( mEglWindow );
635 ecore_wl_window_free( mEcoreWindow );
637 WindowSystem::Shutdown();
641 void WindowBaseEcoreWl::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
643 if( surface.Empty() == false )
645 // check we have a valid type
646 DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl_Window *) ) && "Surface type is invalid" );
648 mEcoreWindow = AnyCast< Ecore_Wl_Window* >( surface );
652 // we own the surface about to created
653 WindowSystem::Initialize();
656 CreateWindow( positionSize );
659 mWlSurface = ecore_wl_window_surface_create( mEcoreWindow );
661 SetTransparency( isTransparent );
663 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
664 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
665 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
666 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
667 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
669 // Register Rotate event
670 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
672 // Register Touch events
673 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
674 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
675 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
676 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
678 // Register Mouse wheel events
679 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
681 // Register Detent event
682 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
684 // Register Key events
685 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
686 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
688 // Register Selection event - clipboard selection
689 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
690 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
692 // Register Vconf notify - font name and size
693 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
694 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
696 InitializeEcoreElDBus();
698 mDisplay = ecore_wl_display_get();
702 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
705 mEventQueue = wl_display_create_queue( mDisplay );
708 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
710 wl_registry* registry = wl_display_get_registry( displayWrapper );
711 wl_registry_add_listener( registry, ®istryListener, this );
714 wl_proxy_wrapper_destroy( displayWrapper );
718 // get auxiliary hint
719 Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEcoreWindow );
725 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) ) ) )
727 mSupportedAuxiliaryHints.push_back( hint );
729 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint );
734 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event )
736 Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
737 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
739 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) )
741 if( iconifyChangedEvent->iconified == EINA_TRUE )
743 mIconifyChangedSignal.Emit( true );
747 mIconifyChangedSignal.Emit( false );
749 handled = ECORE_CALLBACK_DONE;
755 Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event )
757 Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
759 if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
761 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
763 mFocusChangedSignal.Emit( true );
766 return ECORE_CALLBACK_PASS_ON;
769 Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event )
771 Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
773 if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
775 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
777 mFocusChangedSignal.Emit( false );
780 return ECORE_CALLBACK_PASS_ON;
783 Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event )
785 Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) );
787 if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) )
789 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
791 mOutputTransformedSignal.Emit();
794 return ECORE_CALLBACK_PASS_ON;
797 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event )
799 Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) );
801 if( ignoreTransformEvent->win == mEcoreWindow )
803 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
805 mOutputTransformedSignal.Emit();
808 return ECORE_CALLBACK_PASS_ON;
811 void WindowBaseEcoreWl::OnRotation( void* data, int type, void* event )
813 Ecore_Wl_Event_Window_Rotate* ev( static_cast< Ecore_Wl_Event_Window_Rotate* >( event ) );
815 if( ev->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
817 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h );
819 RotationEvent rotationEvent;
820 rotationEvent.angle = ev->angle;
821 rotationEvent.winResize = 0;
823 if( ev->angle == 0 || ev->angle == 180 )
825 rotationEvent.width = ev->w;
826 rotationEvent.height = ev->h;
830 rotationEvent.width = ev->h;
831 rotationEvent.height = ev->w;
834 mRotationSignal.Emit( rotationEvent );
838 void WindowBaseEcoreWl::OnMouseButtonDown( void* data, int type, void* event )
840 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
842 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
844 PointState::Type state ( PointState::DOWN );
846 // Check if the buttons field is set and ensure it's the primary touch button.
847 // If this event was triggered by buttons other than the primary button (used for touch), then
848 // just send an interrupted event to Core.
849 if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
851 state = PointState::INTERRUPTED;
854 Device::Class::Type deviceClass;
855 Device::Subclass::Type deviceSubclass;
857 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
858 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
860 Integration::Point point;
861 point.SetDeviceId( touchEvent->multi.device );
862 point.SetState( state );
863 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
864 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
865 point.SetPressure( touchEvent->multi.pressure );
866 point.SetAngle( Degree( touchEvent->multi.angle ) );
867 point.SetDeviceClass( deviceClass );
868 point.SetDeviceSubclass( deviceSubclass );
870 mTouchEventSignal.Emit( point, touchEvent->timestamp );
874 void WindowBaseEcoreWl::OnMouseButtonUp( void* data, int type, void* event )
876 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
878 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
880 Device::Class::Type deviceClass;
881 Device::Subclass::Type deviceSubclass;
883 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
884 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
886 Integration::Point point;
887 point.SetDeviceId( touchEvent->multi.device );
888 point.SetState( PointState::UP );
889 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
890 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
891 point.SetPressure( touchEvent->multi.pressure );
892 point.SetAngle( Degree( touchEvent->multi.angle ) );
893 point.SetDeviceClass( deviceClass );
894 point.SetDeviceSubclass( deviceSubclass );
896 mTouchEventSignal.Emit( point, touchEvent->timestamp );
900 void WindowBaseEcoreWl::OnMouseButtonMove( void* data, int type, void* event )
902 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
904 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
906 Device::Class::Type deviceClass;
907 Device::Subclass::Type deviceSubclass;
909 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
910 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
912 Integration::Point point;
913 point.SetDeviceId( touchEvent->multi.device );
914 point.SetState( PointState::MOTION );
915 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
916 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
917 point.SetPressure( touchEvent->multi.pressure );
918 point.SetAngle( Degree( touchEvent->multi.angle ) );
919 point.SetDeviceClass( deviceClass );
920 point.SetDeviceSubclass( deviceSubclass );
922 mTouchEventSignal.Emit( point, touchEvent->timestamp );
926 void WindowBaseEcoreWl::OnMouseButtonCancel( void* data, int type, void* event )
928 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
930 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
932 Integration::Point point;
933 point.SetDeviceId( touchEvent->multi.device );
934 point.SetState( PointState::INTERRUPTED );
935 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
937 mTouchEventSignal.Emit( point, touchEvent->timestamp );
939 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" );
943 void WindowBaseEcoreWl::OnMouseWheel( void* data, int type, void* event )
945 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
947 if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
949 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 );
951 Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
953 mWheelEventSignal.Emit( wheelEvent );
957 void WindowBaseEcoreWl::OnDetentRotation( void* data, int type, void* event )
959 Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
961 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" );
963 int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
964 int timeStamp = detentEvent->timestamp;
966 Integration::WheelEvent wheelEvent( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2( 0.0f, 0.0f ), direction, timeStamp );
968 mWheelEventSignal.Emit( wheelEvent );
971 void WindowBaseEcoreWl::OnKeyDown( void* data, int type, void* event )
973 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
975 if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
977 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" );
979 std::string keyName( keyEvent->keyname );
980 std::string logicalKey( "" );
981 std::string keyString( "" );
982 std::string compose( "" );
984 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
985 if( keyEvent->compose )
987 compose = keyEvent->compose;
990 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
993 logicalKey = keyEvent->key;
996 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
997 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
998 int modifier( keyEvent->modifiers );
999 unsigned long time = keyEvent->timestamp;
1000 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1002 keyCode = atoi( keyEvent->keyname + 8 );
1005 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1006 if( keyEvent->string )
1008 keyString = keyEvent->string;
1011 std::string deviceName;
1012 Device::Class::Type deviceClass;
1013 Device::Subclass::Type deviceSubclass;
1015 GetDeviceName( keyEvent, deviceName );
1016 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1017 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1019 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass );
1021 mKeyEventSignal.Emit( keyEvent );
1025 void WindowBaseEcoreWl::OnKeyUp( void* data, int type, void* event )
1027 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1029 if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
1031 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" );
1033 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1034 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1035 if( keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL )
1037 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp: This event flag indicates the event is canceled. \n" );
1040 #endif // Since ecore 1.23 version
1042 std::string keyName( keyEvent->keyname );
1043 std::string logicalKey( "" );
1044 std::string keyString( "" );
1045 std::string compose( "" );
1047 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1048 if( keyEvent->compose )
1050 compose = keyEvent->compose;
1053 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1056 logicalKey = keyEvent->key;
1059 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1060 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1061 int modifier( keyEvent->modifiers );
1062 unsigned long time = keyEvent->timestamp;
1063 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1065 keyCode = atoi( keyEvent->keyname + 8 );
1068 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1069 if( keyEvent->string )
1071 keyString = keyEvent->string;
1074 std::string deviceName;
1075 Device::Class::Type deviceClass;
1076 Device::Subclass::Type deviceSubclass;
1078 GetDeviceName( keyEvent, deviceName );
1079 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1080 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1082 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass );
1084 mKeyEventSignal.Emit( keyEvent );
1088 void WindowBaseEcoreWl::OnDataSend( void* data, int type, void* event )
1090 mSelectionDataSendSignal.Emit( event );
1093 void WindowBaseEcoreWl::OnDataReceive( void* data, int type, void* event )
1095 mSelectionDataReceivedSignal.Emit( event );
1098 void WindowBaseEcoreWl::OnFontNameChanged()
1100 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1103 void WindowBaseEcoreWl::OnFontSizeChanged()
1105 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1108 void WindowBaseEcoreWl::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1110 #ifdef DALI_ELDBUS_AVAILABLE
1111 AccessibilityInfo info;
1113 // The string defines the arg-list's respective types.
1114 if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1116 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1119 mAccessibilitySignal.Emit( info );
1123 void WindowBaseEcoreWl::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1125 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1127 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1129 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1132 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1136 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1138 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1140 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1142 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1143 if( !mTizenDisplayPolicy )
1145 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1149 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1151 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1155 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1157 mTizenPolicy = NULL;
1158 mTizenDisplayPolicy = NULL;
1161 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1163 mNotificationLevel = level;
1164 mNotificationChangeState = state;
1165 mNotificationLevelChangeDone = true;
1167 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1170 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1172 mScreenOffMode = mode;
1173 mScreenOffModeChangeState = state;
1174 mScreenOffModeChangeDone = true;
1176 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1179 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1181 mBrightness = brightness;
1182 mBrightnessChangeState = state;
1183 mBrightnessChangeDone = true;
1185 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1188 Any WindowBaseEcoreWl::GetNativeWindow()
1190 return mEcoreWindow;
1193 int WindowBaseEcoreWl::GetNativeWindowId()
1195 return ecore_wl_window_id_get( mEcoreWindow );
1198 EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow( int width, int height )
1200 mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1202 return static_cast< EGLNativeWindowType >( mEglWindow );
1205 void WindowBaseEcoreWl::DestroyEglWindow()
1207 if( mEglWindow != NULL )
1209 wl_egl_window_destroy( mEglWindow );
1214 void WindowBaseEcoreWl::SetEglWindowRotation( int angle )
1216 wl_egl_window_rotation rotation;
1222 rotation = ROTATION_0;
1227 rotation = ROTATION_270;
1232 rotation = ROTATION_180;
1237 rotation = ROTATION_90;
1242 rotation = ROTATION_0;
1247 wl_egl_window_set_rotation( mEglWindow, rotation );
1250 void WindowBaseEcoreWl::SetEglWindowBufferTransform( int angle )
1252 wl_output_transform bufferTransform;
1258 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1263 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1268 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1273 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1278 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1283 wl_egl_window_set_buffer_transform( mEglWindow, bufferTransform );
1286 void WindowBaseEcoreWl::SetEglWindowTransform( int angle )
1288 wl_output_transform windowTransform;
1294 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1299 windowTransform = WL_OUTPUT_TRANSFORM_90;
1304 windowTransform = WL_OUTPUT_TRANSFORM_180;
1309 windowTransform = WL_OUTPUT_TRANSFORM_270;
1314 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1319 wl_egl_window_set_window_transform( mEglWindow, windowTransform );
1322 void WindowBaseEcoreWl::ResizeEglWindow( PositionSize positionSize )
1324 wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1327 bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
1330 wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) );
1331 if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED )
1333 mSupportedPreProtation = true;
1336 mSupportedPreProtation = false;
1340 void WindowBaseEcoreWl::Move( PositionSize positionSize )
1342 ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1345 void WindowBaseEcoreWl::Resize( PositionSize positionSize )
1347 ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
1350 void WindowBaseEcoreWl::MoveResize( PositionSize positionSize )
1352 ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1353 ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
1356 void WindowBaseEcoreWl::SetClass( const std::string& name, const std::string& className )
1358 ecore_wl_window_title_set( mEcoreWindow, name.c_str() );
1359 ecore_wl_window_class_name_set( mEcoreWindow, className.c_str() );
1362 void WindowBaseEcoreWl::Raise()
1364 // Use ecore_wl_window_activate to prevent the window shown without rendering
1365 ecore_wl_window_activate( mEcoreWindow );
1368 void WindowBaseEcoreWl::Lower()
1370 ecore_wl_window_lower( mEcoreWindow );
1373 void WindowBaseEcoreWl::Activate()
1375 ecore_wl_window_activate( mEcoreWindow );
1378 void WindowBaseEcoreWl::SetAvailableAnlges( const std::vector< int >& angles )
1380 int rotations[4] = { 0 };
1381 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl::SetAvailableAnlges, angle's count: %d\n", angles.size() );
1382 for( std::size_t i = 0; i < angles.size(); ++i )
1384 rotations[i] = static_cast< int >( angles[i] );
1385 DALI_LOG_RELEASE_INFO( "%d ", rotations[i] );
1387 ecore_wl_window_rotation_available_rotations_set( mEcoreWindow, rotations, angles.size() );
1390 void WindowBaseEcoreWl::SetPreferredAngle( int angle )
1392 ecore_wl_window_rotation_preferred_rotation_set( mEcoreWindow, angle );
1395 void WindowBaseEcoreWl::SetAcceptFocus( bool accept )
1397 ecore_wl_window_focus_skip_set( mEcoreWindow, !accept );
1400 void WindowBaseEcoreWl::Show()
1402 ecore_wl_window_show( mEcoreWindow );
1405 void WindowBaseEcoreWl::Hide()
1407 ecore_wl_window_hide( mEcoreWindow );
1410 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
1412 return mSupportedAuxiliaryHints.size();
1415 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint( unsigned int index ) const
1417 if( index >= GetSupportedAuxiliaryHintCount() )
1419 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1422 return mSupportedAuxiliaryHints[index];
1425 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1427 bool supported = false;
1429 // Check if the hint is suppported
1430 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1441 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1445 // Check if the hint is already added
1446 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1448 if( mAuxiliaryHints[i].first == hint )
1450 // Just change the value
1451 mAuxiliaryHints[i].second = value;
1453 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1455 return i + 1; // id is index + 1
1460 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1462 unsigned int id = mAuxiliaryHints.size();
1464 ecore_wl_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1466 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1471 bool WindowBaseEcoreWl::RemoveAuxiliaryHint( unsigned int id )
1473 if( id == 0 || id > mAuxiliaryHints.size() )
1475 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1479 mAuxiliaryHints[id - 1].second = std::string();
1481 ecore_wl_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1483 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1488 bool WindowBaseEcoreWl::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1490 if( id == 0 || id > mAuxiliaryHints.size() )
1492 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1496 mAuxiliaryHints[id - 1].second = value;
1498 ecore_wl_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1500 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() );
1505 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue( unsigned int id ) const
1507 if( id == 0 || id > mAuxiliaryHints.size() )
1509 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1510 return std::string();
1513 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() );
1515 return mAuxiliaryHints[id - 1].second;
1518 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId( const std::string& hint ) const
1520 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1522 if( mAuxiliaryHints[i].first == hint )
1524 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1529 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1534 void WindowBaseEcoreWl::SetInputRegion( const Rect< int >& inputRegion )
1536 ecore_wl_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1539 void WindowBaseEcoreWl::SetType( Dali::WindowType type )
1541 Ecore_Wl_Window_Type windowType;
1545 case Dali::WindowType::NORMAL:
1547 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1550 case Dali::WindowType::NOTIFICATION:
1552 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1555 case Dali::WindowType::UTILITY:
1557 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1560 case Dali::WindowType::DIALOG:
1562 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1567 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1572 ecore_wl_window_type_set( mEcoreWindow, windowType );
1575 bool WindowBaseEcoreWl::SetNotificationLevel( Dali::WindowNotificationLevel level )
1577 while( !mTizenPolicy )
1579 wl_display_dispatch_queue( mDisplay, mEventQueue );
1582 int notificationLevel;
1586 case Dali::WindowNotificationLevel::NONE:
1588 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1591 case Dali::WindowNotificationLevel::BASE:
1593 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1596 case Dali::WindowNotificationLevel::MEDIUM:
1598 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1601 case Dali::WindowNotificationLevel::HIGH:
1603 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1606 case Dali::WindowNotificationLevel::TOP:
1608 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1613 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level );
1614 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1619 mNotificationLevelChangeDone = false;
1620 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1622 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), notificationLevel );
1626 while( !mNotificationLevelChangeDone && count < 3 )
1629 wl_display_dispatch_queue( mDisplay, mEventQueue );
1633 if( !mNotificationLevelChangeDone )
1635 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1638 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1640 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level );
1644 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1649 Dali::WindowNotificationLevel WindowBaseEcoreWl::GetNotificationLevel() const
1651 while( !mTizenPolicy )
1653 wl_display_dispatch_queue( mDisplay, mEventQueue );
1658 while( !mNotificationLevelChangeDone && count < 3 )
1661 wl_display_dispatch_queue( mDisplay, mEventQueue );
1665 if( !mNotificationLevelChangeDone )
1667 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1668 return Dali::Window::NotificationLevel::NONE;
1671 Dali::WindowNotificationLevel level;
1673 switch( mNotificationLevel )
1675 case TIZEN_POLICY_LEVEL_NONE:
1677 level = Dali::WindowNotificationLevel::NONE;
1680 case TIZEN_POLICY_LEVEL_DEFAULT:
1682 level = Dali::WindowNotificationLevel::BASE;
1685 case TIZEN_POLICY_LEVEL_MEDIUM:
1687 level = Dali::WindowNotificationLevel::MEDIUM;
1690 case TIZEN_POLICY_LEVEL_HIGH:
1692 level = Dali::WindowNotificationLevel::HIGH;
1695 case TIZEN_POLICY_LEVEL_TOP:
1697 level = Dali::WindowNotificationLevel::TOP;
1702 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1703 level = Dali::WindowNotificationLevel::NONE;
1708 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1713 void WindowBaseEcoreWl::SetOpaqueState( bool opaque )
1715 while( !mTizenPolicy )
1717 wl_display_dispatch_queue( mDisplay, mEventQueue );
1720 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1723 bool WindowBaseEcoreWl::SetScreenOffMode(WindowScreenOffMode screenOffMode)
1725 while( !mTizenPolicy )
1727 wl_display_dispatch_queue( mDisplay, mEventQueue );
1730 mScreenOffModeChangeDone = false;
1731 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1733 unsigned int mode = 0;
1735 switch( screenOffMode )
1737 case WindowScreenOffMode::TIMEOUT:
1742 case WindowScreenOffMode::NEVER:
1749 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), mode );
1753 while( !mScreenOffModeChangeDone && count < 3 )
1756 wl_display_dispatch_queue( mDisplay, mEventQueue );
1760 if( !mScreenOffModeChangeDone )
1762 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
1765 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1767 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
1771 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
1776 WindowScreenOffMode WindowBaseEcoreWl::GetScreenOffMode() const
1778 while( !mTizenPolicy )
1780 wl_display_dispatch_queue( mDisplay, mEventQueue );
1785 while( !mScreenOffModeChangeDone && count < 3 )
1788 wl_display_dispatch_queue( mDisplay, mEventQueue );
1792 if( !mScreenOffModeChangeDone )
1794 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
1795 return WindowScreenOffMode::TIMEOUT;
1798 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
1800 switch( mScreenOffMode )
1804 screenMode = WindowScreenOffMode::TIMEOUT;
1809 screenMode = WindowScreenOffMode::NEVER;
1814 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
1819 bool WindowBaseEcoreWl::SetBrightness( int brightness )
1821 while( !mTizenDisplayPolicy )
1823 wl_display_dispatch_queue( mDisplay, mEventQueue );
1826 mBrightnessChangeDone = false;
1827 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1829 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl_window_surface_get( mEcoreWindow ), brightness );
1833 while( !mBrightnessChangeDone && count < 3 )
1836 wl_display_dispatch_queue( mDisplay, mEventQueue );
1840 if( !mBrightnessChangeDone )
1842 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
1845 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1847 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness );
1851 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness );
1856 int WindowBaseEcoreWl::GetBrightness() const
1858 while( !mTizenDisplayPolicy )
1860 wl_display_dispatch_queue( mDisplay, mEventQueue );
1865 while( !mBrightnessChangeDone && count < 3 )
1868 wl_display_dispatch_queue( mDisplay, mEventQueue );
1872 if( !mBrightnessChangeDone )
1874 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
1878 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness );
1883 bool WindowBaseEcoreWl::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
1885 Ecore_Wl_Window_Keygrab_Mode mode;
1889 case KeyGrab::TOPMOST:
1891 mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1894 case KeyGrab::SHARED:
1896 mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1899 case KeyGrab::OVERRIDE_EXCLUSIVE:
1901 mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1904 case KeyGrab::EXCLUSIVE:
1906 mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1915 return ecore_wl_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
1918 bool WindowBaseEcoreWl::UngrabKey( Dali::KEY key )
1920 return ecore_wl_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
1923 bool WindowBaseEcoreWl::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
1925 int keyCount = key.Count();
1926 int keyGrabModeCount = grabMode.Count();
1928 if( keyCount != keyGrabModeCount || keyCount == 0 )
1935 Eina_List* keyList = NULL;
1936 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1938 for( int index = 0; index < keyCount; ++index )
1940 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1942 switch( grabMode[index] )
1944 case KeyGrab::TOPMOST:
1946 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1949 case KeyGrab::SHARED:
1951 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1954 case KeyGrab::OVERRIDE_EXCLUSIVE:
1956 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1959 case KeyGrab::EXCLUSIVE:
1961 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1966 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1971 keyList = eina_list_append( keyList, &info );
1974 Eina_List* grabList = ecore_wl_window_keygrab_list_set( mEcoreWindow, keyList );
1976 result.Resize( keyCount, true );
1978 Eina_List* l = NULL;
1979 Eina_List* m = NULL;
1980 void* listData = NULL;
1982 if( grabList != NULL )
1984 EINA_LIST_FOREACH( grabList, m, data )
1987 EINA_LIST_FOREACH( keyList, l, listData )
1989 if( static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key == NULL )
1991 DALI_LOG_ERROR( "input key list has null data!" );
1995 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
1997 result[index] = false;
2006 eina_list_free( keyList );
2007 eina_list_free( grabList );
2013 bool WindowBaseEcoreWl::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2015 int keyCount = key.Count();
2023 Eina_List* keyList = NULL;
2024 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
2026 for( int index = 0; index < keyCount; ++index )
2028 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2029 keyList = eina_list_append( keyList, &info );
2032 Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset( mEcoreWindow, keyList );
2034 result.Resize( keyCount, true );
2036 Eina_List* l = NULL;
2037 Eina_List* m = NULL;
2038 void *listData = NULL;
2041 if( ungrabList != NULL )
2043 EINA_LIST_FOREACH( ungrabList, m, data )
2046 EINA_LIST_FOREACH( keyList, l, listData )
2048 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
2050 result[index] = false;
2059 eina_list_free( keyList );
2060 eina_list_free( ungrabList );
2066 void WindowBaseEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2071 // 1 inch = 25.4 millimeters
2072 xres = ecore_wl_dpi_get();
2073 yres = ecore_wl_dpi_get();
2075 dpiHorizontal = int( xres + 0.5f ); // rounding
2076 dpiVertical = int( yres + 0.5f );
2079 int WindowBaseEcoreWl::GetOrientation() const
2081 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2082 if(mSupportedPreProtation)
2089 int WindowBaseEcoreWl::GetScreenRotationAngle()
2093 if( ecore_wl_window_ignore_output_transform_get( mEcoreWindow ) )
2099 transform = ecore_wl_output_transform_get( ecore_wl_window_output_find( mEcoreWindow ) );
2102 mScreenRotationAngle = transform * 90;
2103 return mScreenRotationAngle;
2106 void WindowBaseEcoreWl::SetWindowRotationAngle( int degree )
2108 mWindowRotationAngle = degree;
2109 ecore_wl_window_rotation_set( mEcoreWindow, degree );
2112 void WindowBaseEcoreWl::WindowRotationCompleted( int degree, int width, int height )
2114 ecore_wl_window_rotation_change_done_send( mEcoreWindow );
2117 void WindowBaseEcoreWl::SetTransparency( bool transparent )
2119 ecore_wl_window_alpha_set( mEcoreWindow, transparent );
2122 void WindowBaseEcoreWl::InitializeEcoreElDBus()
2124 #ifdef DALI_ELDBUS_AVAILABLE
2125 Eldbus_Object* object;
2126 Eldbus_Proxy* manager;
2128 if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2130 DALI_LOG_ERROR( "Unable to get system bus\n" );
2133 object = eldbus_object_get( mSystemConnection, BUS, PATH );
2136 DALI_LOG_ERROR( "Getting object failed\n" );
2140 manager = eldbus_proxy_get( object, INTERFACE );
2143 DALI_LOG_ERROR( "Getting proxy failed\n" );
2147 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2149 DALI_LOG_ERROR( "No signal handler returned\n" );
2154 void WindowBaseEcoreWl::CreateWindow( PositionSize positionSize )
2156 mEcoreWindow = ecore_wl_window_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW );
2158 if ( mEcoreWindow == 0 )
2160 DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2164 void WindowBaseEcoreWl::SetParent( WindowBase* parentWinBase )
2166 Ecore_Wl_Window* ecoreParent = NULL;
2169 WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>( parentWinBase );
2170 ecoreParent = winBaseEcore->mEcoreWindow;
2172 ecore_wl_window_parent_set( mEcoreWindow, ecoreParent );
2175 int WindowBaseEcoreWl::CreateFrameRenderedSyncFence()
2180 int WindowBaseEcoreWl::CreateFramePresentedSyncFence()
2185 } // namespace Adaptor
2187 } // namespace Internal
2191 #pragma GCC diagnostic pop