2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
23 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/common/window-system.h>
28 #include <dali/internal/window-system/common/window-render-surface.h>
29 #include <dali/internal/input/common/key-impl.h>
32 #include <dali/public-api/object/any.h>
33 #include <dali/public-api/events/mouse-button.h>
34 #include <dali/integration-api/debug.h>
35 #include <Ecore_Input.h>
37 #include <vconf-keys.h>
38 #include <wayland-egl-tizen.h>
52 #if defined(DEBUG_ENABLED)
53 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
56 const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
57 const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
59 const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
62 const char* BUS = "org.enlightenment.wm-screen-reader";
63 const char* INTERFACE = "org.tizen.GestureNavigation";
64 const char* PATH = "/org/tizen/GestureNavigation";
69 xkb_keycode_t keyCode;
74 * Get the device name from the provided ecore key event
76 void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
78 const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
82 result = ecoreDeviceName;
87 * Get the device class from the provided ecore event
89 void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
91 switch( ecoreDeviceClass )
93 case ECORE_DEVICE_CLASS_SEAT:
95 deviceClass = Device::Class::USER;
98 case ECORE_DEVICE_CLASS_KEYBOARD:
100 deviceClass = Device::Class::KEYBOARD;
103 case ECORE_DEVICE_CLASS_MOUSE:
105 deviceClass = Device::Class::MOUSE;
108 case ECORE_DEVICE_CLASS_TOUCH:
110 deviceClass = Device::Class::TOUCH;
113 case ECORE_DEVICE_CLASS_PEN:
115 deviceClass = Device::Class::PEN;
118 case ECORE_DEVICE_CLASS_POINTER:
120 deviceClass = Device::Class::POINTER;
123 case ECORE_DEVICE_CLASS_GAMEPAD:
125 deviceClass = Device::Class::GAMEPAD;
130 deviceClass = Device::Class::NONE;
136 void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
138 switch( ecoreDeviceSubclass )
140 case ECORE_DEVICE_SUBCLASS_FINGER:
142 deviceSubclass = Device::Subclass::FINGER;
145 case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
147 deviceSubclass = Device::Subclass::FINGERNAIL;
150 case ECORE_DEVICE_SUBCLASS_KNUCKLE:
152 deviceSubclass = Device::Subclass::KNUCKLE;
155 case ECORE_DEVICE_SUBCLASS_PALM:
157 deviceSubclass = Device::Subclass::PALM;
160 case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
162 deviceSubclass = Device::Subclass::HAND_SIDE;
165 case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
167 deviceSubclass = Device::Subclass::HAND_FLAT;
170 case ECORE_DEVICE_SUBCLASS_PEN_TIP:
172 deviceSubclass = Device::Subclass::PEN_TIP;
175 case ECORE_DEVICE_SUBCLASS_TRACKPAD:
177 deviceSubclass = Device::Subclass::TRACKPAD;
180 case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
182 deviceSubclass = Device::Subclass::TRACKPOINT;
185 case ECORE_DEVICE_SUBCLASS_TRACKBALL:
187 deviceSubclass = Device::Subclass::TRACKBALL;
190 case ECORE_DEVICE_SUBCLASS_REMOCON:
192 deviceSubclass = Device::Subclass::REMOCON;
195 case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
197 deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
202 deviceSubclass = Device::Subclass::NONE;
209 void FindKeyCode( struct xkb_keymap* keyMap, xkb_keycode_t key, void* data )
211 KeyCodeMap* foundKeyCode = static_cast< KeyCodeMap* >( data );
212 if( foundKeyCode->isKeyCode )
217 xkb_keysym_t keySym = foundKeyCode->keySym;
219 const xkb_keysym_t* symsOut = NULL;
221 nsyms = xkb_keymap_key_get_syms_by_level( keyMap, key, 0, 0, &symsOut );
223 if( nsyms && symsOut )
225 if( *symsOut == keySym )
227 foundKeyCode->keyCode = key;
228 foundKeyCode->isKeyCode = true;
233 /////////////////////////////////////////////////////////////////////////////////////////////////
235 /////////////////////////////////////////////////////////////////////////////////////////////////
237 /// Called when the window iconify state is changed.
238 static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
240 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
243 return windowBase->OnIconifyStateChanged( data, type, event );
246 return ECORE_CALLBACK_PASS_ON;
249 /// Called when the window gains focus
250 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
252 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
255 return windowBase->OnFocusIn( data, type, event );
258 return ECORE_CALLBACK_PASS_ON;
261 /// Called when the window loses focus
262 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
264 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
267 return windowBase->OnFocusOut( data, type, event );
270 return ECORE_CALLBACK_PASS_ON;
273 /// Called when the output is transformed
274 static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
276 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
279 return windowBase->OnOutputTransform( data, type, event );
282 return ECORE_CALLBACK_PASS_ON;
285 /// Called when the output transform should be ignored
286 static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
288 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
291 return windowBase->OnIgnoreOutputTransform( data, type, event );
294 return ECORE_CALLBACK_PASS_ON;
298 * Called when rotate event is recevied.
300 static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
302 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
305 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::EcoreEventRotate\n" );
306 windowBase->OnRotation( data, type, event );
308 return ECORE_CALLBACK_PASS_ON;
312 * Called when configure event is recevied.
314 static Eina_Bool EcoreEventConfigure( void* data, int type, void* event )
316 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
319 windowBase->OnConfiguration( data, type, event );
321 return ECORE_CALLBACK_PASS_ON;
324 /////////////////////////////////////////////////////////////////////////////////////////////////
326 /////////////////////////////////////////////////////////////////////////////////////////////////
329 * Called when a touch down is received.
331 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
333 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
336 windowBase->OnMouseButtonDown( data, type, event );
338 return ECORE_CALLBACK_PASS_ON;
342 * Called when a touch up is received.
344 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
346 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
349 windowBase->OnMouseButtonUp( data, type, event );
351 return ECORE_CALLBACK_PASS_ON;
355 * Called when a touch motion is received.
357 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
359 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
362 windowBase->OnMouseButtonMove( data, type, event );
364 return ECORE_CALLBACK_PASS_ON;
368 * Called when a touch is canceled.
370 static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
372 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
375 windowBase->OnMouseButtonCancel( data, type, event );
377 return ECORE_CALLBACK_PASS_ON;
381 * Called when a mouse wheel is received.
383 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
385 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
388 windowBase->OnMouseWheel( data, type, event );
390 return ECORE_CALLBACK_PASS_ON;
394 * Called when a detent rotation event is recevied.
396 static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
398 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
401 windowBase->OnDetentRotation( data, type, event );
403 return ECORE_CALLBACK_PASS_ON;
406 /////////////////////////////////////////////////////////////////////////////////////////////////
408 /////////////////////////////////////////////////////////////////////////////////////////////////
411 * Called when a key down is received.
413 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
415 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
418 windowBase->OnKeyDown( data, type, event );
420 return ECORE_CALLBACK_PASS_ON;
424 * Called when a key up is received.
426 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
428 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
431 windowBase->OnKeyUp( data, type, event );
433 return ECORE_CALLBACK_PASS_ON;
436 /////////////////////////////////////////////////////////////////////////////////////////////////
437 // Selection Callbacks
438 /////////////////////////////////////////////////////////////////////////////////////////////////
441 * Called when the source window notifies us the content in clipboard is selected.
443 static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
445 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
448 windowBase->OnDataSend( data, type, event );
450 return ECORE_CALLBACK_PASS_ON;
454 * Called when the source window sends us about the selected content.
455 * For example, when item is selected in the clipboard.
457 static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
459 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
462 windowBase->OnDataReceive( data, type, event );
464 return ECORE_CALLBACK_PASS_ON;
467 /////////////////////////////////////////////////////////////////////////////////////////////////
468 // Effect Start/End Callbacks
469 /////////////////////////////////////////////////////////////////////////////////////////////////
472 * Called when transition animation of the window's shown/hidden is started by window manager.
474 static Eina_Bool EcoreEventEffectStart(void *data, int type, void *event)
476 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
477 Ecore_Wl2_Event_Effect_Start *effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
478 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type );
481 if( effectStart->type < 3 ) // only under restack
483 windowBase->OnTransitionEffectEvent( DevelWindow::EffectState::START, static_cast<DevelWindow::EffectType>( effectStart->type ) );
486 return ECORE_CALLBACK_PASS_ON;
490 * Called when transition animation of the window's shown/hidden is ended by window manager.
492 static Eina_Bool EcoreEventEffectEnd(void *data, int type, void *event)
494 Ecore_Wl2_Event_Effect_Start *effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
495 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
496 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type );
499 if( effectEnd->type < 3 ) // only under restack
501 windowBase->OnTransitionEffectEvent( DevelWindow::EffectState::END, static_cast<DevelWindow::EffectType>( effectEnd->type ) );
504 return ECORE_CALLBACK_PASS_ON;
507 /////////////////////////////////////////////////////////////////////////////////////////////////
508 // Keyboard Repeat Settings Changed Callbacks
509 /////////////////////////////////////////////////////////////////////////////////////////////////
511 static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void *data, int type, void *event)
513 Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed *keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>( event );
514 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
515 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id );
518 windowBase->OnKeyboardRepeatSettingsChanged();
521 return ECORE_CALLBACK_RENEW;
524 /////////////////////////////////////////////////////////////////////////////////////////////////
525 // Keymap Changed Callbacks
526 /////////////////////////////////////////////////////////////////////////////////////////////////
528 static Eina_Bool EcoreEventSeatKeymapChanged(void *data, int type, void *event)
530 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
533 windowBase->KeymapChanged( data, type, event );
536 return ECORE_CALLBACK_RENEW;
539 /////////////////////////////////////////////////////////////////////////////////////////////////
541 /////////////////////////////////////////////////////////////////////////////////////////////////
544 * Called when a font name is changed.
546 static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
548 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
551 windowBase->OnFontNameChanged();
556 * Called when a font size is changed.
558 static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
560 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
563 windowBase->OnFontSizeChanged();
567 /////////////////////////////////////////////////////////////////////////////////////////////////
568 // Window Redraw Request Event Callbacks
569 /////////////////////////////////////////////////////////////////////////////////////////////////
571 static Eina_Bool EcoreEventWindowRedrawRequest(void *data, int type, void *event)
573 Ecore_Wl2_Event_Window_Redraw_Request *windowRedrawRequest = static_cast<Ecore_Wl2_Event_Window_Redraw_Request *>(event);
574 WindowBaseEcoreWl2 *windowBase = static_cast<WindowBaseEcoreWl2 *>(data);
575 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", windowRedrawRequest->win );
578 windowBase->OnEcoreEventWindowRedrawRequest();
581 return ECORE_CALLBACK_RENEW;
584 /////////////////////////////////////////////////////////////////////////////////////////////////
585 // ElDBus Accessibility Callbacks
586 /////////////////////////////////////////////////////////////////////////////////////////////////
588 #ifdef DALI_ELDBUS_AVAILABLE
589 // Callback for Ecore ElDBus accessibility events.
590 static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
592 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( context );
595 windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
599 // Callback for Ecore ElDBus accessibility quickpanel changed event.
600 static void EcoreElDBusAccessibilityQuickpanelChanged( void* context, const Eldbus_Message* message )
602 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( context );
605 windowBase->OnEcoreElDBusAccessibilityQuickpanelChanged( context, message );
608 #endif // DALI_ELDBUS_AVAILABLE
610 static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
612 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
615 windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
619 static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
621 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
624 windowBase->RegistryGlobalCallbackRemove( data, registry, id );
628 static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
632 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 )
636 static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
638 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
641 windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
645 static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
649 static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
651 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
654 windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
658 static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
662 static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
666 static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
670 static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
674 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 )
678 static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
680 WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
683 windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
687 const struct wl_registry_listener registryListener =
689 RegistryGlobalCallback,
690 RegistryGlobalCallbackRemove
693 const struct tizen_policy_listener tizenPolicyListener =
695 TizenPolicyConformant,
696 TizenPolicyConformantArea,
697 TizenPolicyNotificationChangeDone,
698 TizenPolicyTransientForDone,
699 TizenPolicyScreenModeChangeDone,
700 TizenPolicyIconifyStateChanged,
701 TizenPolicySupportedAuxiliaryHints,
702 TizenPolicyAllowedAuxiliaryHint,
703 TizenPolicyAuxiliaryMessage,
704 TizenPolicyConformantRegion
707 const struct tizen_display_policy_listener tizenDisplayPolicyListener =
709 DisplayPolicyBrightnessChangeDone
712 } // unnamed namespace
714 WindowBaseEcoreWl2::WindowBaseEcoreWl2( Dali::PositionSize positionSize, Any surface, bool isTransparent )
715 : mEcoreEventHandler(),
716 mEcoreWindow( NULL ),
721 mTizenPolicy( NULL ),
722 mTizenDisplayPolicy( NULL ),
724 mSupportedAuxiliaryHints(),
726 mNotificationLevel( -1 ),
727 mNotificationChangeState( 0 ),
728 mNotificationLevelChangeDone( true ),
730 mScreenOffModeChangeState( 0 ),
731 mScreenOffModeChangeDone( true ),
733 mBrightnessChangeState( 0 ),
734 mBrightnessChangeDone( true ),
736 mWindowPositionSize( positionSize ),
737 mOwnSurface( false ),
738 mMoveResizeSerial( 0 ),
739 mLastSubmittedMoveResizeSerial( 0 ),
740 mWindowRotationAngle( 0 ),
741 mScreenRotationAngle( 0 ),
742 mSupportedPreProtation( 0 )
743 #ifdef DALI_ELDBUS_AVAILABLE
744 , mSystemConnection( NULL )
747 Initialize( positionSize, surface, isTransparent );
750 WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
752 #ifdef DALI_ELDBUS_AVAILABLE
753 // Close down ElDBus connections.
754 if( mSystemConnection )
756 eldbus_connection_unref( mSystemConnection );
758 #endif // DALI_ELDBUS_AVAILABLE
760 vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
761 vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
763 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
765 ecore_event_handler_del( *iter );
767 mEcoreEventHandler.Clear();
771 wl_event_queue_destroy( mEventQueue );
774 mSupportedAuxiliaryHints.clear();
775 mAuxiliaryHints.clear();
777 if( mEglWindow != NULL )
779 wl_egl_window_destroy( mEglWindow );
785 ecore_wl2_window_free( mEcoreWindow );
787 WindowSystem::Shutdown();
791 void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
793 if( surface.Empty() == false )
795 // check we have a valid type
796 DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl2_Window *) ) && "Surface type is invalid" );
798 mEcoreWindow = AnyCast< Ecore_Wl2_Window* >( surface );
802 // we own the surface about to created
803 WindowSystem::Initialize();
806 CreateWindow( positionSize );
809 mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
811 SetTransparency( isTransparent );
813 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
814 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
815 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
816 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
817 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
819 // Register Rotate event
820 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
822 // Register Configure event
823 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this ) );
825 // Register Touch events
826 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
827 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
828 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
829 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
831 // Register Mouse wheel events
832 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
834 // Register Detent event
835 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
837 // Register Key events
838 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
839 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
841 // Register Selection event - clipboard selection
842 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
843 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
845 // Register Effect Start/End event
846 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this ) );
847 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this ) );
849 // Register Keyboard repeat event
850 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this ) );
852 // Register Window redraw request event
853 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this ) );
855 // Register Vconf notify - font name and size
856 vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
857 vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
859 InitializeEcoreElDBus();
861 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
862 mDisplay = ecore_wl2_display_get( display );
866 wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
869 mEventQueue = wl_display_create_queue( mDisplay );
872 wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
874 wl_registry* registry = wl_display_get_registry( displayWrapper );
875 wl_registry_add_listener( registry, ®istryListener, this );
878 wl_proxy_wrapper_destroy( displayWrapper );
882 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( display );
886 mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
888 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this ) );
891 // get auxiliary hint
892 Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
898 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) ) ) )
900 mSupportedAuxiliaryHints.push_back( hint );
902 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
907 Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
909 Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
910 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
912 if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
914 if( iconifyChangedEvent->iconified == EINA_TRUE )
916 mIconifyChangedSignal.Emit( true );
920 mIconifyChangedSignal.Emit( false );
922 handled = ECORE_CALLBACK_DONE;
928 Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
930 Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
932 if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
934 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
936 mFocusChangedSignal.Emit( true );
939 return ECORE_CALLBACK_PASS_ON;
942 Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
944 Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
946 if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
948 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
950 mFocusChangedSignal.Emit( false );
953 return ECORE_CALLBACK_PASS_ON;
956 Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
958 Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
960 if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
962 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
964 mOutputTransformedSignal.Emit();
967 return ECORE_CALLBACK_PASS_ON;
970 Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
972 Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
974 if( ignoreTransformEvent->win == mEcoreWindow )
976 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
978 mOutputTransformedSignal.Emit();
981 return ECORE_CALLBACK_PASS_ON;
984 void WindowBaseEcoreWl2::OnRotation( void* data, int type, void* event )
986 Ecore_Wl2_Event_Window_Rotation* ev( static_cast< Ecore_Wl2_Event_Window_Rotation* >( event ) );
988 if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
990 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h );
992 RotationEvent rotationEvent;
993 rotationEvent.angle = ev->angle;
994 rotationEvent.winResize = 0;
996 if( ev->angle == 0 || ev->angle == 180 )
998 rotationEvent.width = ev->w;
999 rotationEvent.height = ev->h;
1003 rotationEvent.width = ev->h;
1004 rotationEvent.height = ev->w;
1007 mWindowPositionSize.width = rotationEvent.width;
1008 mWindowPositionSize.height = rotationEvent.height;
1010 mRotationSignal.Emit( rotationEvent );
1014 void WindowBaseEcoreWl2::OnConfiguration( void* data, int type, void* event )
1016 Ecore_Wl2_Event_Window_Configure* ev( static_cast< Ecore_Wl2_Event_Window_Configure* >( event ) );
1018 if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1020 // Note: To comply with the wayland protocol, Dali should make an ack_configure
1021 // by calling ecore_wl2_window_commit
1022 ecore_wl2_window_commit(mEcoreWindow, EINA_FALSE);
1026 void WindowBaseEcoreWl2::OnMouseButtonDown( void* data, int type, void* event )
1028 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1030 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1032 Device::Class::Type deviceClass;
1033 Device::Subclass::Type deviceSubclass;
1035 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1036 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1038 PointState::Type state ( PointState::DOWN );
1040 if( deviceClass != Device::Class::Type::MOUSE )
1042 // Check if the buttons field is set and ensure it's the primary touch button.
1043 // If this event was triggered by buttons other than the primary button (used for touch), then
1044 // just send an interrupted event to Core.
1045 if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
1047 state = PointState::INTERRUPTED;
1051 Integration::Point point;
1052 point.SetDeviceId( touchEvent->multi.device );
1053 point.SetState( state );
1054 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1055 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1056 point.SetPressure( touchEvent->multi.pressure );
1057 point.SetAngle( Degree( touchEvent->multi.angle ) );
1058 point.SetDeviceClass( deviceClass );
1059 point.SetDeviceSubclass( deviceSubclass );
1060 point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1062 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1066 void WindowBaseEcoreWl2::OnMouseButtonUp( void* data, int type, void* event )
1068 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1070 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1072 Device::Class::Type deviceClass;
1073 Device::Subclass::Type deviceSubclass;
1075 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1076 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1078 Integration::Point point;
1079 point.SetDeviceId( touchEvent->multi.device );
1080 point.SetState( PointState::UP );
1081 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1082 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1083 point.SetPressure( touchEvent->multi.pressure );
1084 point.SetAngle( Degree( touchEvent->multi.angle ) );
1085 point.SetDeviceClass( deviceClass );
1086 point.SetDeviceSubclass( deviceSubclass );
1087 point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
1089 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1093 void WindowBaseEcoreWl2::OnMouseButtonMove( void* data, int type, void* event )
1095 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
1097 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1099 Device::Class::Type deviceClass;
1100 Device::Subclass::Type deviceSubclass;
1102 GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
1103 GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
1105 Integration::Point point;
1106 point.SetDeviceId( touchEvent->multi.device );
1107 point.SetState( PointState::MOTION );
1108 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
1109 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
1110 point.SetPressure( touchEvent->multi.pressure );
1111 point.SetAngle( Degree( touchEvent->multi.angle ) );
1112 point.SetDeviceClass( deviceClass );
1113 point.SetDeviceSubclass( deviceSubclass );
1115 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1119 void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event )
1121 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
1123 if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1125 Integration::Point point;
1126 point.SetDeviceId( touchEvent->multi.device );
1127 point.SetState( PointState::INTERRUPTED );
1128 point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
1130 mTouchEventSignal.Emit( point, touchEvent->timestamp );
1132 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" );
1136 void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
1138 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
1140 if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1142 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 );
1144 Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
1146 mWheelEventSignal.Emit( wheelEvent );
1150 void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event )
1152 Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
1154 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n" );
1156 int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
1157 int timeStamp = detentEvent->timestamp;
1159 Integration::WheelEvent wheelEvent( Integration::WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2( 0.0f, 0.0f ), 0, timeStamp );
1161 mWheelEventSignal.Emit( wheelEvent );
1164 void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event )
1166 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1168 if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1170 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n" );
1172 std::string keyName( keyEvent->keyname );
1173 std::string logicalKey( "" );
1174 std::string keyString( "" );
1175 std::string compose( "" );
1177 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1178 if( keyEvent->compose )
1180 compose = keyEvent->compose;
1183 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1186 logicalKey = keyEvent->key;
1190 GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1194 // Get a specific key code from dali key look up table.
1195 keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1198 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1199 int modifier( keyEvent->modifiers );
1200 unsigned long time = keyEvent->timestamp;
1201 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1203 keyCode = atoi( keyEvent->keyname + 8 );
1206 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1207 if( keyEvent->string )
1209 keyString = keyEvent->string;
1212 std::string deviceName;
1213 Device::Class::Type deviceClass;
1214 Device::Subclass::Type deviceSubclass;
1216 GetDeviceName( keyEvent, deviceName );
1217 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1218 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1220 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass );
1222 mKeyEventSignal.Emit( keyEvent );
1226 void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event )
1228 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
1230 if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
1232 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n" );
1234 #if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
1235 // Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
1236 if( keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL )
1238 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n" );
1241 #endif // Since ecore 1.23 version
1243 std::string keyName( keyEvent->keyname );
1244 std::string logicalKey( "" );
1245 std::string keyString( "" );
1246 std::string compose( "" );
1248 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
1249 if( keyEvent->compose )
1251 compose = keyEvent->compose;
1254 // Ensure key symbol is not NULL as keys like SHIFT have a null string.
1257 logicalKey = keyEvent->key;
1261 GetKeyCode( keyName, keyCode ); // Get key code dynamically.
1265 // Get a specific key code from dali key look up table.
1266 keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
1269 keyCode = ( keyCode == -1 ) ? 0 : keyCode;
1270 int modifier( keyEvent->modifiers );
1271 unsigned long time = keyEvent->timestamp;
1272 if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
1274 keyCode = atoi( keyEvent->keyname + 8 );
1277 // Ensure key event string is not NULL as keys like SHIFT have a null string.
1278 if( keyEvent->string )
1280 keyString = keyEvent->string;
1283 std::string deviceName;
1284 Device::Class::Type deviceClass;
1285 Device::Subclass::Type deviceSubclass;
1287 GetDeviceName( keyEvent, deviceName );
1288 GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
1289 GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
1291 Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass );
1293 mKeyEventSignal.Emit( keyEvent );
1297 void WindowBaseEcoreWl2::OnDataSend( void* data, int type, void* event )
1299 mSelectionDataSendSignal.Emit( event );
1302 void WindowBaseEcoreWl2::OnDataReceive( void* data, int type, void* event )
1304 mSelectionDataReceivedSignal.Emit( event );
1307 void WindowBaseEcoreWl2::OnFontNameChanged()
1309 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
1312 void WindowBaseEcoreWl2::OnFontSizeChanged()
1314 mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
1317 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
1319 #ifdef DALI_ELDBUS_AVAILABLE
1321 // The string defines the arg-list's respective types.
1322 if( !eldbus_message_arguments_get( message, "iiiiiiu", &mAccessibilityInfo.gestureValue, &mAccessibilityInfo.startX, &mAccessibilityInfo.startY, &mAccessibilityInfo.endX, &mAccessibilityInfo.endY, &mAccessibilityInfo.state, &mAccessibilityInfo.eventTime ) )
1324 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
1327 mAccessibilitySignal.Emit( mAccessibilityInfo );
1331 void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityQuickpanelChanged( void* context, const Eldbus_Message* message )
1333 #ifdef DALI_ELDBUS_AVAILABLE
1335 unsigned int type = 0; // For example, type 1 is QuickPanel, type 3 is AllApps
1336 unsigned int state = 0; // 0 is hidden, 1 is shown
1338 // The string defines the arg-list's respective types.
1339 if( !eldbus_message_arguments_get( message, "uu", &type, &state ) )
1341 DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityQuickpanelChanged: Error getting arguments\n" );
1344 if( state ) // Shown
1346 mAccessibilityInfo.quickpanelInfo |= 1 << type;
1350 mAccessibilityInfo.quickpanelInfo &= ~( 1 << type );
1353 mQuickPanelSignal.Emit( mAccessibilityInfo.quickpanelInfo );
1357 void WindowBaseEcoreWl2::OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type )
1359 mTransitionEffectEventSignal.Emit( state, type );
1362 void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
1364 mKeyboardRepeatSettingsChangedSignal.Emit();
1367 void WindowBaseEcoreWl2::OnEcoreEventWindowRedrawRequest()
1369 mWindowRedrawRequestSignal.Emit();
1372 void WindowBaseEcoreWl2::KeymapChanged(void *data, int type, void *event)
1374 Ecore_Wl2_Event_Seat_Keymap_Changed *changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>( event );
1375 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id );
1376 Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( changed->display );
1379 mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
1383 void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
1385 if( strcmp( interface, tizen_policy_interface.name ) == 0 )
1387 uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
1389 mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
1392 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
1396 tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
1398 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
1400 else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
1402 mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
1403 if( !mTizenDisplayPolicy )
1405 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
1409 tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
1411 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
1415 void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
1417 mTizenPolicy = NULL;
1418 mTizenDisplayPolicy = NULL;
1421 void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
1423 mNotificationLevel = level;
1424 mNotificationChangeState = state;
1425 mNotificationLevelChangeDone = true;
1427 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
1430 void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
1432 mScreenOffMode = mode;
1433 mScreenOffModeChangeState = state;
1434 mScreenOffModeChangeDone = true;
1436 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
1439 void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
1441 mBrightness = brightness;
1442 mBrightnessChangeState = state;
1443 mBrightnessChangeDone = true;
1445 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
1448 void WindowBaseEcoreWl2::GetKeyCode( std::string keyName, int32_t& keyCode )
1450 xkb_keysym_t sym = XKB_KEY_NoSymbol;
1451 KeyCodeMap foundKeyCode;
1453 sym = xkb_keysym_from_name( keyName.c_str(), XKB_KEYSYM_NO_FLAGS );
1454 if( sym == XKB_KEY_NoSymbol )
1456 DALI_LOG_ERROR( "Failed to get keysym in WindowBaseEcoreWl2\n" );
1460 foundKeyCode.keySym = sym;
1461 foundKeyCode.isKeyCode = false;
1462 xkb_keymap_key_for_each( mKeyMap, FindKeyCode, &foundKeyCode );
1463 keyCode = static_cast< int32_t >( foundKeyCode.keyCode );
1466 Any WindowBaseEcoreWl2::GetNativeWindow()
1468 return mEcoreWindow;
1471 int WindowBaseEcoreWl2::GetNativeWindowId()
1473 return ecore_wl2_window_id_get( mEcoreWindow );
1476 EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow( int width, int height )
1478 int totalAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
1479 if( totalAngle == 90 || totalAngle == 270 )
1481 mEglWindow = wl_egl_window_create( mWlSurface, height, width );
1485 mEglWindow = wl_egl_window_create( mWlSurface, width, height );
1488 return static_cast< EGLNativeWindowType >( mEglWindow );
1491 void WindowBaseEcoreWl2::DestroyEglWindow()
1493 if( mEglWindow != NULL )
1495 wl_egl_window_destroy( mEglWindow );
1500 void WindowBaseEcoreWl2::SetEglWindowRotation( int angle )
1502 wl_egl_window_tizen_rotation rotation;
1508 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1513 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_270;
1518 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_180;
1523 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_90;
1528 rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
1533 wl_egl_window_tizen_set_rotation( mEglWindow, rotation );
1536 void WindowBaseEcoreWl2::SetEglWindowBufferTransform( int angle )
1538 wl_output_transform bufferTransform;
1544 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1549 bufferTransform = WL_OUTPUT_TRANSFORM_90;
1554 bufferTransform = WL_OUTPUT_TRANSFORM_180;
1559 bufferTransform = WL_OUTPUT_TRANSFORM_270;
1564 bufferTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1569 wl_egl_window_tizen_set_buffer_transform( mEglWindow, bufferTransform );
1572 void WindowBaseEcoreWl2::SetEglWindowTransform( int angle )
1574 wl_output_transform windowTransform;
1580 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1585 windowTransform = WL_OUTPUT_TRANSFORM_90;
1590 windowTransform = WL_OUTPUT_TRANSFORM_180;
1595 windowTransform = WL_OUTPUT_TRANSFORM_270;
1600 windowTransform = WL_OUTPUT_TRANSFORM_NORMAL;
1605 wl_egl_window_tizen_set_window_transform( mEglWindow, windowTransform );
1608 void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize )
1610 wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
1612 // Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
1613 if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial )
1615 wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial );
1616 mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
1620 bool WindowBaseEcoreWl2::IsEglWindowRotationSupported()
1623 wl_egl_window_tizen_capability capability = static_cast< wl_egl_window_tizen_capability >( wl_egl_window_tizen_get_capabilities( mEglWindow ) );
1624 if( capability == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED )
1626 mSupportedPreProtation = true;
1629 mSupportedPreProtation = false;
1633 void WindowBaseEcoreWl2::Move( PositionSize positionSize )
1635 mWindowPositionSize = positionSize;
1636 ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
1639 void WindowBaseEcoreWl2::Resize( PositionSize positionSize )
1641 mWindowPositionSize = positionSize;
1642 ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1645 void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize )
1647 mWindowPositionSize = positionSize;
1648 ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
1651 void WindowBaseEcoreWl2::SetClass( const std::string& name, const std::string& className )
1653 ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
1654 ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
1657 void WindowBaseEcoreWl2::Raise()
1659 // Use ecore_wl2_window_activate to prevent the window shown without rendering
1660 ecore_wl2_window_activate( mEcoreWindow );
1663 void WindowBaseEcoreWl2::Lower()
1665 ecore_wl2_window_lower( mEcoreWindow );
1668 void WindowBaseEcoreWl2::Activate()
1670 ecore_wl2_window_activate( mEcoreWindow );
1673 void WindowBaseEcoreWl2::SetAvailableAnlges( const std::vector< int >& angles )
1675 int rotations[4] = { 0 };
1676 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetAvailableAnlges, angle's count: %d, angles\n", angles.size() );
1677 for( std::size_t i = 0; i < angles.size(); ++i )
1679 rotations[i] = static_cast< int >( angles[i] );
1680 DALI_LOG_RELEASE_INFO( "%d ", rotations[i] );
1682 ecore_wl2_window_available_rotations_set( mEcoreWindow, rotations, angles.size() );
1685 void WindowBaseEcoreWl2::SetPreferredAngle( int angle )
1687 DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle );
1688 ecore_wl2_window_preferred_rotation_set( mEcoreWindow, angle );
1691 void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
1693 ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
1696 void WindowBaseEcoreWl2::Show()
1700 ecore_wl2_window_geometry_set( mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height );
1704 ecore_wl2_window_show( mEcoreWindow );
1707 void WindowBaseEcoreWl2::Hide()
1710 ecore_wl2_window_hide( mEcoreWindow );
1713 unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
1715 return mSupportedAuxiliaryHints.size();
1718 std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
1720 if( index >= GetSupportedAuxiliaryHintCount() )
1722 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
1725 return mSupportedAuxiliaryHints[index];
1728 unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
1730 bool supported = false;
1732 // Check if the hint is suppported
1733 for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
1744 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
1748 // Check if the hint is already added
1749 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1751 if( mAuxiliaryHints[i].first == hint )
1753 // Just change the value
1754 mAuxiliaryHints[i].second = value;
1756 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
1758 return i + 1; // id is index + 1
1763 mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
1765 unsigned int id = mAuxiliaryHints.size();
1767 ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
1769 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
1774 bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
1776 if( id == 0 || id > mAuxiliaryHints.size() )
1778 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
1782 mAuxiliaryHints[id - 1].second = std::string();
1784 ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
1786 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
1791 bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
1793 if( id == 0 || id > mAuxiliaryHints.size() )
1795 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
1799 mAuxiliaryHints[id - 1].second = value;
1801 ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
1803 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() );
1808 std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
1810 if( id == 0 || id > mAuxiliaryHints.size() )
1812 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
1813 return std::string();
1816 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() );
1818 return mAuxiliaryHints[id - 1].second;
1821 unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
1823 for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
1825 if( mAuxiliaryHints[i].first == hint )
1827 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
1832 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
1837 void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
1839 ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
1842 void WindowBaseEcoreWl2::SetType( Dali::Window::Type type )
1844 Ecore_Wl2_Window_Type windowType;
1848 case Dali::Window::NORMAL:
1850 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1853 case Dali::Window::NOTIFICATION:
1855 windowType = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
1858 case Dali::Window::UTILITY:
1860 windowType = ECORE_WL2_WINDOW_TYPE_UTILITY;
1863 case Dali::Window::DIALOG:
1865 windowType = ECORE_WL2_WINDOW_TYPE_DIALOG;
1870 windowType = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
1875 ecore_wl2_window_type_set( mEcoreWindow, windowType );
1878 bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
1880 while( !mTizenPolicy )
1882 wl_display_dispatch_queue( mDisplay, mEventQueue );
1885 int notificationLevel;
1889 case Dali::Window::NotificationLevel::NONE:
1891 notificationLevel = TIZEN_POLICY_LEVEL_NONE;
1894 case Dali::Window::NotificationLevel::BASE:
1896 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1899 case Dali::Window::NotificationLevel::MEDIUM:
1901 notificationLevel = TIZEN_POLICY_LEVEL_MEDIUM;
1904 case Dali::Window::NotificationLevel::HIGH:
1906 notificationLevel = TIZEN_POLICY_LEVEL_HIGH;
1909 case Dali::Window::NotificationLevel::TOP:
1911 notificationLevel = TIZEN_POLICY_LEVEL_TOP;
1916 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
1917 notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
1922 mNotificationLevelChangeDone = false;
1923 mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
1925 tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
1929 while( !mNotificationLevelChangeDone && count < 3 )
1931 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1932 wl_display_dispatch_queue( mDisplay, mEventQueue );
1936 if( !mNotificationLevelChangeDone )
1938 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
1941 else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
1943 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
1947 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
1952 Dali::Window::NotificationLevel::Type WindowBaseEcoreWl2::GetNotificationLevel() const
1954 while( !mTizenPolicy )
1956 wl_display_dispatch_queue( mDisplay, mEventQueue );
1961 while( !mNotificationLevelChangeDone && count < 3 )
1963 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
1964 wl_display_dispatch_queue( mDisplay, mEventQueue );
1968 if( !mNotificationLevelChangeDone )
1970 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
1971 return Dali::Window::NotificationLevel::NONE;
1974 Dali::Window::NotificationLevel::Type level;
1976 switch( mNotificationLevel )
1978 case TIZEN_POLICY_LEVEL_NONE:
1980 level = Dali::Window::NotificationLevel::NONE;
1983 case TIZEN_POLICY_LEVEL_DEFAULT:
1985 level = Dali::Window::NotificationLevel::BASE;
1988 case TIZEN_POLICY_LEVEL_MEDIUM:
1990 level = Dali::Window::NotificationLevel::MEDIUM;
1993 case TIZEN_POLICY_LEVEL_HIGH:
1995 level = Dali::Window::NotificationLevel::HIGH;
1998 case TIZEN_POLICY_LEVEL_TOP:
2000 level = Dali::Window::NotificationLevel::TOP;
2005 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
2006 level = Dali::Window::NotificationLevel::NONE;
2011 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
2016 void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
2018 while( !mTizenPolicy )
2020 wl_display_dispatch_queue( mDisplay, mEventQueue );
2023 tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
2026 bool WindowBaseEcoreWl2::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
2028 while( !mTizenPolicy )
2030 wl_display_dispatch_queue( mDisplay, mEventQueue );
2033 mScreenOffModeChangeDone = false;
2034 mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2036 unsigned int mode = 0;
2038 switch( screenOffMode )
2040 case Dali::Window::ScreenOffMode::TIMEOUT:
2045 case Dali::Window::ScreenOffMode::NEVER:
2052 tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
2056 while( !mScreenOffModeChangeDone && count < 3 )
2058 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2059 wl_display_dispatch_queue( mDisplay, mEventQueue );
2063 if( !mScreenOffModeChangeDone )
2065 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
2068 else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2070 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
2074 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
2079 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWl2::GetScreenOffMode() const
2081 while( !mTizenPolicy )
2083 wl_display_dispatch_queue( mDisplay, mEventQueue );
2088 while( !mScreenOffModeChangeDone && count < 3 )
2090 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2091 wl_display_dispatch_queue( mDisplay, mEventQueue );
2095 if( !mScreenOffModeChangeDone )
2097 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
2098 return Dali::Window::ScreenOffMode::TIMEOUT;
2101 Dali::Window::ScreenOffMode::Type screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
2103 switch( mScreenOffMode )
2107 screenMode = Dali::Window::ScreenOffMode::TIMEOUT;
2112 screenMode = Dali::Window::ScreenOffMode::NEVER;
2117 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
2122 bool WindowBaseEcoreWl2::SetBrightness( int brightness )
2124 while( !mTizenDisplayPolicy )
2126 wl_display_dispatch_queue( mDisplay, mEventQueue );
2129 mBrightnessChangeDone = false;
2130 mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
2132 tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
2136 while( !mBrightnessChangeDone && count < 3 )
2138 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2139 wl_display_dispatch_queue( mDisplay, mEventQueue );
2143 if( !mBrightnessChangeDone )
2145 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
2148 else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
2150 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
2154 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
2159 int WindowBaseEcoreWl2::GetBrightness() const
2161 while( !mTizenDisplayPolicy )
2163 wl_display_dispatch_queue( mDisplay, mEventQueue );
2168 while( !mBrightnessChangeDone && count < 3 )
2170 ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
2171 wl_display_dispatch_queue( mDisplay, mEventQueue );
2175 if( !mBrightnessChangeDone )
2177 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
2181 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
2186 bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
2188 Ecore_Wl2_Window_Keygrab_Mode mode;
2192 case KeyGrab::TOPMOST:
2194 mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2197 case KeyGrab::SHARED:
2199 mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2202 case KeyGrab::OVERRIDE_EXCLUSIVE:
2204 mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2207 case KeyGrab::EXCLUSIVE:
2209 mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2218 return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
2221 bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
2223 return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
2226 bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
2228 int keyCount = key.Count();
2229 int keyGrabModeCount = grabMode.Count();
2231 if( keyCount != keyGrabModeCount || keyCount == 0 )
2238 Eina_List* keyList = NULL;
2239 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2241 for( int index = 0; index < keyCount; ++index )
2243 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2245 switch( grabMode[index] )
2247 case KeyGrab::TOPMOST:
2249 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
2252 case KeyGrab::SHARED:
2254 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
2257 case KeyGrab::OVERRIDE_EXCLUSIVE:
2259 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
2262 case KeyGrab::EXCLUSIVE:
2264 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
2269 info[index].mode = ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN;
2274 keyList = eina_list_append( keyList, &info );
2277 Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
2279 result.Resize( keyCount, true );
2281 Eina_List* l = NULL;
2282 Eina_List* m = NULL;
2283 void* listData = NULL;
2285 if( grabList != NULL )
2287 EINA_LIST_FOREACH( grabList, m, data )
2290 EINA_LIST_FOREACH( keyList, l, listData )
2292 if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
2294 DALI_LOG_ERROR( "input key list has null data!" );
2298 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2300 result[index] = false;
2309 eina_list_free( keyList );
2310 eina_list_free( grabList );
2316 bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
2318 int keyCount = key.Count();
2326 Eina_List* keyList = NULL;
2327 Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
2329 for( int index = 0; index < keyCount; ++index )
2331 info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
2332 keyList = eina_list_append( keyList, &info );
2335 Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
2337 result.Resize( keyCount, true );
2339 Eina_List* l = NULL;
2340 Eina_List* m = NULL;
2341 void *listData = NULL;
2344 if( ungrabList != NULL )
2346 EINA_LIST_FOREACH( ungrabList, m, data )
2349 EINA_LIST_FOREACH( keyList, l, listData )
2351 if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
2353 result[index] = false;
2362 eina_list_free( keyList );
2363 eina_list_free( ungrabList );
2369 void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
2374 Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mEcoreWindow );
2376 // 1 inch = 25.4 millimeters
2377 xres = ecore_wl2_output_dpi_get( output );
2378 yres = ecore_wl2_output_dpi_get( output );
2380 dpiHorizontal = int( xres + 0.5f ); // rounding
2381 dpiVertical = int( yres + 0.5f );
2384 int WindowBaseEcoreWl2::GetOrientation() const
2386 int orientation = (mScreenRotationAngle + mWindowRotationAngle) % 360;
2387 if( mSupportedPreProtation )
2394 int WindowBaseEcoreWl2::GetScreenRotationAngle()
2398 if( ecore_wl2_window_ignore_output_transform_get( mEcoreWindow ) )
2404 transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mEcoreWindow ) );
2406 mScreenRotationAngle = transform * 90;
2407 return mScreenRotationAngle;
2410 void WindowBaseEcoreWl2::SetWindowRotationAngle( int degree )
2412 mWindowRotationAngle = degree;
2413 ecore_wl2_window_rotation_set( mEcoreWindow, degree );
2416 int WindowBaseEcoreWl2::GetWindowRotationAngle()
2418 return mWindowRotationAngle;
2421 void WindowBaseEcoreWl2::WindowRotationCompleted( int degree, int width, int height )
2423 ecore_wl2_window_rotation_change_done_send( mEcoreWindow, degree, width, height );
2426 void WindowBaseEcoreWl2::SetTransparency( bool transparent )
2428 ecore_wl2_window_alpha_set( mEcoreWindow, transparent );
2431 void WindowBaseEcoreWl2::InitializeEcoreElDBus()
2433 #ifdef DALI_ELDBUS_AVAILABLE
2434 Eldbus_Object* object;
2435 Eldbus_Proxy* manager;
2437 if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
2439 DALI_LOG_ERROR( "Unable to get system bus\n" );
2442 object = eldbus_object_get( mSystemConnection, BUS, PATH );
2445 DALI_LOG_ERROR( "Getting object failed\n" );
2449 manager = eldbus_proxy_get( object, INTERFACE );
2452 DALI_LOG_ERROR( "Getting proxy failed\n" );
2456 if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
2458 DALI_LOG_ERROR( "No signal handler returned\n" );
2461 if( !eldbus_proxy_signal_handler_add( manager, "QuickpanelChanged", EcoreElDBusAccessibilityQuickpanelChanged, this ) )
2463 DALI_LOG_ERROR( "No signal handler returned for QuickpanelChanged signal\n" );
2468 void WindowBaseEcoreWl2::CreateWindow( PositionSize positionSize )
2470 Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL );
2473 DALI_ASSERT_ALWAYS( 0 && "Failed to get display" );
2476 ecore_wl2_display_sync( display );
2478 mEcoreWindow = ecore_wl2_window_new( display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
2480 if ( mEcoreWindow == 0 )
2482 DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
2486 ecore_wl2_window_type_set( mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL );
2489 void WindowBaseEcoreWl2::SetParent( WindowBase* parentWinBase )
2491 Ecore_Wl2_Window* ecoreParent = NULL;
2494 WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>( parentWinBase );
2495 ecoreParent = winBaseEcore2->mEcoreWindow;
2497 ecore_wl2_window_parent_set( mEcoreWindow, ecoreParent );
2500 int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
2502 return wl_egl_window_tizen_create_commit_sync_fd( mEglWindow );
2505 int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
2507 return wl_egl_window_tizen_create_presentation_sync_fd( mEglWindow );
2510 } // namespace Adaptor
2512 } // namespace Internal
2516 #pragma GCC diagnostic pop