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/public-api/adaptor-framework/window-enumerations.h>
35 #include <dali/integration-api/debug.h>
36 #include <Ecore_Input.h>
38 #include <vconf-keys.h>
39 #include <wayland-egl-tizen.h>
53 #if defined(DEBUG_ENABLED)
54 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
57 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
58 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
60 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
63 const char* BUS = "org.enlightenment.wm-screen-reader";
64 const char* INTERFACE = "org.tizen.GestureNavigation";
65 const char* PATH = "/org/tizen/GestureNavigation";
70 xkb_keycode_t keyCode;
75 * Get the device name from the provided ecore key event
77 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
79 const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
83 result = ecoreDeviceName;
88 * Get the device class from the provided ecore event
90 void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
92 switch( ecoreDeviceClass )
94 case ECORE_DEVICE_CLASS_SEAT:
96 deviceClass = Device::Class::USER;
99 case ECORE_DEVICE_CLASS_KEYBOARD:
101 deviceClass = Device::Class::KEYBOARD;
104 case ECORE_DEVICE_CLASS_MOUSE:
106 deviceClass = Device::Class::MOUSE;
109 case ECORE_DEVICE_CLASS_TOUCH:
111 deviceClass = Device::Class::TOUCH;
114 case ECORE_DEVICE_CLASS_PEN:
116 deviceClass = Device::Class::PEN;
119 case ECORE_DEVICE_CLASS_POINTER:
121 deviceClass = Device::Class::POINTER;
124 case ECORE_DEVICE_CLASS_GAMEPAD:
126 deviceClass = Device::Class::GAMEPAD;
131 deviceClass = Device::Class::NONE;
137 void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
139 switch( ecoreDeviceSubclass )
141 case ECORE_DEVICE_SUBCLASS_FINGER:
143 deviceSubclass = Device::Subclass::FINGER;
146 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
148 deviceSubclass = Device::Subclass::FINGERNAIL;
151 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
153 deviceSubclass = Device::Subclass::KNUCKLE;
156 case ECORE_DEVICE_SUBCLASS_PALM:
158 deviceSubclass = Device::Subclass::PALM;
161 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
163 deviceSubclass = Device::Subclass::HAND_SIDE;
166 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
168 deviceSubclass = Device::Subclass::HAND_FLAT;
171 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
173 deviceSubclass = Device::Subclass::PEN_TIP;
176 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
178 deviceSubclass = Device::Subclass::TRACKPAD;
181 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
183 deviceSubclass = Device::Subclass::TRACKPOINT;
186 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
188 deviceSubclass = Device::Subclass::TRACKBALL;
191 case ECORE_DEVICE_SUBCLASS_REMOCON:
193 deviceSubclass = Device::Subclass::REMOCON;
196 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
198 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
203 deviceSubclass = Device::Subclass::NONE;
210 void FindKeyCode( struct xkb_keymap* keyMap, xkb_keycode_t key, void* data )
212 KeyCodeMap* foundKeyCode = static_cast< KeyCodeMap* >( data );
213 if( foundKeyCode->isKeyCode )
218 xkb_keysym_t keySym = foundKeyCode->keySym;
220 const xkb_keysym_t* symsOut = NULL;
222 nsyms = xkb_keymap_key_get_syms_by_level( keyMap, key, 0, 0, &symsOut );
224 if( nsyms && symsOut )
226 if( *symsOut == keySym )
228 foundKeyCode->keyCode = key;
229 foundKeyCode->isKeyCode = true;
234 /////////////////////////////////////////////////////////////////////////////////////////////////
236 /////////////////////////////////////////////////////////////////////////////////////////////////
238 /// Called when the window iconify state is changed.
239 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
241 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
244 return windowBase->OnIconifyStateChanged( data, type, event );
247 return ECORE_CALLBACK_PASS_ON;
250 /// Called when the window gains focus
251 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
253 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
256 return windowBase->OnFocusIn( data, type, event );
259 return ECORE_CALLBACK_PASS_ON;
262 /// Called when the window loses focus
263 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
265 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
268 return windowBase->OnFocusOut( data, type, event );
271 return ECORE_CALLBACK_PASS_ON;
274 /// Called when the output is transformed
275 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
277 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
280 return windowBase->OnOutputTransform( data, type, event );
283 return ECORE_CALLBACK_PASS_ON;
286 /// Called when the output transform should be ignored
287 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
289 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
292 return windowBase->OnIgnoreOutputTransform( data, type, event );
295 return ECORE_CALLBACK_PASS_ON;
299 * Called when rotate event is recevied.
301 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
303 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
306 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::EcoreEventRotate\n" );
307 windowBase->OnRotation( data, type, event );
309 return ECORE_CALLBACK_PASS_ON;
313 * Called when configure event is recevied.
315 static Eina_Bool EcoreEventConfigure( void* data, int type, void* event )
317 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
320 windowBase->OnConfiguration( data, type, event );
322 return ECORE_CALLBACK_PASS_ON;
325 /////////////////////////////////////////////////////////////////////////////////////////////////
327 /////////////////////////////////////////////////////////////////////////////////////////////////
330 * Called when a touch down is received.
332 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
334 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
337 windowBase->OnMouseButtonDown( data, type, event );
339 return ECORE_CALLBACK_PASS_ON;
343 * Called when a touch up is received.
345 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
347 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
350 windowBase->OnMouseButtonUp( data, type, event );
352 return ECORE_CALLBACK_PASS_ON;
356 * Called when a touch motion is received.
358 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
360 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
363 windowBase->OnMouseButtonMove( data, type, event );
365 return ECORE_CALLBACK_PASS_ON;
369 * Called when a touch is canceled.
371 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
373 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
376 windowBase->OnMouseButtonCancel( data, type, event );
378 return ECORE_CALLBACK_PASS_ON;
382 * Called when a mouse wheel is received.
384 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
386 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
389 windowBase->OnMouseWheel( data, type, event );
391 return ECORE_CALLBACK_PASS_ON;
395 * Called when a detent rotation event is recevied.
397 static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
399 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
402 windowBase->OnDetentRotation( data, type, event );
404 return ECORE_CALLBACK_PASS_ON;
407 /////////////////////////////////////////////////////////////////////////////////////////////////
409 /////////////////////////////////////////////////////////////////////////////////////////////////
412 * Called when a key down is received.
414 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
416 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
419 windowBase->OnKeyDown( data, type, event );
421 return ECORE_CALLBACK_PASS_ON;
425 * Called when a key up is received.
427 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
429 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
432 windowBase->OnKeyUp( data, type, event );
434 return ECORE_CALLBACK_PASS_ON;
437 /////////////////////////////////////////////////////////////////////////////////////////////////
438 // Selection Callbacks
439 /////////////////////////////////////////////////////////////////////////////////////////////////
442 * Called when the source window notifies us the content in clipboard is selected.
444 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
446 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
449 windowBase->OnDataSend( data, type, event );
451 return ECORE_CALLBACK_PASS_ON;
455 * Called when the source window sends us about the selected content.
456 * For example, when item is selected in the clipboard.
458 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
460 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
463 windowBase->OnDataReceive( data, type, event );
465 return ECORE_CALLBACK_PASS_ON;
468 /////////////////////////////////////////////////////////////////////////////////////////////////
469 // Effect Start/End Callbacks
470 /////////////////////////////////////////////////////////////////////////////////////////////////
473 * Called when transition animation of the window's shown/hidden is started by window manager.
475 static Eina_Bool EcoreEventEffectStart(void *data, int type, void *event)
477 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
478 Ecore_Wl2_Event_Effect_Start *effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
479 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type );
482 if( effectStart->type < 3 ) // only under restack
484 windowBase->OnTransitionEffectEvent( WindowEffectState::START, static_cast<WindowEffectType>( effectStart->type ) );
487 return ECORE_CALLBACK_PASS_ON;
491 * Called when transition animation of the window's shown/hidden is ended by window manager.
493 static Eina_Bool EcoreEventEffectEnd(void *data, int type, void *event)
495 Ecore_Wl2_Event_Effect_Start *effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
496 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
497 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type );
500 if( effectEnd->type < 3 ) // only under restack
502 windowBase->OnTransitionEffectEvent( WindowEffectState::END, static_cast<WindowEffectType>( effectEnd->type ) );
505 return ECORE_CALLBACK_PASS_ON;
508 /////////////////////////////////////////////////////////////////////////////////////////////////
509 // Keyboard Repeat Settings Changed Callbacks
510 /////////////////////////////////////////////////////////////////////////////////////////////////
512 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void *data, int type, void *event)
514 Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed *keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>( event );
515 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
516 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id );
519 windowBase->OnKeyboardRepeatSettingsChanged();
522 return ECORE_CALLBACK_RENEW;
525 /////////////////////////////////////////////////////////////////////////////////////////////////
526 // Keymap Changed Callbacks
527 /////////////////////////////////////////////////////////////////////////////////////////////////
529 static Eina_Bool EcoreEventSeatKeymapChanged(void *data, int type, void *event)
531 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
534 windowBase->KeymapChanged( data, type, event );
537 return ECORE_CALLBACK_RENEW;
540 /////////////////////////////////////////////////////////////////////////////////////////////////
542 /////////////////////////////////////////////////////////////////////////////////////////////////
545 * Called when a font name is changed.
547 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
549 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
552 windowBase->OnFontNameChanged();
557 * Called when a font size is changed.
559 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
561 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
564 windowBase->OnFontSizeChanged();
568 /////////////////////////////////////////////////////////////////////////////////////////////////
569 // Window Redraw Request Event Callbacks
570 /////////////////////////////////////////////////////////////////////////////////////////////////
572 static Eina_Bool EcoreEventWindowRedrawRequest(void *data, int type, void *event)
574 Ecore_Wl2_Event_Window_Redraw_Request *windowRedrawRequest = static_cast<Ecore_Wl2_Event_Window_Redraw_Request *>(event);
575 WindowBaseEcoreWl2 *windowBase = static_cast<WindowBaseEcoreWl2 *>(data);
576 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", windowRedrawRequest->win );
579 windowBase->OnEcoreEventWindowRedrawRequest();
582 return ECORE_CALLBACK_RENEW;
585 /////////////////////////////////////////////////////////////////////////////////////////////////
586 // ElDBus Accessibility Callbacks
587 /////////////////////////////////////////////////////////////////////////////////////////////////
589 #ifdef DALI_ELDBUS_AVAILABLE
590 // Callback for Ecore ElDBus accessibility events.
591 static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
593 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( context );
596 windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
599 #endif // DALI_ELDBUS_AVAILABLE
601 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
603 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
606 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
610 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
612 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
615 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
619 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
623 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 )
627 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
629 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
632 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
636 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
640 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
642 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
645 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
649 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
653 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
657 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
661 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
665 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 )
669 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
671 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
674 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
678 const struct wl_registry_listener registryListener =
680 RegistryGlobalCallback,
681 RegistryGlobalCallbackRemove
684 const struct tizen_policy_listener tizenPolicyListener =
686 TizenPolicyConformant,
687 TizenPolicyConformantArea,
688 TizenPolicyNotificationChangeDone,
689 TizenPolicyTransientForDone,
690 TizenPolicyScreenModeChangeDone,
691 TizenPolicyIconifyStateChanged,
692 TizenPolicySupportedAuxiliaryHints,
693 TizenPolicyAllowedAuxiliaryHint,
694 TizenPolicyAuxiliaryMessage,
695 TizenPolicyConformantRegion
698 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
700 DisplayPolicyBrightnessChangeDone
703 } // unnamed namespace
705 WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any surface, bool isTransparent )
706 : mEcoreEventHandler(),
707 mEcoreWindow( NULL ),
712 mTizenPolicy( NULL ),
713 mTizenDisplayPolicy( NULL ),
715 mSupportedAuxiliaryHints(),
717 mNotificationLevel( -1 ),
718 mNotificationChangeState( 0 ),
719 mNotificationLevelChangeDone( true ),
721 mScreenOffModeChangeState( 0 ),
722 mScreenOffModeChangeDone( true ),
724 mBrightnessChangeState( 0 ),
725 mBrightnessChangeDone( true ),
727 mWindowPositionSize( positionSize ),
728 mOwnSurface( false ),
729 mMoveResizeSerial( 0 ),
730 mLastSubmittedMoveResizeSerial( 0 )
731 #ifdef DALI_ELDBUS_AVAILABLE
732 , mSystemConnection( NULL )
735 Initialize( positionSize, surface, isTransparent );
738 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
740 #ifdef DALI_ELDBUS_AVAILABLE
741 // Close down ElDBus connections.
742 if( mSystemConnection )
744 eldbus_connection_unref( mSystemConnection );
746 #endif // DALI_ELDBUS_AVAILABLE
748 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
749 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
751 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
753 ecore_event_handler_del( *iter );
755 mEcoreEventHandler.Clear();
759 wl_event_queue_destroy( mEventQueue );
762 mSupportedAuxiliaryHints.clear();
763 mAuxiliaryHints.clear();
765 if( mEglWindow != NULL )
767 wl_egl_window_destroy( mEglWindow );
773 ecore_wl2_window_free( mEcoreWindow );
775 WindowSystem::Shutdown();
779 void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
781 if( surface.Empty() == false )
783 // check we have a valid type
784 DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl2_Window *) ) && "Surface type is invalid" );
786 mEcoreWindow = AnyCast< Ecore_Wl2_Window* >( surface );
790 // we own the surface about to created
791 WindowSystem::Initialize();
794 CreateWindow( positionSize );
797 mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
799 SetTransparency( isTransparent );
801 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
802 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
803 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
804 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
805 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
807 // Register Rotate event
808 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
810 // Register Configure event
811 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this ) );
813 // Register Touch events
814 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
815 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
816 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
817 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
819 // Register Mouse wheel events
820 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
822 // Register Detent event
823 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
825 // Register Key events
826 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
827 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
829 // Register Selection event - clipboard selection
830 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
831 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
833 // Register Effect Start/End event
834 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this ) );
835 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this ) );
837 // Register Keyboard repeat event
838 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this ) );
840 // Register Window redraw request event
841 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this ) );
843 // Register Vconf notify - font name and size
844 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
845 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
847 InitializeEcoreElDBus();
849 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
850 mDisplay = ecore_wl2_display_get( display );
854 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
857 mEventQueue = wl_display_create_queue( mDisplay );
860 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
862 wl_registry* registry = wl_display_get_registry( displayWrapper );
863 wl_registry_add_listener( registry, ®istryListener, this );
866 wl_proxy_wrapper_destroy( displayWrapper );
870 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( display );
874 mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
876 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this ) );
879 // get auxiliary hint
880 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
886 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) ) ) )
888 mSupportedAuxiliaryHints.push_back( hint );
890 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
895 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
897 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
898 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
900 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
902 if( iconifyChangedEvent->iconified == EINA_TRUE )
904 mIconifyChangedSignal.Emit( true );
908 mIconifyChangedSignal.Emit( false );
910 handled = ECORE_CALLBACK_DONE;
916 Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
918 Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
920 if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
922 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
924 mFocusChangedSignal.Emit( true );
927 return ECORE_CALLBACK_PASS_ON;
930 Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
932 Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
934 if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
936 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
938 mFocusChangedSignal.Emit( false );
941 return ECORE_CALLBACK_PASS_ON;
944 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
946 Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
948 if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
950 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
952 mOutputTransformedSignal.Emit();
955 return ECORE_CALLBACK_PASS_ON;
958 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
960 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
962 if( ignoreTransformEvent->win == mEcoreWindow )
964 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
966 mOutputTransformedSignal.Emit();
969 return ECORE_CALLBACK_PASS_ON;
972 void WindowBaseEcoreWl2::OnRotation( void* data, int type, void* event )
974 Ecore_Wl2_Event_Window_Rotation* ev( static_cast< Ecore_Wl2_Event_Window_Rotation* >( event ) );
976 if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
978 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h );
980 RotationEvent rotationEvent;
981 rotationEvent.angle = ev->angle;
982 rotationEvent.winResize = 0;
984 if( ev->angle == 0 || ev->angle == 180 )
986 rotationEvent.width = ev->w;
987 rotationEvent.height = ev->h;
991 rotationEvent.width = ev->h;
992 rotationEvent.height = ev->w;
995 mWindowPositionSize.width = rotationEvent.width;
996 mWindowPositionSize.height = rotationEvent.height;
998 mRotationSignal.Emit( rotationEvent );
1002 void WindowBaseEcoreWl2::OnConfiguration( void* data, int type, void* event )
1004 Ecore_Wl2_Event_Window_Configure* ev( static_cast< Ecore_Wl2_Event_Window_Configure* >( event ) );
1006 if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1008 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1009 // by calling ecore_wl2_window_commit
1010 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1014 void WindowBaseEcoreWl2::OnMouseButtonDown( void* data, int type, void* event )
1016 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1018 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1020 Device::Class::Type deviceClass;
1021 Device::Subclass::Type deviceSubclass;
1023 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1024 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1026 PointState::Type state ( PointState::DOWN );
1028 if( deviceClass != Device::Class::Type::MOUSE )
1030 // Check if the buttons field is set and ensure it's the primary touch button.
1031 // If this event was triggered by buttons other than the primary button (used for touch), then
1032 // just send an interrupted event to Core.
1033 if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
1035 state = PointState::INTERRUPTED;
1039 Integration::Point point;
1040 point.SetDeviceId( touchEvent->multi.device );
1041 point.SetState( state );
1042 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1043 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1044 point.SetPressure( touchEvent->multi.pressure );
1045 point.SetAngle( Degree( touchEvent->multi.angle ) );
1046 point.SetDeviceClass( deviceClass );
1047 point.SetDeviceSubclass( deviceSubclass );
1048 point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1050 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1054 void WindowBaseEcoreWl2::OnMouseButtonUp( void* data, int type, void* event )
1056 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1058 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1060 Device::Class::Type deviceClass;
1061 Device::Subclass::Type deviceSubclass;
1063 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1064 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1066 Integration::Point point;
1067 point.SetDeviceId( touchEvent->multi.device );
1068 point.SetState( PointState::UP );
1069 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1070 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1071 point.SetPressure( touchEvent->multi.pressure );
1072 point.SetAngle( Degree( touchEvent->multi.angle ) );
1073 point.SetDeviceClass( deviceClass );
1074 point.SetDeviceSubclass( deviceSubclass );
1075 point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1077 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1081 void WindowBaseEcoreWl2::OnMouseButtonMove( void* data, int type, void* event )
1083 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
1085 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1087 Device::Class::Type deviceClass;
1088 Device::Subclass::Type deviceSubclass;
1090 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1091 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1093 Integration::Point point;
1094 point.SetDeviceId( touchEvent->multi.device );
1095 point.SetState( PointState::MOTION );
1096 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1097 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1098 point.SetPressure( touchEvent->multi.pressure );
1099 point.SetAngle( Degree( touchEvent->multi.angle ) );
1100 point.SetDeviceClass( deviceClass );
1101 point.SetDeviceSubclass( deviceSubclass );
1103 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1107 void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event )
1109 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1111 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1113 Integration::Point point;
1114 point.SetDeviceId( touchEvent->multi.device );
1115 point.SetState( PointState::INTERRUPTED );
1116 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
1118 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1120 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" );
1124 void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
1126 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
1128 if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1130 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
1132 Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
1134 mWheelEventSignal.Emit( wheelEvent );
1138 void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event )
1140 Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
1142 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" );
1144 int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
1145 int timeStamp = detentEvent->timestamp;
1147 Integration::WheelEvent wheelEvent( Integration::WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2( 0.0f, 0.0f ), 0, timeStamp );
1149 mWheelEventSignal.Emit( wheelEvent );
1152 void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event )
1154 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1156 if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1158 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" );
1160 std::string keyName( keyEvent->keyname );
1161 std::string logicalKey( "" );
1162 std::string keyString( "" );
1163 std::string compose( "" );
1165 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1166 if( keyEvent->compose )
1168 compose = keyEvent->compose;
1171 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1174 logicalKey = keyEvent->key;
1178 GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1182 // Get a specific key code from dali key look up table.
1183 keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1186 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1187 int modifier( keyEvent->modifiers );
1188 unsigned long time = keyEvent->timestamp;
1189 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1191 keyCode = atoi( keyEvent->keyname + 8 );
1194 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1195 if( keyEvent->string )
1197 keyString = keyEvent->string;
1200 std::string deviceName;
1201 Device::Class::Type deviceClass;
1202 Device::Subclass::Type deviceSubclass;
1204 GetDeviceName( keyEvent, deviceName );
1205 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1206 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1208 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass );
1210 mKeyEventSignal.Emit( keyEvent );
1214 void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event )
1216 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1218 if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1220 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" );
1222 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1223 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1224 if( keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL )
1226 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n" );
1229 #endif // Since ecore 1.23 version
1231 std::string keyName( keyEvent->keyname );
1232 std::string logicalKey( "" );
1233 std::string keyString( "" );
1234 std::string compose( "" );
1236 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1237 if( keyEvent->compose )
1239 compose = keyEvent->compose;
1242 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1245 logicalKey = keyEvent->key;
1249 GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1253 // Get a specific key code from dali key look up table.
1254 keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1257 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1258 int modifier( keyEvent->modifiers );
1259 unsigned long time = keyEvent->timestamp;
1260 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1262 keyCode = atoi( keyEvent->keyname + 8 );
1265 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1266 if( keyEvent->string )
1268 keyString = keyEvent->string;
1271 std::string deviceName;
1272 Device::Class::Type deviceClass;
1273 Device::Subclass::Type deviceSubclass;
1275 GetDeviceName( keyEvent, deviceName );
1276 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1277 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1279 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass );
1281 mKeyEventSignal.Emit( keyEvent );
1285 void WindowBaseEcoreWl2::OnDataSend( void* data, int type, void* event )
1287 mSelectionDataSendSignal.Emit( event );
1290 void WindowBaseEcoreWl2::OnDataReceive( void* data, int type, void* event )
1292 mSelectionDataReceivedSignal.Emit( event );
1295 void WindowBaseEcoreWl2::OnFontNameChanged()
1297 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1300 void WindowBaseEcoreWl2::OnFontSizeChanged()
1302 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1305 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1307 #ifdef DALI_ELDBUS_AVAILABLE
1308 AccessibilityInfo info;
1310 // The string defines the arg-list's respective types.
1311 if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
1313 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1316 mAccessibilitySignal.Emit( info );
1320 void WindowBaseEcoreWl2::OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type )
1322 mTransitionEffectEventSignal.Emit( state, type );
1325 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1327 mKeyboardRepeatSettingsChangedSignal.Emit();
1330 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1332 mWindowRedrawRequestSignal.Emit();
1335 void WindowBaseEcoreWl2::KeymapChanged(void *data, int type, void *event)
1337 Ecore_Wl2_Event_Seat_Keymap_Changed *changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>( event );
1338 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id );
1339 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( changed->display );
1342 mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
1346 void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1348 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1350 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1352 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1355 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1359 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1361 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1363 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1365 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1366 if( !mTizenDisplayPolicy )
1368 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1372 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1374 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1378 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1380 mTizenPolicy = NULL;
1381 mTizenDisplayPolicy = NULL;
1384 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1386 mNotificationLevel = level;
1387 mNotificationChangeState = state;
1388 mNotificationLevelChangeDone = true;
1390 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1393 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1395 mScreenOffMode = mode;
1396 mScreenOffModeChangeState = state;
1397 mScreenOffModeChangeDone = true;
1399 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1402 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1404 mBrightness = brightness;
1405 mBrightnessChangeState = state;
1406 mBrightnessChangeDone = true;
1408 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1411 void WindowBaseEcoreWl2::GetKeyCode( std::string keyName, int32_t& keyCode )
1413 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1414 KeyCodeMap foundKeyCode;
1416 sym = xkb_keysym_from_name( keyName.c_str(), XKB_KEYSYM_NO_FLAGS );
1417 if( sym == XKB_KEY_NoSymbol )
1419 DALI_LOG_ERROR( "Failed to get keysym in WindowBaseEcoreWl2\n" );
1423 foundKeyCode.keySym = sym;
1424 foundKeyCode.isKeyCode = false;
1425 xkb_keymap_key_for_each( mKeyMap, FindKeyCode, &foundKeyCode );
1426 keyCode = static_cast< int32_t >( foundKeyCode.keyCode );
1429 Any WindowBaseEcoreWl2::GetNativeWindow()
1431 return mEcoreWindow;
1434 int WindowBaseEcoreWl2::GetNativeWindowId()
1436 return ecore_wl2_window_id_get( mEcoreWindow );
1439 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow( int width, int height )
1441 mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1443 return static_cast< EGLNativeWindowType >( mEglWindow );
1446 void WindowBaseEcoreWl2::DestroyEglWindow()
1448 if( mEglWindow != NULL )
1450 wl_egl_window_destroy( mEglWindow );
1455 void WindowBaseEcoreWl2::SetEglWindowRotation( int angle )
1457 wl_egl_window_tizen_rotation rotation;
1463 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1468 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1473 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1478 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1483 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1488 wl_egl_window_tizen_set_rotation( mEglWindow, rotation );
1491 void WindowBaseEcoreWl2::SetEglWindowBufferTransform( int angle )
1493 wl_output_transform bufferTransform;
1499 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1504 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1509 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1514 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1519 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1524 wl_egl_window_tizen_set_buffer_transform( mEglWindow, bufferTransform );
1527 void WindowBaseEcoreWl2::SetEglWindowTransform( int angle )
1529 wl_output_transform windowTransform;
1535 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1540 windowTransform = WL_OUTPUT_TRANSFORM_90;
1545 windowTransform = WL_OUTPUT_TRANSFORM_180;
1550 windowTransform = WL_OUTPUT_TRANSFORM_270;
1555 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1560 wl_egl_window_tizen_set_window_transform( mEglWindow, windowTransform );
1563 void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize )
1565 wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1567 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1568 if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial )
1570 wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial );
1571 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1575 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1578 wl_egl_window_tizen_capability capability = static_cast< wl_egl_window_tizen_capability >( wl_egl_window_tizen_get_capabilities( mEglWindow ) );
1579 if( capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED )
1587 void WindowBaseEcoreWl2::Move( PositionSize positionSize )
1589 mWindowPositionSize = positionSize;
1590 ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1593 void WindowBaseEcoreWl2::Resize( PositionSize positionSize )
1595 mWindowPositionSize = positionSize;
1596 ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1599 void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize )
1601 mWindowPositionSize = positionSize;
1602 ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1605 void WindowBaseEcoreWl2::SetClass( const std::string& name, const std::string& className )
1607 ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
1608 ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
1611 void WindowBaseEcoreWl2::Raise()
1613 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1614 ecore_wl2_window_activate( mEcoreWindow );
1617 void WindowBaseEcoreWl2::Lower()
1619 ecore_wl2_window_lower( mEcoreWindow );
1622 void WindowBaseEcoreWl2::Activate()
1624 ecore_wl2_window_activate( mEcoreWindow );
1627 void WindowBaseEcoreWl2::SetAvailableAnlges( const std::vector< int >& angles )
1629 int rotations[4] = { 0 };
1630 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size() );
1631 for( std::size_t i = 0; i < angles.size(); ++i )
1633 rotations[i] = static_cast< int >( angles[i] );
1634 DALI_LOG_RELEASE_INFO( "%d ", rotations[i] );
1636 ecore_wl2_window_available_rotations_set( mEcoreWindow, rotations, angles.size() );
1639 void WindowBaseEcoreWl2::SetPreferredAngle( int angle )
1641 ecore_wl2_window_preferred_rotation_set( mEcoreWindow, angle );
1644 void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
1646 ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
1649 void WindowBaseEcoreWl2::Show()
1653 ecore_wl2_window_geometry_set( mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height );
1657 ecore_wl2_window_show( mEcoreWindow );
1660 void WindowBaseEcoreWl2::Hide()
1663 ecore_wl2_window_hide( mEcoreWindow );
1666 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1668 return mSupportedAuxiliaryHints.size();
1671 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
1673 if( index >= GetSupportedAuxiliaryHintCount() )
1675 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1678 return mSupportedAuxiliaryHints[index];
1681 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1683 bool supported = false;
1685 // Check if the hint is suppported
1686 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1697 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1701 // Check if the hint is already added
1702 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1704 if( mAuxiliaryHints[i].first == hint )
1706 // Just change the value
1707 mAuxiliaryHints[i].second = value;
1709 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1711 return i + 1; // id is index + 1
1716 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1718 unsigned int id = mAuxiliaryHints.size();
1720 ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1722 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1727 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
1729 if( id == 0 || id > mAuxiliaryHints.size() )
1731 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1735 mAuxiliaryHints[id - 1].second = std::string();
1737 ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1739 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1744 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1746 if( id == 0 || id > mAuxiliaryHints.size() )
1748 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1752 mAuxiliaryHints[id - 1].second = value;
1754 ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1756 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() );
1761 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
1763 if( id == 0 || id > mAuxiliaryHints.size() )
1765 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1766 return std::string();
1769 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() );
1771 return mAuxiliaryHints[id - 1].second;
1774 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
1776 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1778 if( mAuxiliaryHints[i].first == hint )
1780 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1785 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1790 void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
1792 ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1795 void WindowBaseEcoreWl2::SetType( Dali::WindowType type )
1797 Ecore_Wl2_Window_Type windowType;
1801 case Dali::WindowType::NORMAL:
1803 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1806 case Dali::WindowType::NOTIFICATION:
1808 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1811 case Dali::WindowType::UTILITY:
1813 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1816 case Dali::WindowType::DIALOG:
1818 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1823 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1828 ecore_wl2_window_type_set( mEcoreWindow, windowType );
1831 bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::WindowNotificationLevel level )
1833 while( !mTizenPolicy )
1835 wl_display_dispatch_queue( mDisplay, mEventQueue );
1838 int notificationLevel;
1842 case Dali::WindowNotificationLevel::NONE:
1844 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1847 case Dali::WindowNotificationLevel::BASE:
1849 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1852 case Dali::WindowNotificationLevel::MEDIUM:
1854 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1857 case Dali::WindowNotificationLevel::HIGH:
1859 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1862 case Dali::WindowNotificationLevel::TOP:
1864 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1869 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
1870 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1875 mNotificationLevelChangeDone = false;
1876 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1878 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
1882 while( !mNotificationLevelChangeDone && count < 3 )
1884 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1885 wl_display_dispatch_queue( mDisplay, mEventQueue );
1889 if( !mNotificationLevelChangeDone )
1891 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1894 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1896 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
1900 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1905 Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
1907 while( !mTizenPolicy )
1909 wl_display_dispatch_queue( mDisplay, mEventQueue );
1914 while( !mNotificationLevelChangeDone && count < 3 )
1916 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1917 wl_display_dispatch_queue( mDisplay, mEventQueue );
1921 if( !mNotificationLevelChangeDone )
1923 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1924 return Dali::WindowNotificationLevel::NONE;
1927 Dali::WindowNotificationLevel level;
1929 switch( mNotificationLevel )
1931 case TIZEN_POLICY_LEVEL_NONE:
1933 level = Dali::WindowNotificationLevel::NONE;
1936 case TIZEN_POLICY_LEVEL_DEFAULT:
1938 level = Dali::WindowNotificationLevel::BASE;
1941 case TIZEN_POLICY_LEVEL_MEDIUM:
1943 level = Dali::WindowNotificationLevel::MEDIUM;
1946 case TIZEN_POLICY_LEVEL_HIGH:
1948 level = Dali::WindowNotificationLevel::HIGH;
1951 case TIZEN_POLICY_LEVEL_TOP:
1953 level = Dali::WindowNotificationLevel::TOP;
1958 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
1959 level = Dali::WindowNotificationLevel::NONE;
1964 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
1969 void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
1971 while( !mTizenPolicy )
1973 wl_display_dispatch_queue( mDisplay, mEventQueue );
1976 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
1979 bool WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
1981 while( !mTizenPolicy )
1983 wl_display_dispatch_queue( mDisplay, mEventQueue );
1986 mScreenOffModeChangeDone = false;
1987 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1989 unsigned int mode = 0;
1991 switch( screenOffMode )
1993 case WindowScreenOffMode::TIMEOUT:
1998 case WindowScreenOffMode::NEVER:
2005 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
2009 while( !mScreenOffModeChangeDone && count < 3 )
2011 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2012 wl_display_dispatch_queue( mDisplay, mEventQueue );
2016 if( !mScreenOffModeChangeDone )
2018 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
2021 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2023 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
2027 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
2032 WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
2034 while( !mTizenPolicy )
2036 wl_display_dispatch_queue( mDisplay, mEventQueue );
2041 while( !mScreenOffModeChangeDone && count < 3 )
2043 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2044 wl_display_dispatch_queue( mDisplay, mEventQueue );
2048 if( !mScreenOffModeChangeDone )
2050 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
2051 return WindowScreenOffMode::TIMEOUT;
2054 WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
2056 switch( mScreenOffMode )
2060 screenMode = WindowScreenOffMode::TIMEOUT;
2065 screenMode = WindowScreenOffMode::NEVER;
2070 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
2075 bool WindowBaseEcoreWl2::SetBrightness( int brightness )
2077 while( !mTizenDisplayPolicy )
2079 wl_display_dispatch_queue( mDisplay, mEventQueue );
2082 mBrightnessChangeDone = false;
2083 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2085 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
2089 while( !mBrightnessChangeDone && count < 3 )
2091 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2092 wl_display_dispatch_queue( mDisplay, mEventQueue );
2096 if( !mBrightnessChangeDone )
2098 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
2101 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2103 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
2107 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
2112 int WindowBaseEcoreWl2::GetBrightness() const
2114 while( !mTizenDisplayPolicy )
2116 wl_display_dispatch_queue( mDisplay, mEventQueue );
2121 while( !mBrightnessChangeDone && count < 3 )
2123 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2124 wl_display_dispatch_queue( mDisplay, mEventQueue );
2128 if( !mBrightnessChangeDone )
2130 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
2134 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
2139 bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
2141 Ecore_Wl2_Window_Keygrab_Mode mode;
2145 case KeyGrab::TOPMOST:
2147 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2150 case KeyGrab::SHARED:
2152 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2155 case KeyGrab::OVERRIDE_EXCLUSIVE:
2157 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2160 case KeyGrab::EXCLUSIVE:
2162 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2171 return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
2174 bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
2176 return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
2179 bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
2181 int keyCount = key.Count();
2182 int keyGrabModeCount = grabMode.Count();
2184 if( keyCount != keyGrabModeCount || keyCount == 0 )
2191 Eina_List* keyList = NULL;
2192 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2194 for( int index = 0; index < keyCount; ++index )
2196 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2198 switch( grabMode[index] )
2200 case KeyGrab::TOPMOST:
2202 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2205 case KeyGrab::SHARED:
2207 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2210 case KeyGrab::OVERRIDE_EXCLUSIVE:
2212 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2215 case KeyGrab::EXCLUSIVE:
2217 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2222 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2227 keyList = eina_list_append( keyList, &info );
2230 Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
2232 result.Resize( keyCount, true );
2234 Eina_List* l = NULL;
2235 Eina_List* m = NULL;
2236 void* listData = NULL;
2238 if( grabList != NULL )
2240 EINA_LIST_FOREACH( grabList, m, data )
2243 EINA_LIST_FOREACH( keyList, l, listData )
2245 if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
2247 DALI_LOG_ERROR( "input key list has null data!" );
2251 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2253 result[index] = false;
2262 eina_list_free( keyList );
2263 eina_list_free( grabList );
2269 bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2271 int keyCount = key.Count();
2279 Eina_List* keyList = NULL;
2280 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2282 for( int index = 0; index < keyCount; ++index )
2284 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2285 keyList = eina_list_append( keyList, &info );
2288 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
2290 result.Resize( keyCount, true );
2292 Eina_List* l = NULL;
2293 Eina_List* m = NULL;
2294 void *listData = NULL;
2297 if( ungrabList != NULL )
2299 EINA_LIST_FOREACH( ungrabList, m, data )
2302 EINA_LIST_FOREACH( keyList, l, listData )
2304 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2306 result[index] = false;
2315 eina_list_free( keyList );
2316 eina_list_free( ungrabList );
2322 void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2327 Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mEcoreWindow );
2329 // 1 inch = 25.4 millimeters
2330 xres = ecore_wl2_output_dpi_get( output );
2331 yres = ecore_wl2_output_dpi_get( output );
2333 dpiHorizontal = int( xres + 0.5f ); // rounding
2334 dpiVertical = int( yres + 0.5f );
2337 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2341 if( ecore_wl2_window_ignore_output_transform_get( mEcoreWindow ) )
2347 transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mEcoreWindow ) );
2350 return transform * 90;
2353 void WindowBaseEcoreWl2::SetWindowRotationAngle( int degree )
2355 ecore_wl2_window_rotation_set( mEcoreWindow, degree );
2358 void WindowBaseEcoreWl2::WindowRotationCompleted( int degree, int width, int height )
2360 ecore_wl2_window_rotation_change_done_send( mEcoreWindow, degree, width, height );
2363 void WindowBaseEcoreWl2::SetTransparency( bool transparent )
2365 ecore_wl2_window_alpha_set( mEcoreWindow, transparent );
2368 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2370 #ifdef DALI_ELDBUS_AVAILABLE
2371 Eldbus_Object* object;
2372 Eldbus_Proxy* manager;
2374 if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2376 DALI_LOG_ERROR( "Unable to get system bus\n" );
2379 object = eldbus_object_get( mSystemConnection, BUS, PATH );
2382 DALI_LOG_ERROR( "Getting object failed\n" );
2386 manager = eldbus_proxy_get( object, INTERFACE );
2389 DALI_LOG_ERROR( "Getting proxy failed\n" );
2393 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2395 DALI_LOG_ERROR( "No signal handler returned\n" );
2400 void WindowBaseEcoreWl2::CreateWindow( PositionSize positionSize )
2402 Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL );
2405 DALI_ASSERT_ALWAYS( 0 && "Failed to get display" );
2408 ecore_wl2_display_sync( display );
2410 mEcoreWindow = ecore_wl2_window_new( display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
2412 if ( mEcoreWindow == 0 )
2414 DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2418 ecore_wl2_window_type_set( mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL );
2421 void WindowBaseEcoreWl2::SetParent( WindowBase* parentWinBase )
2423 Ecore_Wl2_Window* ecoreParent = NULL;
2426 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>( parentWinBase );
2427 ecoreParent = winBaseEcore2->mEcoreWindow;
2429 ecore_wl2_window_parent_set( mEcoreWindow, ecoreParent );
2432 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2434 return wl_egl_window_tizen_create_commit_sync_fd( mEglWindow );
2437 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2439 return wl_egl_window_tizen_create_presentation_sync_fd( mEglWindow );
2442 } // namespace Adaptor
2444 } // namespace Internal
2448 #pragma GCC diagnostic pop