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 // Keymap Changed Callbacks
509 /////////////////////////////////////////////////////////////////////////////////////////////////
511 static Eina_Bool EcoreEventSeatKeymapChanged(void *data, int type, void *event)
513 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
516 windowBase->KeymapChanged( data, type, event );
519 return ECORE_CALLBACK_RENEW;
522 /////////////////////////////////////////////////////////////////////////////////////////////////
524 /////////////////////////////////////////////////////////////////////////////////////////////////
527 * Called when a font name is changed.
529 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
531 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
534 windowBase->OnFontNameChanged();
539 * Called when a font size is changed.
541 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
543 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
546 windowBase->OnFontSizeChanged();
550 /////////////////////////////////////////////////////////////////////////////////////////////////
551 // ElDBus Accessibility Callbacks
552 /////////////////////////////////////////////////////////////////////////////////////////////////
554 #ifdef DALI_ELDBUS_AVAILABLE
555 // Callback for Ecore ElDBus accessibility events.
556 static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
558 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( context );
561 windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
564 #endif // DALI_ELDBUS_AVAILABLE
566 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
568 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
571 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
575 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
577 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
580 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
584 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
588 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 )
592 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
594 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
597 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
601 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
605 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
607 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
610 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
614 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
618 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
622 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
626 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
630 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 )
634 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
636 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
639 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
643 const struct wl_registry_listener registryListener =
645 RegistryGlobalCallback,
646 RegistryGlobalCallbackRemove
649 const struct tizen_policy_listener tizenPolicyListener =
651 TizenPolicyConformant,
652 TizenPolicyConformantArea,
653 TizenPolicyNotificationChangeDone,
654 TizenPolicyTransientForDone,
655 TizenPolicyScreenModeChangeDone,
656 TizenPolicyIconifyStateChanged,
657 TizenPolicySupportedAuxiliaryHints,
658 TizenPolicyAllowedAuxiliaryHint,
659 TizenPolicyAuxiliaryMessage,
660 TizenPolicyConformantRegion
663 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
665 DisplayPolicyBrightnessChangeDone
668 } // unnamed namespace
670 WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any surface, bool isTransparent )
671 : mEcoreEventHandler(),
672 mEcoreWindow( NULL ),
677 mTizenPolicy( NULL ),
678 mTizenDisplayPolicy( NULL ),
680 mSupportedAuxiliaryHints(),
682 mNotificationLevel( -1 ),
683 mNotificationChangeState( 0 ),
684 mNotificationLevelChangeDone( true ),
686 mScreenOffModeChangeState( 0 ),
687 mScreenOffModeChangeDone( true ),
689 mBrightnessChangeState( 0 ),
690 mBrightnessChangeDone( true ),
692 mWindowPositionSize( positionSize ),
693 mOwnSurface( false ),
694 mMoveResizeSerial( 0 ),
695 mLastSubmittedMoveResizeSerial( 0 ),
696 mWindowRotationAngle( 0 ),
697 mScreenRotationAngle( 0 ),
698 mSupportedPreProtation( 0 )
699 #ifdef DALI_ELDBUS_AVAILABLE
700 , mSystemConnection( NULL )
703 Initialize( positionSize, surface, isTransparent );
706 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
708 #ifdef DALI_ELDBUS_AVAILABLE
709 // Close down ElDBus connections.
710 if( mSystemConnection )
712 eldbus_connection_unref( mSystemConnection );
714 #endif // DALI_ELDBUS_AVAILABLE
716 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
717 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
719 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
721 ecore_event_handler_del( *iter );
723 mEcoreEventHandler.Clear();
727 wl_event_queue_destroy( mEventQueue );
730 mSupportedAuxiliaryHints.clear();
731 mAuxiliaryHints.clear();
733 if( mEglWindow != NULL )
735 wl_egl_window_destroy( mEglWindow );
741 ecore_wl2_window_free( mEcoreWindow );
743 WindowSystem::Shutdown();
747 void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
749 if( surface.Empty() == false )
751 // check we have a valid type
752 DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl2_Window *) ) && "Surface type is invalid" );
754 mEcoreWindow = AnyCast< Ecore_Wl2_Window* >( surface );
758 // we own the surface about to created
759 WindowSystem::Initialize();
762 CreateWindow( positionSize );
765 for( int i = 0; i < 4; ++i )
767 mAvaiableWindowOrientations[i] = 0;
770 mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
772 SetTransparency( isTransparent );
774 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
775 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
776 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
777 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
778 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
780 // Register Rotate event
781 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
783 // Register Configure event
784 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this ) );
786 // Register Touch events
787 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
788 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
789 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
790 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
792 // Register Mouse wheel events
793 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
795 // Register Detent event
796 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
798 // Register Key events
799 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
800 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
802 // Register Selection event - clipboard selection
803 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
804 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
806 // Register Effect Start/End event
807 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this ) );
808 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this ) );
810 // Register Vconf notify - font name and size
811 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
812 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
814 InitializeEcoreElDBus();
816 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
817 mDisplay = ecore_wl2_display_get( display );
821 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
824 mEventQueue = wl_display_create_queue( mDisplay );
827 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
829 wl_registry* registry = wl_display_get_registry( displayWrapper );
830 wl_registry_add_listener( registry, ®istryListener, this );
833 wl_proxy_wrapper_destroy( displayWrapper );
837 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( display );
841 mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
843 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this ) );
846 // get auxiliary hint
847 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
853 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) ) ) )
855 mSupportedAuxiliaryHints.push_back( hint );
857 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
862 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
864 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
865 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
867 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
869 if( iconifyChangedEvent->iconified == EINA_TRUE )
871 mIconifyChangedSignal.Emit( true );
875 mIconifyChangedSignal.Emit( false );
877 handled = ECORE_CALLBACK_DONE;
883 Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
885 Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
887 if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
889 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
891 mFocusChangedSignal.Emit( true );
894 return ECORE_CALLBACK_PASS_ON;
897 Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
899 Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
901 if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
903 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
905 mFocusChangedSignal.Emit( false );
908 return ECORE_CALLBACK_PASS_ON;
911 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
913 Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
915 if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
917 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
919 mOutputTransformedSignal.Emit();
922 return ECORE_CALLBACK_PASS_ON;
925 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
927 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
929 if( ignoreTransformEvent->win == mEcoreWindow )
931 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
933 mOutputTransformedSignal.Emit();
936 return ECORE_CALLBACK_PASS_ON;
939 void WindowBaseEcoreWl2::OnRotation( void* data, int type, void* event )
941 Ecore_Wl2_Event_Window_Rotation* ev( static_cast< Ecore_Wl2_Event_Window_Rotation* >( event ) );
943 if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
945 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h );
947 RotationEvent rotationEvent;
948 rotationEvent.angle = ev->angle;
949 rotationEvent.winResize = 0;
951 if( ev->angle == 0 || ev->angle == 180 )
953 rotationEvent.width = ev->w;
954 rotationEvent.height = ev->h;
958 rotationEvent.width = ev->h;
959 rotationEvent.height = ev->w;
962 mWindowPositionSize.width = rotationEvent.width;
963 mWindowPositionSize.height = rotationEvent.height;
965 mRotationSignal.Emit( rotationEvent );
969 void WindowBaseEcoreWl2::OnConfiguration( void* data, int type, void* event )
971 Ecore_Wl2_Event_Window_Configure* ev( static_cast< Ecore_Wl2_Event_Window_Configure* >( event ) );
973 if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
975 // Note: To comply with the wayland protocol, Dali should make an ack_configure
976 // by calling ecore_wl2_window_commit
977 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
981 void WindowBaseEcoreWl2::OnMouseButtonDown( void* data, int type, void* event )
983 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
985 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
987 Device::Class::Type deviceClass;
988 Device::Subclass::Type deviceSubclass;
990 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
991 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
993 PointState::Type state ( PointState::DOWN );
995 if( deviceClass != Device::Class::Type::MOUSE )
997 // Check if the buttons field is set and ensure it's the primary touch button.
998 // If this event was triggered by buttons other than the primary button (used for touch), then
999 // just send an interrupted event to Core.
1000 if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
1002 state = PointState::INTERRUPTED;
1006 Integration::Point point;
1007 point.SetDeviceId( touchEvent->multi.device );
1008 point.SetState( state );
1009 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1010 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1011 point.SetPressure( touchEvent->multi.pressure );
1012 point.SetAngle( Degree( touchEvent->multi.angle ) );
1013 point.SetDeviceClass( deviceClass );
1014 point.SetDeviceSubclass( deviceSubclass );
1015 point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1017 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1021 void WindowBaseEcoreWl2::OnMouseButtonUp( void* data, int type, void* event )
1023 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1025 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1027 Device::Class::Type deviceClass;
1028 Device::Subclass::Type deviceSubclass;
1030 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1031 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1033 Integration::Point point;
1034 point.SetDeviceId( touchEvent->multi.device );
1035 point.SetState( PointState::UP );
1036 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1037 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1038 point.SetPressure( touchEvent->multi.pressure );
1039 point.SetAngle( Degree( touchEvent->multi.angle ) );
1040 point.SetDeviceClass( deviceClass );
1041 point.SetDeviceSubclass( deviceSubclass );
1042 point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1044 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1048 void WindowBaseEcoreWl2::OnMouseButtonMove( void* data, int type, void* event )
1050 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
1052 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1054 Device::Class::Type deviceClass;
1055 Device::Subclass::Type deviceSubclass;
1057 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1058 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1060 Integration::Point point;
1061 point.SetDeviceId( touchEvent->multi.device );
1062 point.SetState( PointState::MOTION );
1063 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1064 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1065 point.SetPressure( touchEvent->multi.pressure );
1066 point.SetAngle( Degree( touchEvent->multi.angle ) );
1067 point.SetDeviceClass( deviceClass );
1068 point.SetDeviceSubclass( deviceSubclass );
1070 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1074 void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event )
1076 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1078 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1080 Integration::Point point;
1081 point.SetDeviceId( touchEvent->multi.device );
1082 point.SetState( PointState::INTERRUPTED );
1083 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
1085 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1087 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" );
1091 void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
1093 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
1095 if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1097 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 );
1099 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
1101 mWheelEventSignal.Emit( wheelEvent );
1105 void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event )
1107 Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
1109 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n" );
1111 int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
1112 int timeStamp = detentEvent->timestamp;
1114 WheelEvent wheelEvent( WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2( 0.0f, 0.0f ), 0, timeStamp );
1116 mWheelEventSignal.Emit( wheelEvent );
1119 void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event )
1121 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1123 if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1125 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n" );
1127 std::string keyName( keyEvent->keyname );
1128 std::string logicalKey( "" );
1129 std::string keyString( "" );
1130 std::string compose( "" );
1132 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1133 if( keyEvent->compose )
1135 compose = keyEvent->compose;
1138 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1141 logicalKey = keyEvent->key;
1145 GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1149 // Get a specific key code from dali key look up table.
1150 keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1153 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1154 int modifier( keyEvent->modifiers );
1155 unsigned long time = keyEvent->timestamp;
1156 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1158 keyCode = atoi( keyEvent->keyname + 8 );
1161 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1162 if( keyEvent->string )
1164 keyString = keyEvent->string;
1167 std::string deviceName;
1168 Device::Class::Type deviceClass;
1169 Device::Subclass::Type deviceSubclass;
1171 GetDeviceName( keyEvent, deviceName );
1172 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1173 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1175 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, deviceName, deviceClass, deviceSubclass );
1177 mKeyEventSignal.Emit( keyEvent );
1181 void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event )
1183 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1185 if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1187 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n" );
1189 std::string keyName( keyEvent->keyname );
1190 std::string logicalKey( "" );
1191 std::string keyString( "" );
1192 std::string compose( "" );
1194 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1195 if( keyEvent->compose )
1197 compose = keyEvent->compose;
1200 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1203 logicalKey = keyEvent->key;
1207 GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1211 // Get a specific key code from dali key look up table.
1212 keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1215 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1216 int modifier( keyEvent->modifiers );
1217 unsigned long time = keyEvent->timestamp;
1218 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1220 keyCode = atoi( keyEvent->keyname + 8 );
1223 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1224 if( keyEvent->string )
1226 keyString = keyEvent->string;
1229 std::string deviceName;
1230 Device::Class::Type deviceClass;
1231 Device::Subclass::Type deviceSubclass;
1233 GetDeviceName( keyEvent, deviceName );
1234 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1235 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1237 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, deviceName, deviceClass, deviceSubclass );
1239 mKeyEventSignal.Emit( keyEvent );
1243 void WindowBaseEcoreWl2::OnDataSend( void* data, int type, void* event )
1245 mSelectionDataSendSignal.Emit( event );
1248 void WindowBaseEcoreWl2::OnDataReceive( void* data, int type, void* event )
1250 mSelectionDataReceivedSignal.Emit( event );
1253 void WindowBaseEcoreWl2::OnFontNameChanged()
1255 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1258 void WindowBaseEcoreWl2::OnFontSizeChanged()
1260 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1263 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1265 #ifdef DALI_ELDBUS_AVAILABLE
1266 AccessibilityInfo info;
1268 // The string defines the arg-list's respective types.
1269 if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1271 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1274 mAccessibilitySignal.Emit( info );
1278 void WindowBaseEcoreWl2::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
1280 mTransitionEffectEventSignal.Emit( state, type );
1283 void WindowBaseEcoreWl2::KeymapChanged(void *data, int type, void *event)
1285 Ecore_Wl2_Event_Seat_Keymap_Changed *changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>( event );
1286 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id );
1287 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( changed->display );
1290 mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
1294 void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1296 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1298 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1300 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1303 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1307 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1309 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1311 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1313 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1314 if( !mTizenDisplayPolicy )
1316 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1320 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1322 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1326 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1328 mTizenPolicy = NULL;
1329 mTizenDisplayPolicy = NULL;
1332 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1334 mNotificationLevel = level;
1335 mNotificationChangeState = state;
1336 mNotificationLevelChangeDone = true;
1338 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1341 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1343 mScreenOffMode = mode;
1344 mScreenOffModeChangeState = state;
1345 mScreenOffModeChangeDone = true;
1347 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1350 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1352 mBrightness = brightness;
1353 mBrightnessChangeState = state;
1354 mBrightnessChangeDone = true;
1356 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1359 void WindowBaseEcoreWl2::GetKeyCode( std::string keyName, int32_t& keyCode )
1361 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1362 KeyCodeMap foundKeyCode;
1364 sym = xkb_keysym_from_name( keyName.c_str(), XKB_KEYSYM_NO_FLAGS );
1365 if( sym == XKB_KEY_NoSymbol )
1367 DALI_LOG_ERROR( "Failed to get keysym in WindowBaseEcoreWl2\n" );
1371 foundKeyCode.keySym = sym;
1372 foundKeyCode.isKeyCode = false;
1373 xkb_keymap_key_for_each( mKeyMap, FindKeyCode, &foundKeyCode );
1374 keyCode = static_cast< int32_t >( foundKeyCode.keyCode );
1377 Any WindowBaseEcoreWl2::GetNativeWindow()
1379 return mEcoreWindow;
1382 int WindowBaseEcoreWl2::GetNativeWindowId()
1384 return ecore_wl2_window_id_get( mEcoreWindow );
1387 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow( int width, int height )
1389 mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1391 return static_cast< EGLNativeWindowType >( mEglWindow );
1394 void WindowBaseEcoreWl2::DestroyEglWindow()
1396 if( mEglWindow != NULL )
1398 wl_egl_window_destroy( mEglWindow );
1403 void WindowBaseEcoreWl2::SetEglWindowRotation( int angle )
1405 wl_egl_window_tizen_rotation rotation;
1411 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1416 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1421 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1426 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1431 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1436 wl_egl_window_tizen_set_rotation( mEglWindow, rotation );
1439 void WindowBaseEcoreWl2::SetEglWindowBufferTransform( int angle )
1441 wl_output_transform bufferTransform;
1447 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1452 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1457 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1462 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1467 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1472 wl_egl_window_tizen_set_buffer_transform( mEglWindow, bufferTransform );
1475 void WindowBaseEcoreWl2::SetEglWindowTransform( int angle )
1477 wl_output_transform windowTransform;
1483 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1488 windowTransform = WL_OUTPUT_TRANSFORM_90;
1493 windowTransform = WL_OUTPUT_TRANSFORM_180;
1498 windowTransform = WL_OUTPUT_TRANSFORM_270;
1503 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1508 wl_egl_window_tizen_set_window_transform( mEglWindow, windowTransform );
1511 void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize )
1513 wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1515 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1516 if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial )
1518 wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial );
1519 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1523 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1526 wl_egl_window_tizen_capability capability = static_cast< wl_egl_window_tizen_capability >( wl_egl_window_tizen_get_capabilities( mEglWindow ) );
1527 if( capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED )
1529 mSupportedPreProtation = true;
1532 mSupportedPreProtation = false;
1536 void WindowBaseEcoreWl2::Move( PositionSize positionSize )
1538 mWindowPositionSize = positionSize;
1539 ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1542 void WindowBaseEcoreWl2::Resize( PositionSize positionSize )
1544 mWindowPositionSize = positionSize;
1545 ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1548 void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize )
1550 mWindowPositionSize = positionSize;
1551 ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1554 void WindowBaseEcoreWl2::SetClass( const std::string& name, const std::string& className )
1556 ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
1557 ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
1560 void WindowBaseEcoreWl2::Raise()
1562 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1563 ecore_wl2_window_activate( mEcoreWindow );
1566 void WindowBaseEcoreWl2::Lower()
1568 ecore_wl2_window_lower( mEcoreWindow );
1571 void WindowBaseEcoreWl2::Activate()
1573 ecore_wl2_window_activate( mEcoreWindow );
1576 void WindowBaseEcoreWl2::SetAvailableAnlges( const std::vector< int >& angles )
1578 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size() );
1579 std::size_t size = angles.size();
1580 for( std::size_t i = 0; i < size; ++i )
1582 mAvaiableWindowOrientations[i] = static_cast< int >( angles[i] );
1583 DALI_LOG_RELEASE_INFO( "%d ", mAvaiableWindowOrientations[i] );
1585 ecore_wl2_window_available_rotations_set( mEcoreWindow, mAvaiableWindowOrientations, size );
1588 void WindowBaseEcoreWl2::SetPreferredAngle( int angle )
1590 ecore_wl2_window_preferred_rotation_set( mEcoreWindow, angle );
1593 void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
1595 ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
1598 void WindowBaseEcoreWl2::Show()
1602 ecore_wl2_window_geometry_set( mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height );
1606 ecore_wl2_window_show( mEcoreWindow );
1609 void WindowBaseEcoreWl2::Hide()
1612 ecore_wl2_window_hide( mEcoreWindow );
1615 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1617 return mSupportedAuxiliaryHints.size();
1620 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
1622 if( index >= GetSupportedAuxiliaryHintCount() )
1624 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1627 return mSupportedAuxiliaryHints[index];
1630 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1632 bool supported = false;
1634 // Check if the hint is suppported
1635 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1646 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1650 // Check if the hint is already added
1651 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1653 if( mAuxiliaryHints[i].first == hint )
1655 // Just change the value
1656 mAuxiliaryHints[i].second = value;
1658 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1660 return i + 1; // id is index + 1
1665 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1667 unsigned int id = mAuxiliaryHints.size();
1669 ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1671 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1676 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
1678 if( id == 0 || id > mAuxiliaryHints.size() )
1680 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1684 mAuxiliaryHints[id - 1].second = std::string();
1686 ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1688 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1693 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1695 if( id == 0 || id > mAuxiliaryHints.size() )
1697 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1701 mAuxiliaryHints[id - 1].second = value;
1703 ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1705 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() );
1710 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
1712 if( id == 0 || id > mAuxiliaryHints.size() )
1714 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1715 return std::string();
1718 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() );
1720 return mAuxiliaryHints[id - 1].second;
1723 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
1725 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1727 if( mAuxiliaryHints[i].first == hint )
1729 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1734 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1739 void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
1741 ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1744 void WindowBaseEcoreWl2::SetType( Dali::Window::Type type )
1746 Ecore_Wl2_Window_Type windowType;
1750 case Dali::Window::NORMAL:
1752 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1755 case Dali::Window::NOTIFICATION:
1757 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1760 case Dali::Window::UTILITY:
1762 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1765 case Dali::Window::DIALOG:
1767 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1772 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1777 ecore_wl2_window_type_set( mEcoreWindow, windowType );
1780 bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
1782 while( !mTizenPolicy )
1784 wl_display_dispatch_queue( mDisplay, mEventQueue );
1787 int notificationLevel;
1791 case Dali::Window::NotificationLevel::NONE:
1793 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1796 case Dali::Window::NotificationLevel::BASE:
1798 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1801 case Dali::Window::NotificationLevel::MEDIUM:
1803 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1806 case Dali::Window::NotificationLevel::HIGH:
1808 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1811 case Dali::Window::NotificationLevel::TOP:
1813 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1818 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
1819 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1824 mNotificationLevelChangeDone = false;
1825 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1827 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
1831 while( !mNotificationLevelChangeDone && count < 3 )
1833 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1834 wl_display_dispatch_queue( mDisplay, mEventQueue );
1838 if( !mNotificationLevelChangeDone )
1840 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1843 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1845 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
1849 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1854 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl2::GetNotificationLevel() const
1856 while( !mTizenPolicy )
1858 wl_display_dispatch_queue( mDisplay, mEventQueue );
1863 while( !mNotificationLevelChangeDone && count < 3 )
1865 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1866 wl_display_dispatch_queue( mDisplay, mEventQueue );
1870 if( !mNotificationLevelChangeDone )
1872 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1873 return Dali::Window::NotificationLevel::NONE;
1876 Dali::Window::NotificationLevel::Type level;
1878 switch( mNotificationLevel )
1880 case TIZEN_POLICY_LEVEL_NONE:
1882 level = Dali::Window::NotificationLevel::NONE;
1885 case TIZEN_POLICY_LEVEL_DEFAULT:
1887 level = Dali::Window::NotificationLevel::BASE;
1890 case TIZEN_POLICY_LEVEL_MEDIUM:
1892 level = Dali::Window::NotificationLevel::MEDIUM;
1895 case TIZEN_POLICY_LEVEL_HIGH:
1897 level = Dali::Window::NotificationLevel::HIGH;
1900 case TIZEN_POLICY_LEVEL_TOP:
1902 level = Dali::Window::NotificationLevel::TOP;
1907 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1908 level = Dali::Window::NotificationLevel::NONE;
1913 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1918 void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
1920 while( !mTizenPolicy )
1922 wl_display_dispatch_queue( mDisplay, mEventQueue );
1925 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1928 bool WindowBaseEcoreWl2::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
1930 while( !mTizenPolicy )
1932 wl_display_dispatch_queue( mDisplay, mEventQueue );
1935 mScreenOffModeChangeDone = false;
1936 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1938 unsigned int mode = 0;
1940 switch( screenOffMode )
1942 case Dali::Window::ScreenOffMode::TIMEOUT:
1947 case Dali::Window::ScreenOffMode::NEVER:
1954 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
1958 while( !mScreenOffModeChangeDone && count < 3 )
1960 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1961 wl_display_dispatch_queue( mDisplay, mEventQueue );
1965 if( !mScreenOffModeChangeDone )
1967 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
1970 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1972 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
1976 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
1981 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl2::GetScreenOffMode() const
1983 while( !mTizenPolicy )
1985 wl_display_dispatch_queue( mDisplay, mEventQueue );
1990 while( !mScreenOffModeChangeDone && count < 3 )
1992 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1993 wl_display_dispatch_queue( mDisplay, mEventQueue );
1997 if( !mScreenOffModeChangeDone )
1999 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
2000 return Dali::Window::ScreenOffMode::TIMEOUT;
2003 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
2005 switch( mScreenOffMode )
2009 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
2014 screenMode = Dali::Window::ScreenOffMode::NEVER;
2019 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
2024 bool WindowBaseEcoreWl2::SetBrightness( int brightness )
2026 while( !mTizenDisplayPolicy )
2028 wl_display_dispatch_queue( mDisplay, mEventQueue );
2031 mBrightnessChangeDone = false;
2032 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2034 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
2038 while( !mBrightnessChangeDone && count < 3 )
2040 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2041 wl_display_dispatch_queue( mDisplay, mEventQueue );
2045 if( !mBrightnessChangeDone )
2047 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
2050 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2052 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
2056 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
2061 int WindowBaseEcoreWl2::GetBrightness() const
2063 while( !mTizenDisplayPolicy )
2065 wl_display_dispatch_queue( mDisplay, mEventQueue );
2070 while( !mBrightnessChangeDone && count < 3 )
2072 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2073 wl_display_dispatch_queue( mDisplay, mEventQueue );
2077 if( !mBrightnessChangeDone )
2079 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
2083 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
2088 bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
2090 Ecore_Wl2_Window_Keygrab_Mode mode;
2094 case KeyGrab::TOPMOST:
2096 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2099 case KeyGrab::SHARED:
2101 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2104 case KeyGrab::OVERRIDE_EXCLUSIVE:
2106 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2109 case KeyGrab::EXCLUSIVE:
2111 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2120 return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
2123 bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
2125 return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
2128 bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
2130 int keyCount = key.Count();
2131 int keyGrabModeCount = grabMode.Count();
2133 if( keyCount != keyGrabModeCount || keyCount == 0 )
2140 Eina_List* keyList = NULL;
2141 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2143 for( int index = 0; index < keyCount; ++index )
2145 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2147 switch( grabMode[index] )
2149 case KeyGrab::TOPMOST:
2151 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2154 case KeyGrab::SHARED:
2156 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2159 case KeyGrab::OVERRIDE_EXCLUSIVE:
2161 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2164 case KeyGrab::EXCLUSIVE:
2166 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2171 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2176 keyList = eina_list_append( keyList, &info );
2179 Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
2181 result.Resize( keyCount, true );
2183 Eina_List* l = NULL;
2184 Eina_List* m = NULL;
2185 void* listData = NULL;
2187 if( grabList != NULL )
2189 EINA_LIST_FOREACH( grabList, m, data )
2192 EINA_LIST_FOREACH( keyList, l, listData )
2194 if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
2196 DALI_LOG_ERROR( "input key list has null data!" );
2200 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2202 result[index] = false;
2211 eina_list_free( keyList );
2212 eina_list_free( grabList );
2218 bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2220 int keyCount = key.Count();
2228 Eina_List* keyList = NULL;
2229 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2231 for( int index = 0; index < keyCount; ++index )
2233 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2234 keyList = eina_list_append( keyList, &info );
2237 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
2239 result.Resize( keyCount, true );
2241 Eina_List* l = NULL;
2242 Eina_List* m = NULL;
2243 void *listData = NULL;
2246 if( ungrabList != NULL )
2248 EINA_LIST_FOREACH( ungrabList, m, data )
2251 EINA_LIST_FOREACH( keyList, l, listData )
2253 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2255 result[index] = false;
2264 eina_list_free( keyList );
2265 eina_list_free( ungrabList );
2271 void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2276 Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mEcoreWindow );
2278 // 1 inch = 25.4 millimeters
2279 xres = ecore_wl2_output_dpi_get( output );
2280 yres = ecore_wl2_output_dpi_get( output );
2282 dpiHorizontal = int( xres + 0.5f ); // rounding
2283 dpiVertical = int( yres + 0.5f );
2286 int WindowBaseEcoreWl2::GetOrientation() const
2288 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2289 if( mSupportedPreProtation )
2296 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2300 if( ecore_wl2_window_ignore_output_transform_get( mEcoreWindow ) )
2306 transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mEcoreWindow ) );
2308 mScreenRotationAngle = transform * 90;
2309 return mScreenRotationAngle;
2312 void WindowBaseEcoreWl2::SetWindowRotationAngle( int degree )
2314 mWindowRotationAngle = degree;
2315 ecore_wl2_window_rotation_set( mEcoreWindow, degree );
2318 int WindowBaseEcoreWl2::GetWindowRotationAngle()
2320 return mWindowRotationAngle;
2323 void WindowBaseEcoreWl2::WindowRotationCompleted( int degree, int width, int height )
2325 ecore_wl2_window_rotation_change_done_send( mEcoreWindow, degree, width, height );
2328 void WindowBaseEcoreWl2::SetTransparency( bool transparent )
2330 ecore_wl2_window_alpha_set( mEcoreWindow, transparent );
2333 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2335 #ifdef DALI_ELDBUS_AVAILABLE
2336 Eldbus_Object* object;
2337 Eldbus_Proxy* manager;
2339 if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2341 DALI_LOG_ERROR( "Unable to get system bus\n" );
2344 object = eldbus_object_get( mSystemConnection, BUS, PATH );
2347 DALI_LOG_ERROR( "Getting object failed\n" );
2351 manager = eldbus_proxy_get( object, INTERFACE );
2354 DALI_LOG_ERROR( "Getting proxy failed\n" );
2358 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2360 DALI_LOG_ERROR( "No signal handler returned\n" );
2365 void WindowBaseEcoreWl2::CreateWindow( PositionSize positionSize )
2367 Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL );
2370 DALI_ASSERT_ALWAYS( 0 && "Failed to get display" );
2373 mEcoreWindow = ecore_wl2_window_new( display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
2375 if ( mEcoreWindow == 0 )
2377 DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2381 ecore_wl2_window_type_set( mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL );
2384 void WindowBaseEcoreWl2::SetParent( WindowBase* parentWinBase )
2386 Ecore_Wl2_Window* ecoreParent = NULL;
2389 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>( parentWinBase );
2390 ecoreParent = winBaseEcore2->mEcoreWindow;
2392 ecore_wl2_window_parent_set( mEcoreWindow, ecoreParent );
2395 } // namespace Adaptor
2397 } // namespace Internal
2401 #pragma GCC diagnostic pop