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 windowBase->OnRotation( data, type, event );
273 return ECORE_CALLBACK_PASS_ON;
276 /////////////////////////////////////////////////////////////////////////////////////////////////
278 /////////////////////////////////////////////////////////////////////////////////////////////////
281 * Called when a touch down is received.
283 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
285 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
288 windowBase->OnMouseButtonDown( data, type, event );
290 return ECORE_CALLBACK_PASS_ON;
294 * Called when a touch up is received.
296 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
298 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
301 windowBase->OnMouseButtonUp( data, type, event );
303 return ECORE_CALLBACK_PASS_ON;
307 * Called when a touch motion is received.
309 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
311 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
314 windowBase->OnMouseButtonMove( data, type, event );
316 return ECORE_CALLBACK_PASS_ON;
320 * Called when a touch is canceled.
322 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
324 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
327 windowBase->OnMouseButtonCancel( data, type, event );
329 return ECORE_CALLBACK_PASS_ON;
333 * Called when a mouse wheel is received.
335 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
337 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
340 windowBase->OnMouseWheel( data, type, event );
342 return ECORE_CALLBACK_PASS_ON;
346 * Called when a detent rotation event is recevied.
348 static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
350 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
353 windowBase->OnDetentRotation( data, type, event );
355 return ECORE_CALLBACK_PASS_ON;
358 /////////////////////////////////////////////////////////////////////////////////////////////////
360 /////////////////////////////////////////////////////////////////////////////////////////////////
363 * Called when a key down is received.
365 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
367 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
370 windowBase->OnKeyDown( data, type, event );
372 return ECORE_CALLBACK_PASS_ON;
376 * Called when a key up is received.
378 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
380 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
383 windowBase->OnKeyUp( data, type, event );
385 return ECORE_CALLBACK_PASS_ON;
388 /////////////////////////////////////////////////////////////////////////////////////////////////
389 // Selection Callbacks
390 /////////////////////////////////////////////////////////////////////////////////////////////////
393 * Called when the source window notifies us the content in clipboard is selected.
395 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
397 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
400 windowBase->OnDataSend( data, type, event );
402 return ECORE_CALLBACK_PASS_ON;
406 * Called when the source window sends us about the selected content.
407 * For example, when item is selected in the clipboard.
409 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
411 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
414 windowBase->OnDataReceive( data, type, event );
416 return ECORE_CALLBACK_PASS_ON;
419 /////////////////////////////////////////////////////////////////////////////////////////////////
421 /////////////////////////////////////////////////////////////////////////////////////////////////
424 * Called when a font name is changed.
426 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
428 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
431 windowBase->OnFontNameChanged();
436 * Called when a font size is changed.
438 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
440 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
443 windowBase->OnFontSizeChanged();
447 /////////////////////////////////////////////////////////////////////////////////////////////////
448 // ElDBus Accessibility Callbacks
449 /////////////////////////////////////////////////////////////////////////////////////////////////
451 #ifdef DALI_ELDBUS_AVAILABLE
452 // Callback for Ecore ElDBus accessibility events.
453 static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
455 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( context );
458 windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
461 #endif // DALI_ELDBUS_AVAILABLE
463 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
465 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
468 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
472 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
474 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
477 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
481 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
485 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 )
489 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
491 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
494 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
498 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
502 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
504 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
507 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
511 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
515 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
519 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
523 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
527 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 )
531 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
533 WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
536 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
540 const struct wl_registry_listener registryListener =
542 RegistryGlobalCallback,
543 RegistryGlobalCallbackRemove
546 const struct tizen_policy_listener tizenPolicyListener =
548 TizenPolicyConformant,
549 TizenPolicyConformantArea,
550 TizenPolicyNotificationChangeDone,
551 TizenPolicyTransientForDone,
552 TizenPolicyScreenModeChangeDone,
553 TizenPolicyIconifyStateChanged,
554 TizenPolicySupportedAuxiliaryHints,
555 TizenPolicyAllowedAuxiliaryHint,
556 TizenPolicyAuxiliaryMessage,
557 TizenPolicyConformantRegion
560 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
562 DisplayPolicyBrightnessChangeDone
565 } // unnamed namespace
567 WindowBaseEcoreWl::WindowBaseEcoreWl( Dali::PositionSize positionSize, Any surface, bool isTransparent )
568 : mEcoreEventHandler(),
569 mEcoreWindow( NULL ),
574 mTizenPolicy( NULL ),
575 mTizenDisplayPolicy( NULL ),
576 mSupportedAuxiliaryHints(),
578 mNotificationLevel( -1 ),
579 mNotificationChangeState( 0 ),
580 mNotificationLevelChangeDone( true ),
582 mScreenOffModeChangeState( 0 ),
583 mScreenOffModeChangeDone( true ),
585 mBrightnessChangeState( 0 ),
586 mBrightnessChangeDone( true ),
587 mOwnSurface( false ),
588 mWindowRotationAngle( 0 ),
589 mScreenRotationAngle( 0 ),
590 mSupportedPreProtation( 0 )
591 #ifdef DALI_ELDBUS_AVAILABLE
592 , mSystemConnection( NULL )
595 Initialize( positionSize, surface, isTransparent );
598 WindowBaseEcoreWl::~WindowBaseEcoreWl()
600 #ifdef DALI_ELDBUS_AVAILABLE
601 // Close down ElDBus connections.
602 if( mSystemConnection )
604 eldbus_connection_unref( mSystemConnection );
606 #endif // DALI_ELDBUS_AVAILABLE
608 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
609 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
611 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
613 ecore_event_handler_del( *iter );
615 mEcoreEventHandler.Clear();
619 wl_event_queue_destroy( mEventQueue );
622 mSupportedAuxiliaryHints.clear();
623 mAuxiliaryHints.clear();
625 if( mEglWindow != NULL )
627 wl_egl_window_destroy( mEglWindow );
633 ecore_wl_window_free( mEcoreWindow );
635 WindowSystem::Shutdown();
639 void WindowBaseEcoreWl::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
641 if( surface.Empty() == false )
643 // check we have a valid type
644 DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl_Window *) ) && "Surface type is invalid" );
646 mEcoreWindow = AnyCast< Ecore_Wl_Window* >( surface );
650 // we own the surface about to created
651 WindowSystem::Initialize();
654 CreateWindow( positionSize );
657 mWlSurface = ecore_wl_window_surface_create( mEcoreWindow );
659 SetTransparency( isTransparent );
661 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
662 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
663 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
664 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
665 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
667 // Register Rotate event
668 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
670 // Register Touch events
671 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
672 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
673 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
674 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
676 // Register Mouse wheel events
677 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
679 // Register Detent event
680 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
682 // Register Key events
683 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
684 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
686 // Register Selection event - clipboard selection
687 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
688 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
690 // Register Vconf notify - font name and size
691 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
692 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
694 InitializeEcoreElDBus();
696 mDisplay = ecore_wl_display_get();
700 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
703 mEventQueue = wl_display_create_queue( mDisplay );
706 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
708 wl_registry* registry = wl_display_get_registry( displayWrapper );
709 wl_registry_add_listener( registry, ®istryListener, this );
712 wl_proxy_wrapper_destroy( displayWrapper );
716 // get auxiliary hint
717 Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEcoreWindow );
723 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) ) ) )
725 mSupportedAuxiliaryHints.push_back( hint );
727 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint );
732 Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event )
734 Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
735 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
737 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) )
739 if( iconifyChangedEvent->iconified == EINA_TRUE )
741 mIconifyChangedSignal.Emit( true );
745 mIconifyChangedSignal.Emit( false );
747 handled = ECORE_CALLBACK_DONE;
753 Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event )
755 Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
757 if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
759 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
761 mFocusChangedSignal.Emit( true );
764 return ECORE_CALLBACK_PASS_ON;
767 Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event )
769 Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
771 if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
773 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
775 mFocusChangedSignal.Emit( false );
778 return ECORE_CALLBACK_PASS_ON;
781 Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event )
783 Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) );
785 if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) )
787 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
789 mOutputTransformedSignal.Emit();
792 return ECORE_CALLBACK_PASS_ON;
795 Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event )
797 Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) );
799 if( ignoreTransformEvent->win == mEcoreWindow )
801 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
803 mOutputTransformedSignal.Emit();
806 return ECORE_CALLBACK_PASS_ON;
809 void WindowBaseEcoreWl::OnRotation( void* data, int type, void* event )
811 Ecore_Wl_Event_Window_Rotate* ev( static_cast< Ecore_Wl_Event_Window_Rotate* >( event ) );
813 if( ev->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
815 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnRotation\n" );
817 RotationEvent rotationEvent;
818 rotationEvent.angle = ev->angle;
819 rotationEvent.winResize = 0;
821 if( ev->angle == 0 || ev->angle == 180 )
823 rotationEvent.width = ev->w;
824 rotationEvent.height = ev->h;
828 rotationEvent.width = ev->h;
829 rotationEvent.height = ev->w;
832 mRotationSignal.Emit( rotationEvent );
836 void WindowBaseEcoreWl::OnMouseButtonDown( void* data, int type, void* event )
838 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
840 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
842 PointState::Type state ( PointState::DOWN );
844 // Check if the buttons field is set and ensure it's the primary touch button.
845 // If this event was triggered by buttons other than the primary button (used for touch), then
846 // just send an interrupted event to Core.
847 if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
849 state = PointState::INTERRUPTED;
852 Device::Class::Type deviceClass;
853 Device::Subclass::Type deviceSubclass;
855 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
856 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
858 Integration::Point point;
859 point.SetDeviceId( touchEvent->multi.device );
860 point.SetState( state );
861 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
862 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
863 point.SetPressure( touchEvent->multi.pressure );
864 point.SetAngle( Degree( touchEvent->multi.angle ) );
865 point.SetDeviceClass( deviceClass );
866 point.SetDeviceSubclass( deviceSubclass );
868 mTouchEventSignal.Emit( point, touchEvent->timestamp );
872 void WindowBaseEcoreWl::OnMouseButtonUp( void* data, int type, void* event )
874 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
876 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
878 Device::Class::Type deviceClass;
879 Device::Subclass::Type deviceSubclass;
881 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
882 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
884 Integration::Point point;
885 point.SetDeviceId( touchEvent->multi.device );
886 point.SetState( PointState::UP );
887 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
888 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
889 point.SetPressure( touchEvent->multi.pressure );
890 point.SetAngle( Degree( touchEvent->multi.angle ) );
891 point.SetDeviceClass( deviceClass );
892 point.SetDeviceSubclass( deviceSubclass );
894 mTouchEventSignal.Emit( point, touchEvent->timestamp );
898 void WindowBaseEcoreWl::OnMouseButtonMove( void* data, int type, void* event )
900 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
902 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
904 Device::Class::Type deviceClass;
905 Device::Subclass::Type deviceSubclass;
907 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
908 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
910 Integration::Point point;
911 point.SetDeviceId( touchEvent->multi.device );
912 point.SetState( PointState::MOTION );
913 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
914 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
915 point.SetPressure( touchEvent->multi.pressure );
916 point.SetAngle( Degree( touchEvent->multi.angle ) );
917 point.SetDeviceClass( deviceClass );
918 point.SetDeviceSubclass( deviceSubclass );
920 mTouchEventSignal.Emit( point, touchEvent->timestamp );
924 void WindowBaseEcoreWl::OnMouseButtonCancel( void* data, int type, void* event )
926 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
928 if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
930 Integration::Point point;
931 point.SetDeviceId( touchEvent->multi.device );
932 point.SetState( PointState::INTERRUPTED );
933 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
935 mTouchEventSignal.Emit( point, touchEvent->timestamp );
937 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" );
941 void WindowBaseEcoreWl::OnMouseWheel( void* data, int type, void* event )
943 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
945 if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
947 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 );
949 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
951 mWheelEventSignal.Emit( wheelEvent );
955 void WindowBaseEcoreWl::OnDetentRotation( void* data, int type, void* event )
957 Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
959 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" );
961 int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
962 int timeStamp = detentEvent->timestamp;
964 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2( 0.0f, 0.0f ), direction, timeStamp );
966 mWheelEventSignal.Emit( wheelEvent );
969 void WindowBaseEcoreWl::OnKeyDown( void* data, int type, void* event )
971 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
973 if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
975 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" );
977 std::string keyName( keyEvent->keyname );
978 std::string logicalKey( "" );
979 std::string keyString( "" );
980 std::string compose( "" );
982 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
983 if( keyEvent->compose )
985 compose = keyEvent->compose;
988 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
991 logicalKey = keyEvent->key;
994 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
995 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
996 int modifier( keyEvent->modifiers );
997 unsigned long time = keyEvent->timestamp;
998 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1000 keyCode = atoi( keyEvent->keyname + 8 );
1003 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1004 if( keyEvent->string )
1006 keyString = keyEvent->string;
1009 std::string deviceName;
1010 Device::Class::Type deviceClass;
1011 Device::Subclass::Type deviceSubclass;
1013 GetDeviceName( keyEvent, deviceName );
1014 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1015 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1017 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, deviceName, deviceClass, deviceSubclass );
1019 mKeyEventSignal.Emit( keyEvent );
1023 void WindowBaseEcoreWl::OnKeyUp( void* data, int type, void* event )
1025 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1027 if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
1029 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" );
1031 std::string keyName( keyEvent->keyname );
1032 std::string logicalKey( "" );
1033 std::string keyString( "" );
1034 std::string compose( "" );
1036 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1037 if( keyEvent->compose )
1039 compose = keyEvent->compose;
1042 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1045 logicalKey = keyEvent->key;
1048 int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1049 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1050 int modifier( keyEvent->modifiers );
1051 unsigned long time = keyEvent->timestamp;
1052 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1054 keyCode = atoi( keyEvent->keyname + 8 );
1057 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1058 if( keyEvent->string )
1060 keyString = keyEvent->string;
1063 std::string deviceName;
1064 Device::Class::Type deviceClass;
1065 Device::Subclass::Type deviceSubclass;
1067 GetDeviceName( keyEvent, deviceName );
1068 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1069 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1071 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, deviceName, deviceClass, deviceSubclass );
1073 mKeyEventSignal.Emit( keyEvent );
1077 void WindowBaseEcoreWl::OnDataSend( void* data, int type, void* event )
1079 mSelectionDataSendSignal.Emit( event );
1082 void WindowBaseEcoreWl::OnDataReceive( void* data, int type, void* event )
1084 mSelectionDataReceivedSignal.Emit( event );
1087 void WindowBaseEcoreWl::OnFontNameChanged()
1089 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1092 void WindowBaseEcoreWl::OnFontSizeChanged()
1094 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1097 void WindowBaseEcoreWl::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1099 #ifdef DALI_ELDBUS_AVAILABLE
1100 AccessibilityInfo info;
1102 // The string defines the arg-list's respective types.
1103 if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1105 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1108 mAccessibilitySignal.Emit( info );
1112 void WindowBaseEcoreWl::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1114 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1116 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1118 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1121 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1125 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1127 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1129 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1131 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1132 if( !mTizenDisplayPolicy )
1134 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1138 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1140 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1144 void WindowBaseEcoreWl::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1146 mTizenPolicy = NULL;
1147 mTizenDisplayPolicy = NULL;
1150 void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1152 mNotificationLevel = level;
1153 mNotificationChangeState = state;
1154 mNotificationLevelChangeDone = true;
1156 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1159 void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1161 mScreenOffMode = mode;
1162 mScreenOffModeChangeState = state;
1163 mScreenOffModeChangeDone = true;
1165 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1168 void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1170 mBrightness = brightness;
1171 mBrightnessChangeState = state;
1172 mBrightnessChangeDone = true;
1174 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1177 Any WindowBaseEcoreWl::GetNativeWindow()
1179 return mEcoreWindow;
1182 int WindowBaseEcoreWl::GetNativeWindowId()
1184 return ecore_wl_window_id_get( mEcoreWindow );
1187 EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow( int width, int height )
1189 mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1191 return static_cast< EGLNativeWindowType >( mEglWindow );
1194 void WindowBaseEcoreWl::DestroyEglWindow()
1196 if( mEglWindow != NULL )
1198 wl_egl_window_destroy( mEglWindow );
1203 void WindowBaseEcoreWl::SetEglWindowRotation( int angle )
1205 wl_egl_window_rotation rotation;
1211 rotation = ROTATION_0;
1216 rotation = ROTATION_270;
1221 rotation = ROTATION_180;
1226 rotation = ROTATION_90;
1231 rotation = ROTATION_0;
1236 wl_egl_window_set_rotation( mEglWindow, rotation );
1239 void WindowBaseEcoreWl::SetEglWindowBufferTransform( int angle )
1241 wl_output_transform bufferTransform;
1247 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1252 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1257 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1262 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1267 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1272 wl_egl_window_set_buffer_transform( mEglWindow, bufferTransform );
1275 void WindowBaseEcoreWl::SetEglWindowTransform( int angle )
1277 wl_output_transform windowTransform;
1283 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1288 windowTransform = WL_OUTPUT_TRANSFORM_90;
1293 windowTransform = WL_OUTPUT_TRANSFORM_180;
1298 windowTransform = WL_OUTPUT_TRANSFORM_270;
1303 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1308 wl_egl_window_set_window_transform( mEglWindow, windowTransform );
1311 void WindowBaseEcoreWl::ResizeEglWindow( PositionSize positionSize )
1313 wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1316 bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
1319 wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) );
1320 if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED )
1322 mSupportedPreProtation = true;
1325 mSupportedPreProtation = false;
1329 void WindowBaseEcoreWl::Move( PositionSize positionSize )
1331 ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1334 void WindowBaseEcoreWl::Resize( PositionSize positionSize )
1336 ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
1339 void WindowBaseEcoreWl::MoveResize( PositionSize positionSize )
1341 ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1342 ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
1345 void WindowBaseEcoreWl::SetClass( const std::string& name, const std::string& className )
1347 ecore_wl_window_title_set( mEcoreWindow, name.c_str() );
1348 ecore_wl_window_class_name_set( mEcoreWindow, className.c_str() );
1351 void WindowBaseEcoreWl::Raise()
1353 // Use ecore_wl_window_activate to prevent the window shown without rendering
1354 ecore_wl_window_activate( mEcoreWindow );
1357 void WindowBaseEcoreWl::Lower()
1359 ecore_wl_window_lower( mEcoreWindow );
1362 void WindowBaseEcoreWl::Activate()
1364 ecore_wl_window_activate( mEcoreWindow );
1367 void WindowBaseEcoreWl::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
1369 int rotations[4] = { 0 };
1370 for( std::size_t i = 0; i < orientations.size(); ++i )
1372 rotations[i] = static_cast< int >( orientations[i] );
1374 ecore_wl_window_rotation_available_rotations_set( mEcoreWindow, rotations, orientations.size() );
1377 void WindowBaseEcoreWl::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
1379 ecore_wl_window_rotation_preferred_rotation_set( mEcoreWindow, orientation );
1382 void WindowBaseEcoreWl::SetAcceptFocus( bool accept )
1384 ecore_wl_window_focus_skip_set( mEcoreWindow, !accept );
1387 void WindowBaseEcoreWl::Show()
1389 ecore_wl_window_show( mEcoreWindow );
1392 void WindowBaseEcoreWl::Hide()
1394 ecore_wl_window_hide( mEcoreWindow );
1397 unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
1399 return mSupportedAuxiliaryHints.size();
1402 std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint( unsigned int index ) const
1404 if( index >= GetSupportedAuxiliaryHintCount() )
1406 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1409 return mSupportedAuxiliaryHints[index];
1412 unsigned int WindowBaseEcoreWl::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1414 bool supported = false;
1416 // Check if the hint is suppported
1417 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1428 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1432 // Check if the hint is already added
1433 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1435 if( mAuxiliaryHints[i].first == hint )
1437 // Just change the value
1438 mAuxiliaryHints[i].second = value;
1440 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1442 return i + 1; // id is index + 1
1447 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1449 unsigned int id = mAuxiliaryHints.size();
1451 ecore_wl_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1453 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1458 bool WindowBaseEcoreWl::RemoveAuxiliaryHint( unsigned int id )
1460 if( id == 0 || id > mAuxiliaryHints.size() )
1462 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1466 mAuxiliaryHints[id - 1].second = std::string();
1468 ecore_wl_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1470 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1475 bool WindowBaseEcoreWl::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1477 if( id == 0 || id > mAuxiliaryHints.size() )
1479 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1483 mAuxiliaryHints[id - 1].second = value;
1485 ecore_wl_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1487 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() );
1492 std::string WindowBaseEcoreWl::GetAuxiliaryHintValue( unsigned int id ) const
1494 if( id == 0 || id > mAuxiliaryHints.size() )
1496 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1497 return std::string();
1500 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() );
1502 return mAuxiliaryHints[id - 1].second;
1505 unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId( const std::string& hint ) const
1507 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1509 if( mAuxiliaryHints[i].first == hint )
1511 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1516 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1521 void WindowBaseEcoreWl::SetInputRegion( const Rect< int >& inputRegion )
1523 ecore_wl_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1526 void WindowBaseEcoreWl::SetType( Dali::Window::Type type )
1528 Ecore_Wl_Window_Type windowType;
1532 case Dali::Window::NORMAL:
1534 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1537 case Dali::Window::NOTIFICATION:
1539 windowType = ECORE_WL_WINDOW_TYPE_NOTIFICATION;
1542 case Dali::Window::UTILITY:
1544 windowType = ECORE_WL_WINDOW_TYPE_UTILITY;
1547 case Dali::Window::DIALOG:
1549 windowType = ECORE_WL_WINDOW_TYPE_DIALOG;
1554 windowType = ECORE_WL_WINDOW_TYPE_TOPLEVEL;
1559 ecore_wl_window_type_set( mEcoreWindow, windowType );
1562 bool WindowBaseEcoreWl::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
1564 while( !mTizenPolicy )
1566 wl_display_dispatch_queue( mDisplay, mEventQueue );
1569 int notificationLevel;
1573 case Dali::Window::NotificationLevel::NONE:
1575 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1578 case Dali::Window::NotificationLevel::BASE:
1580 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1583 case Dali::Window::NotificationLevel::MEDIUM:
1585 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1588 case Dali::Window::NotificationLevel::HIGH:
1590 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1593 case Dali::Window::NotificationLevel::TOP:
1595 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1600 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level );
1601 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1606 mNotificationLevelChangeDone = false;
1607 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1609 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), notificationLevel );
1613 while( !mNotificationLevelChangeDone && count < 3 )
1616 wl_display_dispatch_queue( mDisplay, mEventQueue );
1620 if( !mNotificationLevelChangeDone )
1622 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1625 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1627 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level );
1631 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1636 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl::GetNotificationLevel() const
1638 while( !mTizenPolicy )
1640 wl_display_dispatch_queue( mDisplay, mEventQueue );
1645 while( !mNotificationLevelChangeDone && count < 3 )
1648 wl_display_dispatch_queue( mDisplay, mEventQueue );
1652 if( !mNotificationLevelChangeDone )
1654 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1655 return Dali::Window::NotificationLevel::NONE;
1658 Dali::Window::NotificationLevel::Type level;
1660 switch( mNotificationLevel )
1662 case TIZEN_POLICY_LEVEL_NONE:
1664 level = Dali::Window::NotificationLevel::NONE;
1667 case TIZEN_POLICY_LEVEL_DEFAULT:
1669 level = Dali::Window::NotificationLevel::BASE;
1672 case TIZEN_POLICY_LEVEL_MEDIUM:
1674 level = Dali::Window::NotificationLevel::MEDIUM;
1677 case TIZEN_POLICY_LEVEL_HIGH:
1679 level = Dali::Window::NotificationLevel::HIGH;
1682 case TIZEN_POLICY_LEVEL_TOP:
1684 level = Dali::Window::NotificationLevel::TOP;
1689 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1690 level = Dali::Window::NotificationLevel::NONE;
1695 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1700 void WindowBaseEcoreWl::SetOpaqueState( bool opaque )
1702 while( !mTizenPolicy )
1704 wl_display_dispatch_queue( mDisplay, mEventQueue );
1707 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1710 bool WindowBaseEcoreWl::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
1712 while( !mTizenPolicy )
1714 wl_display_dispatch_queue( mDisplay, mEventQueue );
1717 mScreenOffModeChangeDone = false;
1718 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1720 unsigned int mode = 0;
1722 switch( screenOffMode )
1724 case Dali::Window::ScreenOffMode::TIMEOUT:
1729 case Dali::Window::ScreenOffMode::NEVER:
1736 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), mode );
1740 while( !mScreenOffModeChangeDone && count < 3 )
1743 wl_display_dispatch_queue( mDisplay, mEventQueue );
1747 if( !mScreenOffModeChangeDone )
1749 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
1752 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1754 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
1758 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
1763 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl::GetScreenOffMode() const
1765 while( !mTizenPolicy )
1767 wl_display_dispatch_queue( mDisplay, mEventQueue );
1772 while( !mScreenOffModeChangeDone && count < 3 )
1775 wl_display_dispatch_queue( mDisplay, mEventQueue );
1779 if( !mScreenOffModeChangeDone )
1781 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
1782 return Dali::Window::ScreenOffMode::TIMEOUT;
1785 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1787 switch( mScreenOffMode )
1791 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
1796 screenMode = Dali::Window::ScreenOffMode::NEVER;
1801 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
1806 bool WindowBaseEcoreWl::SetBrightness( int brightness )
1808 while( !mTizenDisplayPolicy )
1810 wl_display_dispatch_queue( mDisplay, mEventQueue );
1813 mBrightnessChangeDone = false;
1814 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1816 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl_window_surface_get( mEcoreWindow ), brightness );
1820 while( !mBrightnessChangeDone && count < 3 )
1823 wl_display_dispatch_queue( mDisplay, mEventQueue );
1827 if( !mBrightnessChangeDone )
1829 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
1832 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1834 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness );
1838 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness );
1843 int WindowBaseEcoreWl::GetBrightness() const
1845 while( !mTizenDisplayPolicy )
1847 wl_display_dispatch_queue( mDisplay, mEventQueue );
1852 while( !mBrightnessChangeDone && count < 3 )
1855 wl_display_dispatch_queue( mDisplay, mEventQueue );
1859 if( !mBrightnessChangeDone )
1861 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
1865 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness );
1870 bool WindowBaseEcoreWl::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
1872 Ecore_Wl_Window_Keygrab_Mode mode;
1876 case KeyGrab::TOPMOST:
1878 mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1881 case KeyGrab::SHARED:
1883 mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1886 case KeyGrab::OVERRIDE_EXCLUSIVE:
1888 mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1891 case KeyGrab::EXCLUSIVE:
1893 mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1902 return ecore_wl_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
1905 bool WindowBaseEcoreWl::UngrabKey( Dali::KEY key )
1907 return ecore_wl_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
1910 bool WindowBaseEcoreWl::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
1912 int keyCount = key.Count();
1913 int keyGrabModeCount = grabMode.Count();
1915 if( keyCount != keyGrabModeCount || keyCount == 0 )
1922 Eina_List* keyList = NULL;
1923 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
1925 for( int index = 0; index < keyCount; ++index )
1927 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
1929 switch( grabMode[index] )
1931 case KeyGrab::TOPMOST:
1933 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
1936 case KeyGrab::SHARED:
1938 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
1941 case KeyGrab::OVERRIDE_EXCLUSIVE:
1943 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
1946 case KeyGrab::EXCLUSIVE:
1948 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
1953 info[index].mode = ECORE_WL_WINDOW_KEYGRAB_UNKNOWN;
1958 keyList = eina_list_append( keyList, &info );
1961 Eina_List* grabList = ecore_wl_window_keygrab_list_set( mEcoreWindow, keyList );
1963 result.Resize( keyCount, true );
1965 Eina_List* l = NULL;
1966 Eina_List* m = NULL;
1967 void* listData = NULL;
1969 if( grabList != NULL )
1971 EINA_LIST_FOREACH( grabList, m, data )
1974 EINA_LIST_FOREACH( keyList, l, listData )
1976 if( static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key == NULL )
1978 DALI_LOG_ERROR( "input key list has null data!" );
1982 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
1984 result[index] = false;
1993 eina_list_free( keyList );
1994 eina_list_free( grabList );
2000 bool WindowBaseEcoreWl::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2002 int keyCount = key.Count();
2010 Eina_List* keyList = NULL;
2011 Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
2013 for( int index = 0; index < keyCount; ++index )
2015 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2016 keyList = eina_list_append( keyList, &info );
2019 Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset( mEcoreWindow, keyList );
2021 result.Resize( keyCount, true );
2023 Eina_List* l = NULL;
2024 Eina_List* m = NULL;
2025 void *listData = NULL;
2028 if( ungrabList != NULL )
2030 EINA_LIST_FOREACH( ungrabList, m, data )
2033 EINA_LIST_FOREACH( keyList, l, listData )
2035 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
2037 result[index] = false;
2046 eina_list_free( keyList );
2047 eina_list_free( ungrabList );
2053 void WindowBaseEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2058 // 1 inch = 25.4 millimeters
2059 xres = ecore_wl_dpi_get();
2060 yres = ecore_wl_dpi_get();
2062 dpiHorizontal = int( xres + 0.5f ); // rounding
2063 dpiVertical = int( yres + 0.5f );
2066 int WindowBaseEcoreWl::GetOrientation() const
2068 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2069 if( mSupportedPreProtation )
2076 int WindowBaseEcoreWl::GetScreenRotationAngle()
2080 if( ecore_wl_window_ignore_output_transform_get( mEcoreWindow ) )
2086 transform = ecore_wl_output_transform_get( ecore_wl_window_output_find( mEcoreWindow ) );
2089 mScreenRotationAngle = transform * 90;
2090 return mScreenRotationAngle;
2093 void WindowBaseEcoreWl::SetWindowRotationAngle( int degree )
2095 mWindowRotationAngle = degree;
2096 ecore_wl_window_rotation_set( mEcoreWindow, degree );
2099 int WindowBaseEcoreWl::GetWindowRotationAngle()
2101 return mWindowRotationAngle;
2104 void WindowBaseEcoreWl::WindowRotationCompleted( int degree, int width, int height )
2106 ecore_wl_window_rotation_change_done_send( mEcoreWindow );
2109 void WindowBaseEcoreWl::SetTransparency( bool transparent )
2111 ecore_wl_window_alpha_set( mEcoreWindow, transparent );
2114 void WindowBaseEcoreWl::InitializeEcoreElDBus()
2116 #ifdef DALI_ELDBUS_AVAILABLE
2117 Eldbus_Object* object;
2118 Eldbus_Proxy* manager;
2120 if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2122 DALI_LOG_ERROR( "Unable to get system bus\n" );
2125 object = eldbus_object_get( mSystemConnection, BUS, PATH );
2128 DALI_LOG_ERROR( "Getting object failed\n" );
2132 manager = eldbus_proxy_get( object, INTERFACE );
2135 DALI_LOG_ERROR( "Getting proxy failed\n" );
2139 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2141 DALI_LOG_ERROR( "No signal handler returned\n" );
2146 void WindowBaseEcoreWl::CreateWindow( PositionSize positionSize )
2148 mEcoreWindow = ecore_wl_window_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW );
2150 if ( mEcoreWindow == 0 )
2152 DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2156 void WindowBaseEcoreWl::SetParent( WindowBase* parentWinBase )
2158 Ecore_Wl_Window* ecoreParent = NULL;
2161 WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>( parentWinBase );
2162 ecoreParent = winBaseEcore->mEcoreWindow;
2164 ecore_wl_window_parent_set( mEcoreWindow, ecoreParent );
2167 } // namespace Adaptor
2169 } // namespace Internal
2173 #pragma GCC diagnostic pop