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-wl2/window-base-ecore-wl2.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/public-api/events/mouse-button.h>
34 #include <dali/integration-api/debug.h>
35 #include <Ecore_Input.h>
37 #include <vconf-keys.h>
38 #include <wayland-egl-tizen.h>
52 #if defined(DEBUG_ENABLED)
53 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
56 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
57 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
59 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
62 const char* BUS = "org.enlightenment.wm-screen-reader";
63 const char* INTERFACE = "org.tizen.GestureNavigation";
64 const char* PATH = "/org/tizen/GestureNavigation";
69 xkb_keycode_t keyCode;
74 * Get the device name from the provided ecore key event
76 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
78 const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
82 result = ecoreDeviceName;
87 * Get the device class from the provided ecore event
89 void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
91 switch( ecoreDeviceClass )
93 case ECORE_DEVICE_CLASS_SEAT:
95 deviceClass = Device::Class::USER;
98 case ECORE_DEVICE_CLASS_KEYBOARD:
100 deviceClass = Device::Class::KEYBOARD;
103 case ECORE_DEVICE_CLASS_MOUSE:
105 deviceClass = Device::Class::MOUSE;
108 case ECORE_DEVICE_CLASS_TOUCH:
110 deviceClass = Device::Class::TOUCH;
113 case ECORE_DEVICE_CLASS_PEN:
115 deviceClass = Device::Class::PEN;
118 case ECORE_DEVICE_CLASS_POINTER:
120 deviceClass = Device::Class::POINTER;
123 case ECORE_DEVICE_CLASS_GAMEPAD:
125 deviceClass = Device::Class::GAMEPAD;
130 deviceClass = Device::Class::NONE;
136 void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
138 switch( ecoreDeviceSubclass )
140 case ECORE_DEVICE_SUBCLASS_FINGER:
142 deviceSubclass = Device::Subclass::FINGER;
145 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
147 deviceSubclass = Device::Subclass::FINGERNAIL;
150 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
152 deviceSubclass = Device::Subclass::KNUCKLE;
155 case ECORE_DEVICE_SUBCLASS_PALM:
157 deviceSubclass = Device::Subclass::PALM;
160 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
162 deviceSubclass = Device::Subclass::HAND_SIDE;
165 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
167 deviceSubclass = Device::Subclass::HAND_FLAT;
170 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
172 deviceSubclass = Device::Subclass::PEN_TIP;
175 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
177 deviceSubclass = Device::Subclass::TRACKPAD;
180 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
182 deviceSubclass = Device::Subclass::TRACKPOINT;
185 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
187 deviceSubclass = Device::Subclass::TRACKBALL;
190 case ECORE_DEVICE_SUBCLASS_REMOCON:
192 deviceSubclass = Device::Subclass::REMOCON;
195 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
197 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
202 deviceSubclass = Device::Subclass::NONE;
209 void FindKeyCode( struct xkb_keymap* keyMap, xkb_keycode_t key, void* data )
211 KeyCodeMap* foundKeyCode = static_cast< KeyCodeMap* >( data );
212 if( foundKeyCode->isKeyCode )
217 xkb_keysym_t keySym = foundKeyCode->keySym;
219 const xkb_keysym_t* symsOut = NULL;
221 nsyms = xkb_keymap_key_get_syms_by_level( keyMap, key, 0, 0, &symsOut );
223 if( nsyms && symsOut )
225 if( *symsOut == keySym )
227 foundKeyCode->keyCode = key;
228 foundKeyCode->isKeyCode = true;
233 /////////////////////////////////////////////////////////////////////////////////////////////////
235 /////////////////////////////////////////////////////////////////////////////////////////////////
237 /// Called when the window iconify state is changed.
238 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
240 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
243 return windowBase->OnIconifyStateChanged( data, type, event );
246 return ECORE_CALLBACK_PASS_ON;
249 /// Called when the window gains focus
250 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
252 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
255 return windowBase->OnFocusIn( data, type, event );
258 return ECORE_CALLBACK_PASS_ON;
261 /// Called when the window loses focus
262 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
264 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
267 return windowBase->OnFocusOut( data, type, event );
270 return ECORE_CALLBACK_PASS_ON;
273 /// Called when the output is transformed
274 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
276 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
279 return windowBase->OnOutputTransform( data, type, event );
282 return ECORE_CALLBACK_PASS_ON;
285 /// Called when the output transform should be ignored
286 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
288 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
291 return windowBase->OnIgnoreOutputTransform( data, type, event );
294 return ECORE_CALLBACK_PASS_ON;
298 * Called when rotate event is recevied.
300 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
302 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
305 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::EcoreEventRotate\n" );
306 windowBase->OnRotation( data, type, event );
308 return ECORE_CALLBACK_PASS_ON;
312 * Called when configure event is recevied.
314 static Eina_Bool EcoreEventConfigure( void* data, int type, void* event )
316 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
319 windowBase->OnConfiguration( data, type, event );
321 return ECORE_CALLBACK_PASS_ON;
324 /////////////////////////////////////////////////////////////////////////////////////////////////
326 /////////////////////////////////////////////////////////////////////////////////////////////////
329 * Called when a touch down is received.
331 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
333 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
336 windowBase->OnMouseButtonDown( data, type, event );
338 return ECORE_CALLBACK_PASS_ON;
342 * Called when a touch up is received.
344 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
346 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
349 windowBase->OnMouseButtonUp( data, type, event );
351 return ECORE_CALLBACK_PASS_ON;
355 * Called when a touch motion is received.
357 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
359 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
362 windowBase->OnMouseButtonMove( data, type, event );
364 return ECORE_CALLBACK_PASS_ON;
368 * Called when a touch is canceled.
370 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
372 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
375 windowBase->OnMouseButtonCancel( data, type, event );
377 return ECORE_CALLBACK_PASS_ON;
381 * Called when a mouse wheel is received.
383 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
385 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
388 windowBase->OnMouseWheel( data, type, event );
390 return ECORE_CALLBACK_PASS_ON;
394 * Called when a detent rotation event is recevied.
396 static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
398 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
401 windowBase->OnDetentRotation( data, type, event );
403 return ECORE_CALLBACK_PASS_ON;
406 /////////////////////////////////////////////////////////////////////////////////////////////////
408 /////////////////////////////////////////////////////////////////////////////////////////////////
411 * Called when a key down is received.
413 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
415 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
418 windowBase->OnKeyDown( data, type, event );
420 return ECORE_CALLBACK_PASS_ON;
424 * Called when a key up is received.
426 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
428 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
431 windowBase->OnKeyUp( data, type, event );
433 return ECORE_CALLBACK_PASS_ON;
436 /////////////////////////////////////////////////////////////////////////////////////////////////
437 // Selection Callbacks
438 /////////////////////////////////////////////////////////////////////////////////////////////////
441 * Called when the source window notifies us the content in clipboard is selected.
443 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
445 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
448 windowBase->OnDataSend( data, type, event );
450 return ECORE_CALLBACK_PASS_ON;
454 * Called when the source window sends us about the selected content.
455 * For example, when item is selected in the clipboard.
457 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
459 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
462 windowBase->OnDataReceive( data, type, event );
464 return ECORE_CALLBACK_PASS_ON;
467 /////////////////////////////////////////////////////////////////////////////////////////////////
468 // Effect Start/End Callbacks
469 /////////////////////////////////////////////////////////////////////////////////////////////////
472 * Called when transition animation of the window's shown/hidden is started by window manager.
474 static Eina_Bool EcoreEventEffectStart(void *data, int type, void *event)
476 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
477 Ecore_Wl2_Event_Effect_Start *effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
478 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type );
481 if( effectStart->type < 3 ) // only under restack
483 windowBase->OnTransitionEffectEvent( DevelWindow::EffectState::START, static_cast<DevelWindow::EffectType>( effectStart->type ) );
486 return ECORE_CALLBACK_PASS_ON;
490 * Called when transition animation of the window's shown/hidden is ended by window manager.
492 static Eina_Bool EcoreEventEffectEnd(void *data, int type, void *event)
494 Ecore_Wl2_Event_Effect_Start *effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
495 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
496 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type );
499 if( effectEnd->type < 3 ) // only under restack
501 windowBase->OnTransitionEffectEvent( DevelWindow::EffectState::END, static_cast<DevelWindow::EffectType>( effectEnd->type ) );
504 return ECORE_CALLBACK_PASS_ON;
507 /////////////////////////////////////////////////////////////////////////////////////////////////
508 // Keyboard Repeat Settings Changed Callbacks
509 /////////////////////////////////////////////////////////////////////////////////////////////////
511 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void *data, int type, void *event)
513 Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed *keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>( event );
514 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
515 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id );
518 windowBase->OnKeyboardRepeatSettingsChanged();
521 return ECORE_CALLBACK_RENEW;
524 /////////////////////////////////////////////////////////////////////////////////////////////////
525 // Keymap Changed Callbacks
526 /////////////////////////////////////////////////////////////////////////////////////////////////
528 static Eina_Bool EcoreEventSeatKeymapChanged(void *data, int type, void *event)
530 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
533 windowBase->KeymapChanged( data, type, event );
536 return ECORE_CALLBACK_RENEW;
539 /////////////////////////////////////////////////////////////////////////////////////////////////
541 /////////////////////////////////////////////////////////////////////////////////////////////////
544 * Called when a font name is changed.
546 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
548 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
551 windowBase->OnFontNameChanged();
556 * Called when a font size is changed.
558 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
560 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
563 windowBase->OnFontSizeChanged();
567 /////////////////////////////////////////////////////////////////////////////////////////////////
568 // ElDBus Accessibility Callbacks
569 /////////////////////////////////////////////////////////////////////////////////////////////////
571 #ifdef DALI_ELDBUS_AVAILABLE
572 // Callback for Ecore ElDBus accessibility events.
573 static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
575 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( context );
578 windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
581 #endif // DALI_ELDBUS_AVAILABLE
583 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
585 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
588 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
592 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
594 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
597 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
601 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
605 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 )
609 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
611 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
614 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
618 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
622 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
624 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
627 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
631 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
635 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
639 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
643 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
647 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 )
651 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
653 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
656 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
660 const struct wl_registry_listener registryListener =
662 RegistryGlobalCallback,
663 RegistryGlobalCallbackRemove
666 const struct tizen_policy_listener tizenPolicyListener =
668 TizenPolicyConformant,
669 TizenPolicyConformantArea,
670 TizenPolicyNotificationChangeDone,
671 TizenPolicyTransientForDone,
672 TizenPolicyScreenModeChangeDone,
673 TizenPolicyIconifyStateChanged,
674 TizenPolicySupportedAuxiliaryHints,
675 TizenPolicyAllowedAuxiliaryHint,
676 TizenPolicyAuxiliaryMessage,
677 TizenPolicyConformantRegion
680 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
682 DisplayPolicyBrightnessChangeDone
685 } // unnamed namespace
687 WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any surface, bool isTransparent )
688 : mEcoreEventHandler(),
689 mEcoreWindow( NULL ),
694 mTizenPolicy( NULL ),
695 mTizenDisplayPolicy( NULL ),
697 mSupportedAuxiliaryHints(),
699 mNotificationLevel( -1 ),
700 mNotificationChangeState( 0 ),
701 mNotificationLevelChangeDone( true ),
703 mScreenOffModeChangeState( 0 ),
704 mScreenOffModeChangeDone( true ),
706 mBrightnessChangeState( 0 ),
707 mBrightnessChangeDone( true ),
709 mWindowPositionSize( positionSize ),
710 mOwnSurface( false ),
711 mMoveResizeSerial( 0 ),
712 mLastSubmittedMoveResizeSerial( 0 ),
713 mWindowRotationAngle( 0 ),
714 mScreenRotationAngle( 0 ),
715 mSupportedPreProtation( 0 )
716 #ifdef DALI_ELDBUS_AVAILABLE
717 , mSystemConnection( NULL )
720 Initialize( positionSize, surface, isTransparent );
723 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
725 #ifdef DALI_ELDBUS_AVAILABLE
726 // Close down ElDBus connections.
727 if( mSystemConnection )
729 eldbus_connection_unref( mSystemConnection );
731 #endif // DALI_ELDBUS_AVAILABLE
733 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
734 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
736 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
738 ecore_event_handler_del( *iter );
740 mEcoreEventHandler.Clear();
744 wl_event_queue_destroy( mEventQueue );
747 mSupportedAuxiliaryHints.clear();
748 mAuxiliaryHints.clear();
750 if( mEglWindow != NULL )
752 wl_egl_window_destroy( mEglWindow );
758 ecore_wl2_window_free( mEcoreWindow );
760 WindowSystem::Shutdown();
764 void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
766 if( surface.Empty() == false )
768 // check we have a valid type
769 DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl2_Window *) ) && "Surface type is invalid" );
771 mEcoreWindow = AnyCast< Ecore_Wl2_Window* >( surface );
775 // we own the surface about to created
776 WindowSystem::Initialize();
779 CreateWindow( positionSize );
782 mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
784 SetTransparency( isTransparent );
786 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
787 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
788 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
789 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
790 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
792 // Register Rotate event
793 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
795 // Register Configure event
796 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this ) );
798 // Register Touch events
799 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
800 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
801 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
802 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
804 // Register Mouse wheel events
805 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
807 // Register Detent event
808 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
810 // Register Key events
811 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
812 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
814 // Register Selection event - clipboard selection
815 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
816 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
818 // Register Effect Start/End event
819 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this ) );
820 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this ) );
822 // Register Keyboard repeat event
823 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this ) );
825 // Register Vconf notify - font name and size
826 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
827 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
829 InitializeEcoreElDBus();
831 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
832 mDisplay = ecore_wl2_display_get( display );
836 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
839 mEventQueue = wl_display_create_queue( mDisplay );
842 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
844 wl_registry* registry = wl_display_get_registry( displayWrapper );
845 wl_registry_add_listener( registry, ®istryListener, this );
848 wl_proxy_wrapper_destroy( displayWrapper );
852 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( display );
856 mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
858 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this ) );
861 // get auxiliary hint
862 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
868 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) ) ) )
870 mSupportedAuxiliaryHints.push_back( hint );
872 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
877 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
879 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
880 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
882 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
884 if( iconifyChangedEvent->iconified == EINA_TRUE )
886 mIconifyChangedSignal.Emit( true );
890 mIconifyChangedSignal.Emit( false );
892 handled = ECORE_CALLBACK_DONE;
898 Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
900 Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
902 if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
904 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
906 mFocusChangedSignal.Emit( true );
909 return ECORE_CALLBACK_PASS_ON;
912 Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
914 Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
916 if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
918 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
920 mFocusChangedSignal.Emit( false );
923 return ECORE_CALLBACK_PASS_ON;
926 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
928 Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
930 if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
932 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
934 mOutputTransformedSignal.Emit();
937 return ECORE_CALLBACK_PASS_ON;
940 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
942 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
944 if( ignoreTransformEvent->win == mEcoreWindow )
946 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
948 mOutputTransformedSignal.Emit();
951 return ECORE_CALLBACK_PASS_ON;
954 void WindowBaseEcoreWl2::OnRotation( void* data, int type, void* event )
956 Ecore_Wl2_Event_Window_Rotation* ev( static_cast< Ecore_Wl2_Event_Window_Rotation* >( event ) );
958 if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
960 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h );
962 RotationEvent rotationEvent;
963 rotationEvent.angle = ev->angle;
964 rotationEvent.winResize = 0;
966 if( ev->angle == 0 || ev->angle == 180 )
968 rotationEvent.width = ev->w;
969 rotationEvent.height = ev->h;
973 rotationEvent.width = ev->h;
974 rotationEvent.height = ev->w;
977 mWindowPositionSize.width = rotationEvent.width;
978 mWindowPositionSize.height = rotationEvent.height;
980 mRotationSignal.Emit( rotationEvent );
984 void WindowBaseEcoreWl2::OnConfiguration( void* data, int type, void* event )
986 Ecore_Wl2_Event_Window_Configure* ev( static_cast< Ecore_Wl2_Event_Window_Configure* >( event ) );
988 if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
990 // Note: To comply with the wayland protocol, Dali should make an ack_configure
991 // by calling ecore_wl2_window_commit
992 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
996 void WindowBaseEcoreWl2::OnMouseButtonDown( void* data, int type, void* event )
998 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1000 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1002 Device::Class::Type deviceClass;
1003 Device::Subclass::Type deviceSubclass;
1005 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1006 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1008 PointState::Type state ( PointState::DOWN );
1010 if( deviceClass != Device::Class::Type::MOUSE )
1012 // Check if the buttons field is set and ensure it's the primary touch button.
1013 // If this event was triggered by buttons other than the primary button (used for touch), then
1014 // just send an interrupted event to Core.
1015 if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
1017 state = PointState::INTERRUPTED;
1021 Integration::Point point;
1022 point.SetDeviceId( touchEvent->multi.device );
1023 point.SetState( state );
1024 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1025 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1026 point.SetPressure( touchEvent->multi.pressure );
1027 point.SetAngle( Degree( touchEvent->multi.angle ) );
1028 point.SetDeviceClass( deviceClass );
1029 point.SetDeviceSubclass( deviceSubclass );
1030 point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1032 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1036 void WindowBaseEcoreWl2::OnMouseButtonUp( void* data, int type, void* event )
1038 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1040 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1042 Device::Class::Type deviceClass;
1043 Device::Subclass::Type deviceSubclass;
1045 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1046 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1048 Integration::Point point;
1049 point.SetDeviceId( touchEvent->multi.device );
1050 point.SetState( PointState::UP );
1051 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1052 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1053 point.SetPressure( touchEvent->multi.pressure );
1054 point.SetAngle( Degree( touchEvent->multi.angle ) );
1055 point.SetDeviceClass( deviceClass );
1056 point.SetDeviceSubclass( deviceSubclass );
1057 point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1059 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1063 void WindowBaseEcoreWl2::OnMouseButtonMove( void* data, int type, void* event )
1065 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
1067 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1069 Device::Class::Type deviceClass;
1070 Device::Subclass::Type deviceSubclass;
1072 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1073 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1075 Integration::Point point;
1076 point.SetDeviceId( touchEvent->multi.device );
1077 point.SetState( PointState::MOTION );
1078 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1079 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1080 point.SetPressure( touchEvent->multi.pressure );
1081 point.SetAngle( Degree( touchEvent->multi.angle ) );
1082 point.SetDeviceClass( deviceClass );
1083 point.SetDeviceSubclass( deviceSubclass );
1085 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1089 void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event )
1091 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1093 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1095 Integration::Point point;
1096 point.SetDeviceId( touchEvent->multi.device );
1097 point.SetState( PointState::INTERRUPTED );
1098 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
1100 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1102 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" );
1106 void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
1108 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
1110 if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1112 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
1114 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
1116 mWheelEventSignal.Emit( wheelEvent );
1120 void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event )
1122 Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
1124 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n" );
1126 int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
1127 int timeStamp = detentEvent->timestamp;
1129 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2( 0.0f, 0.0f ), 0, timeStamp );
1131 mWheelEventSignal.Emit( wheelEvent );
1134 void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event )
1136 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1138 if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1140 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n" );
1142 std::string keyName( keyEvent->keyname );
1143 std::string logicalKey( "" );
1144 std::string keyString( "" );
1145 std::string compose( "" );
1147 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1148 if( keyEvent->compose )
1150 compose = keyEvent->compose;
1153 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1156 logicalKey = keyEvent->key;
1160 GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1164 // Get a specific key code from dali key look up table.
1165 keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1168 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1169 int modifier( keyEvent->modifiers );
1170 unsigned long time = keyEvent->timestamp;
1171 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1173 keyCode = atoi( keyEvent->keyname + 8 );
1176 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1177 if( keyEvent->string )
1179 keyString = keyEvent->string;
1182 std::string deviceName;
1183 Device::Class::Type deviceClass;
1184 Device::Subclass::Type deviceSubclass;
1186 GetDeviceName( keyEvent, deviceName );
1187 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1188 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1190 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, deviceName, deviceClass, deviceSubclass );
1192 mKeyEventSignal.Emit( keyEvent );
1196 void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event )
1198 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1200 if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1202 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n" );
1204 std::string keyName( keyEvent->keyname );
1205 std::string logicalKey( "" );
1206 std::string keyString( "" );
1207 std::string compose( "" );
1209 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1210 if( keyEvent->compose )
1212 compose = keyEvent->compose;
1215 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1218 logicalKey = keyEvent->key;
1222 GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1226 // Get a specific key code from dali key look up table.
1227 keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1230 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1231 int modifier( keyEvent->modifiers );
1232 unsigned long time = keyEvent->timestamp;
1233 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1235 keyCode = atoi( keyEvent->keyname + 8 );
1238 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1239 if( keyEvent->string )
1241 keyString = keyEvent->string;
1244 std::string deviceName;
1245 Device::Class::Type deviceClass;
1246 Device::Subclass::Type deviceSubclass;
1248 GetDeviceName( keyEvent, deviceName );
1249 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1250 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1252 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, deviceName, deviceClass, deviceSubclass );
1254 mKeyEventSignal.Emit( keyEvent );
1258 void WindowBaseEcoreWl2::OnDataSend( void* data, int type, void* event )
1260 mSelectionDataSendSignal.Emit( event );
1263 void WindowBaseEcoreWl2::OnDataReceive( void* data, int type, void* event )
1265 mSelectionDataReceivedSignal.Emit( event );
1268 void WindowBaseEcoreWl2::OnFontNameChanged()
1270 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1273 void WindowBaseEcoreWl2::OnFontSizeChanged()
1275 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1278 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1280 #ifdef DALI_ELDBUS_AVAILABLE
1281 AccessibilityInfo info;
1283 // The string defines the arg-list's respective types.
1284 if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1286 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1289 mAccessibilitySignal.Emit( info );
1293 void WindowBaseEcoreWl2::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
1295 mTransitionEffectEventSignal.Emit( state, type );
1298 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1300 mKeyboardRepeatSettingsChangedSignal.Emit();
1303 void WindowBaseEcoreWl2::KeymapChanged(void *data, int type, void *event)
1305 Ecore_Wl2_Event_Seat_Keymap_Changed *changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>( event );
1306 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id );
1307 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( changed->display );
1310 mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
1314 void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1316 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1318 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1320 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1323 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1327 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1329 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1331 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1333 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1334 if( !mTizenDisplayPolicy )
1336 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1340 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1342 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1346 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1348 mTizenPolicy = NULL;
1349 mTizenDisplayPolicy = NULL;
1352 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1354 mNotificationLevel = level;
1355 mNotificationChangeState = state;
1356 mNotificationLevelChangeDone = true;
1358 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1361 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1363 mScreenOffMode = mode;
1364 mScreenOffModeChangeState = state;
1365 mScreenOffModeChangeDone = true;
1367 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1370 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1372 mBrightness = brightness;
1373 mBrightnessChangeState = state;
1374 mBrightnessChangeDone = true;
1376 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1379 void WindowBaseEcoreWl2::GetKeyCode( std::string keyName, int32_t& keyCode )
1381 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1382 KeyCodeMap foundKeyCode;
1384 sym = xkb_keysym_from_name( keyName.c_str(), XKB_KEYSYM_NO_FLAGS );
1385 if( sym == XKB_KEY_NoSymbol )
1387 DALI_LOG_ERROR( "Failed to get keysym in WindowBaseEcoreWl2\n" );
1391 foundKeyCode.keySym = sym;
1392 foundKeyCode.isKeyCode = false;
1393 xkb_keymap_key_for_each( mKeyMap, FindKeyCode, &foundKeyCode );
1394 keyCode = static_cast< int32_t >( foundKeyCode.keyCode );
1397 Any WindowBaseEcoreWl2::GetNativeWindow()
1399 return mEcoreWindow;
1402 int WindowBaseEcoreWl2::GetNativeWindowId()
1404 return ecore_wl2_window_id_get( mEcoreWindow );
1407 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow( int width, int height )
1409 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1410 if( totalAngle == 90 || totalAngle == 270 )
1412 mEglWindow = wl_egl_window_create( mWlSurface, height, width );
1416 mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1419 return static_cast< EGLNativeWindowType >( mEglWindow );
1422 void WindowBaseEcoreWl2::DestroyEglWindow()
1424 if( mEglWindow != NULL )
1426 wl_egl_window_destroy( mEglWindow );
1431 void WindowBaseEcoreWl2::SetEglWindowRotation( int angle )
1433 wl_egl_window_tizen_rotation rotation;
1439 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1444 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1449 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1454 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1459 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1464 wl_egl_window_tizen_set_rotation( mEglWindow, rotation );
1467 void WindowBaseEcoreWl2::SetEglWindowBufferTransform( int angle )
1469 wl_output_transform bufferTransform;
1475 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1480 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1485 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1490 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1495 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1500 wl_egl_window_tizen_set_buffer_transform( mEglWindow, bufferTransform );
1503 void WindowBaseEcoreWl2::SetEglWindowTransform( int angle )
1505 wl_output_transform windowTransform;
1511 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1516 windowTransform = WL_OUTPUT_TRANSFORM_90;
1521 windowTransform = WL_OUTPUT_TRANSFORM_180;
1526 windowTransform = WL_OUTPUT_TRANSFORM_270;
1531 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1536 wl_egl_window_tizen_set_window_transform( mEglWindow, windowTransform );
1539 void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize )
1541 wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1543 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1544 if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial )
1546 wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial );
1547 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1551 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1554 wl_egl_window_tizen_capability capability = static_cast< wl_egl_window_tizen_capability >( wl_egl_window_tizen_get_capabilities( mEglWindow ) );
1555 if( capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED )
1557 mSupportedPreProtation = true;
1560 mSupportedPreProtation = false;
1564 void WindowBaseEcoreWl2::Move( PositionSize positionSize )
1566 mWindowPositionSize = positionSize;
1567 ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1570 void WindowBaseEcoreWl2::Resize( PositionSize positionSize )
1572 mWindowPositionSize = positionSize;
1573 ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1576 void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize )
1578 mWindowPositionSize = positionSize;
1579 ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1582 void WindowBaseEcoreWl2::SetClass( const std::string& name, const std::string& className )
1584 ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
1585 ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
1588 void WindowBaseEcoreWl2::Raise()
1590 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1591 ecore_wl2_window_activate( mEcoreWindow );
1594 void WindowBaseEcoreWl2::Lower()
1596 ecore_wl2_window_lower( mEcoreWindow );
1599 void WindowBaseEcoreWl2::Activate()
1601 ecore_wl2_window_activate( mEcoreWindow );
1604 void WindowBaseEcoreWl2::SetAvailableAnlges( const std::vector< int >& angles )
1606 int rotations[4] = { 0 };
1607 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size() );
1608 for( std::size_t i = 0; i < angles.size(); ++i )
1610 rotations[i] = static_cast< int >( angles[i] );
1611 DALI_LOG_RELEASE_INFO( "%d ", rotations[i] );
1613 ecore_wl2_window_available_rotations_set( mEcoreWindow, rotations, angles.size() );
1616 void WindowBaseEcoreWl2::SetPreferredAngle( int angle )
1618 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle );
1619 ecore_wl2_window_preferred_rotation_set( mEcoreWindow, angle );
1622 void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
1624 ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
1627 void WindowBaseEcoreWl2::Show()
1631 ecore_wl2_window_geometry_set( mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height );
1635 ecore_wl2_window_show( mEcoreWindow );
1638 void WindowBaseEcoreWl2::Hide()
1641 ecore_wl2_window_hide( mEcoreWindow );
1644 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1646 return mSupportedAuxiliaryHints.size();
1649 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
1651 if( index >= GetSupportedAuxiliaryHintCount() )
1653 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1656 return mSupportedAuxiliaryHints[index];
1659 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1661 bool supported = false;
1663 // Check if the hint is suppported
1664 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1675 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1679 // Check if the hint is already added
1680 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1682 if( mAuxiliaryHints[i].first == hint )
1684 // Just change the value
1685 mAuxiliaryHints[i].second = value;
1687 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1689 return i + 1; // id is index + 1
1694 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1696 unsigned int id = mAuxiliaryHints.size();
1698 ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1700 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1705 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
1707 if( id == 0 || id > mAuxiliaryHints.size() )
1709 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1713 mAuxiliaryHints[id - 1].second = std::string();
1715 ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1717 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1722 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1724 if( id == 0 || id > mAuxiliaryHints.size() )
1726 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1730 mAuxiliaryHints[id - 1].second = value;
1732 ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1734 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
1739 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
1741 if( id == 0 || id > mAuxiliaryHints.size() )
1743 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1744 return std::string();
1747 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
1749 return mAuxiliaryHints[id - 1].second;
1752 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
1754 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1756 if( mAuxiliaryHints[i].first == hint )
1758 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1763 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1768 void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
1770 ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1773 void WindowBaseEcoreWl2::SetType( Dali::Window::Type type )
1775 Ecore_Wl2_Window_Type windowType;
1779 case Dali::Window::NORMAL:
1781 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1784 case Dali::Window::NOTIFICATION:
1786 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1789 case Dali::Window::UTILITY:
1791 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1794 case Dali::Window::DIALOG:
1796 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1801 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1806 ecore_wl2_window_type_set( mEcoreWindow, windowType );
1809 bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
1811 while( !mTizenPolicy )
1813 wl_display_dispatch_queue( mDisplay, mEventQueue );
1816 int notificationLevel;
1820 case Dali::Window::NotificationLevel::NONE:
1822 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1825 case Dali::Window::NotificationLevel::BASE:
1827 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1830 case Dali::Window::NotificationLevel::MEDIUM:
1832 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1835 case Dali::Window::NotificationLevel::HIGH:
1837 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1840 case Dali::Window::NotificationLevel::TOP:
1842 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1847 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
1848 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1853 mNotificationLevelChangeDone = false;
1854 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1856 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
1860 while( !mNotificationLevelChangeDone && count < 3 )
1862 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1863 wl_display_dispatch_queue( mDisplay, mEventQueue );
1867 if( !mNotificationLevelChangeDone )
1869 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1872 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1874 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
1878 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1883 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl2::GetNotificationLevel() const
1885 while( !mTizenPolicy )
1887 wl_display_dispatch_queue( mDisplay, mEventQueue );
1892 while( !mNotificationLevelChangeDone && count < 3 )
1894 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1895 wl_display_dispatch_queue( mDisplay, mEventQueue );
1899 if( !mNotificationLevelChangeDone )
1901 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1902 return Dali::Window::NotificationLevel::NONE;
1905 Dali::Window::NotificationLevel::Type level;
1907 switch( mNotificationLevel )
1909 case TIZEN_POLICY_LEVEL_NONE:
1911 level = Dali::Window::NotificationLevel::NONE;
1914 case TIZEN_POLICY_LEVEL_DEFAULT:
1916 level = Dali::Window::NotificationLevel::BASE;
1919 case TIZEN_POLICY_LEVEL_MEDIUM:
1921 level = Dali::Window::NotificationLevel::MEDIUM;
1924 case TIZEN_POLICY_LEVEL_HIGH:
1926 level = Dali::Window::NotificationLevel::HIGH;
1929 case TIZEN_POLICY_LEVEL_TOP:
1931 level = Dali::Window::NotificationLevel::TOP;
1936 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1937 level = Dali::Window::NotificationLevel::NONE;
1942 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1947 void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
1949 while( !mTizenPolicy )
1951 wl_display_dispatch_queue( mDisplay, mEventQueue );
1954 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1957 bool WindowBaseEcoreWl2::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
1959 while( !mTizenPolicy )
1961 wl_display_dispatch_queue( mDisplay, mEventQueue );
1964 mScreenOffModeChangeDone = false;
1965 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1967 unsigned int mode = 0;
1969 switch( screenOffMode )
1971 case Dali::Window::ScreenOffMode::TIMEOUT:
1976 case Dali::Window::ScreenOffMode::NEVER:
1983 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
1987 while( !mScreenOffModeChangeDone && count < 3 )
1989 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1990 wl_display_dispatch_queue( mDisplay, mEventQueue );
1994 if( !mScreenOffModeChangeDone )
1996 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
1999 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2001 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
2005 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
2010 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl2::GetScreenOffMode() const
2012 while( !mTizenPolicy )
2014 wl_display_dispatch_queue( mDisplay, mEventQueue );
2019 while( !mScreenOffModeChangeDone && count < 3 )
2021 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2022 wl_display_dispatch_queue( mDisplay, mEventQueue );
2026 if( !mScreenOffModeChangeDone )
2028 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
2029 return Dali::Window::ScreenOffMode::TIMEOUT;
2032 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
2034 switch( mScreenOffMode )
2038 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
2043 screenMode = Dali::Window::ScreenOffMode::NEVER;
2048 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
2053 bool WindowBaseEcoreWl2::SetBrightness( int brightness )
2055 while( !mTizenDisplayPolicy )
2057 wl_display_dispatch_queue( mDisplay, mEventQueue );
2060 mBrightnessChangeDone = false;
2061 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2063 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
2067 while( !mBrightnessChangeDone && count < 3 )
2069 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2070 wl_display_dispatch_queue( mDisplay, mEventQueue );
2074 if( !mBrightnessChangeDone )
2076 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
2079 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2081 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
2085 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
2090 int WindowBaseEcoreWl2::GetBrightness() const
2092 while( !mTizenDisplayPolicy )
2094 wl_display_dispatch_queue( mDisplay, mEventQueue );
2099 while( !mBrightnessChangeDone && count < 3 )
2101 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2102 wl_display_dispatch_queue( mDisplay, mEventQueue );
2106 if( !mBrightnessChangeDone )
2108 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
2112 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
2117 bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
2119 Ecore_Wl2_Window_Keygrab_Mode mode;
2123 case KeyGrab::TOPMOST:
2125 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2128 case KeyGrab::SHARED:
2130 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2133 case KeyGrab::OVERRIDE_EXCLUSIVE:
2135 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2138 case KeyGrab::EXCLUSIVE:
2140 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2149 return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
2152 bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
2154 return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
2157 bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
2159 int keyCount = key.Count();
2160 int keyGrabModeCount = grabMode.Count();
2162 if( keyCount != keyGrabModeCount || keyCount == 0 )
2169 Eina_List* keyList = NULL;
2170 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2172 for( int index = 0; index < keyCount; ++index )
2174 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2176 switch( grabMode[index] )
2178 case KeyGrab::TOPMOST:
2180 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2183 case KeyGrab::SHARED:
2185 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2188 case KeyGrab::OVERRIDE_EXCLUSIVE:
2190 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2193 case KeyGrab::EXCLUSIVE:
2195 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2200 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2205 keyList = eina_list_append( keyList, &info );
2208 Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
2210 result.Resize( keyCount, true );
2212 Eina_List* l = NULL;
2213 Eina_List* m = NULL;
2214 void* listData = NULL;
2216 if( grabList != NULL )
2218 EINA_LIST_FOREACH( grabList, m, data )
2221 EINA_LIST_FOREACH( keyList, l, listData )
2223 if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
2225 DALI_LOG_ERROR( "input key list has null data!" );
2229 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2231 result[index] = false;
2240 eina_list_free( keyList );
2241 eina_list_free( grabList );
2247 bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2249 int keyCount = key.Count();
2257 Eina_List* keyList = NULL;
2258 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2260 for( int index = 0; index < keyCount; ++index )
2262 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2263 keyList = eina_list_append( keyList, &info );
2266 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
2268 result.Resize( keyCount, true );
2270 Eina_List* l = NULL;
2271 Eina_List* m = NULL;
2272 void *listData = NULL;
2275 if( ungrabList != NULL )
2277 EINA_LIST_FOREACH( ungrabList, m, data )
2280 EINA_LIST_FOREACH( keyList, l, listData )
2282 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2284 result[index] = false;
2293 eina_list_free( keyList );
2294 eina_list_free( ungrabList );
2300 void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2305 Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mEcoreWindow );
2307 // 1 inch = 25.4 millimeters
2308 xres = ecore_wl2_output_dpi_get( output );
2309 yres = ecore_wl2_output_dpi_get( output );
2311 dpiHorizontal = int( xres + 0.5f ); // rounding
2312 dpiVertical = int( yres + 0.5f );
2315 int WindowBaseEcoreWl2::GetOrientation() const
2317 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2318 if( mSupportedPreProtation )
2325 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2329 if( ecore_wl2_window_ignore_output_transform_get( mEcoreWindow ) )
2335 transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mEcoreWindow ) );
2337 mScreenRotationAngle = transform * 90;
2338 return mScreenRotationAngle;
2341 void WindowBaseEcoreWl2::SetWindowRotationAngle( int degree )
2343 mWindowRotationAngle = degree;
2344 ecore_wl2_window_rotation_set( mEcoreWindow, degree );
2347 int WindowBaseEcoreWl2::GetWindowRotationAngle()
2349 return mWindowRotationAngle;
2352 void WindowBaseEcoreWl2::WindowRotationCompleted( int degree, int width, int height )
2354 ecore_wl2_window_rotation_change_done_send( mEcoreWindow, degree, width, height );
2357 void WindowBaseEcoreWl2::SetTransparency( bool transparent )
2359 ecore_wl2_window_alpha_set( mEcoreWindow, transparent );
2362 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2364 #ifdef DALI_ELDBUS_AVAILABLE
2365 Eldbus_Object* object;
2366 Eldbus_Proxy* manager;
2368 if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2370 DALI_LOG_ERROR( "Unable to get system bus\n" );
2373 object = eldbus_object_get( mSystemConnection, BUS, PATH );
2376 DALI_LOG_ERROR( "Getting object failed\n" );
2380 manager = eldbus_proxy_get( object, INTERFACE );
2383 DALI_LOG_ERROR( "Getting proxy failed\n" );
2387 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2389 DALI_LOG_ERROR( "No signal handler returned\n" );
2394 void WindowBaseEcoreWl2::CreateWindow( PositionSize positionSize )
2396 Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL );
2399 DALI_ASSERT_ALWAYS( 0 && "Failed to get display" );
2402 ecore_wl2_display_sync( display );
2404 mEcoreWindow = ecore_wl2_window_new( display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
2406 if ( mEcoreWindow == 0 )
2408 DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2412 ecore_wl2_window_type_set( mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL );
2415 void WindowBaseEcoreWl2::SetParent( WindowBase* parentWinBase )
2417 Ecore_Wl2_Window* ecoreParent = NULL;
2420 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>( parentWinBase );
2421 ecoreParent = winBaseEcore2->mEcoreWindow;
2423 ecore_wl2_window_parent_set( mEcoreWindow, ecoreParent );
2426 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2428 return wl_egl_window_tizen_create_commit_sync_fd( mEglWindow );
2431 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2433 return wl_egl_window_tizen_create_presentation_sync_fd( mEglWindow );
2436 } // namespace Adaptor
2438 } // namespace Internal
2442 #pragma GCC diagnostic pop