2 * Copyright (c) 2018 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/ubuntu-x11/window-base-ecore-x.h>
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/common/window-render-surface.h>
28 #include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
31 #include <dali/public-api/object/any.h>
32 #include <dali/integration-api/debug.h>
33 #include <Ecore_Input.h>
47 const std::string DEFAULT_DEVICE_NAME = "";
48 const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE;
49 const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
51 const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
53 #if defined(DEBUG_ENABLED)
54 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
57 /////////////////////////////////////////////////////////////////////////////////////////////////
59 /////////////////////////////////////////////////////////////////////////////////////////////////
61 static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
63 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
66 return windowBase->OnWindowPropertyChanged( data, type, event );
69 return ECORE_CALLBACK_PASS_ON;
73 * Called when the window receives a delete request
75 static Eina_Bool EcoreEventWindowDeleteRequest( void* data, int type, void* event )
77 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
80 windowBase->OnDeleteRequest();
82 return ECORE_CALLBACK_DONE;
86 * Called when the window gains focus.
88 static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
90 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
93 windowBase->OnFocusIn( data, type, event );
95 return ECORE_CALLBACK_PASS_ON;
99 * Called when the window loses focus.
101 static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
103 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
106 windowBase->OnFocusOut( data, type, event );
108 return ECORE_CALLBACK_PASS_ON;
112 * Called when the window is damaged.
114 static Eina_Bool EcoreEventWindowDamaged( void* data, int type, void* event )
116 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
119 windowBase->OnWindowDamaged( data, type, event );
122 return ECORE_CALLBACK_PASS_ON;
125 /////////////////////////////////////////////////////////////////////////////////////////////////
126 // Selection Callbacks
127 /////////////////////////////////////////////////////////////////////////////////////////////////
130 * Called when the source window notifies us the content in clipboard is selected.
132 static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
134 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
137 windowBase->OnSelectionClear( data, type, event );
139 return ECORE_CALLBACK_PASS_ON;
143 * Called when the source window sends us about the selected content.
144 * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
146 static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
148 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
151 windowBase->OnSelectionNotify( data, type, event );
153 return ECORE_CALLBACK_PASS_ON;
156 /////////////////////////////////////////////////////////////////////////////////////////////////
158 /////////////////////////////////////////////////////////////////////////////////////////////////
161 * Called when a touch down is received.
163 static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
165 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
168 windowBase->OnMouseButtonDown( data, type, event );
170 return ECORE_CALLBACK_PASS_ON;
174 * Called when a touch up is received.
176 static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
178 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
181 windowBase->OnMouseButtonUp( data, type, event );
183 return ECORE_CALLBACK_PASS_ON;
187 * Called when a touch motion is received.
189 static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
191 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
194 windowBase->OnMouseButtonMove( data, type, event );
196 return ECORE_CALLBACK_PASS_ON;
199 /////////////////////////////////////////////////////////////////////////////////////////////////
201 /////////////////////////////////////////////////////////////////////////////////////////////////
204 * Called when a mouse wheel is received.
206 static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
208 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
211 windowBase->OnMouseWheel( data, type, event );
213 return ECORE_CALLBACK_PASS_ON;
216 /////////////////////////////////////////////////////////////////////////////////////////////////
218 /////////////////////////////////////////////////////////////////////////////////////////////////
221 * Called when a key down is received.
223 static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
225 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
228 windowBase->OnKeyDown( data, type, event );
230 return ECORE_CALLBACK_PASS_ON;
234 * Called when a key up is received.
236 static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
238 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
241 windowBase->OnKeyUp( data, type, event );
243 return ECORE_CALLBACK_PASS_ON;
246 } // unnamed namespace
248 WindowBaseEcoreX::WindowBaseEcoreX( Dali::PositionSize positionSize, Any surface, bool isTransparent )
249 : mEcoreEventHandler(),
251 mOwnSurface( false ),
252 mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
253 mRotationAppSet( false )
255 Initialize( positionSize, surface, isTransparent );
258 WindowBaseEcoreX::~WindowBaseEcoreX()
260 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
262 ecore_event_handler_del( *iter );
264 mEcoreEventHandler.Clear();
268 ecore_x_window_free( mEcoreWindow );
272 void WindowBaseEcoreX::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
274 // see if there is a surface in Any surface
275 unsigned int surfaceId = GetSurfaceId( surface );
277 // if the surface is empty, create a new one.
280 // we own the surface about to created
282 CreateWindow( positionSize, isTransparent );
286 // XLib should already be initialized so no point in calling XInitThreads
287 mEcoreWindow = static_cast< Ecore_X_Window >( surfaceId );
290 // set up etc properties to match with ecore-evas
292 if( ( id = getenv("DESKTOP_STARTUP_ID") ) )
294 ecore_x_netwm_startup_id_set( mEcoreWindow, id );
297 ecore_x_icccm_hints_set( mEcoreWindow,
299 ECORE_X_WINDOW_STATE_HINT_NORMAL, // initial_state
306 // we SHOULD guarantee the x11 window was created in x server.
309 ecore_x_input_multi_select( mEcoreWindow );
311 // This ensures that we catch the window close (or delete) request
312 ecore_x_icccm_protocol_set( mEcoreWindow, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, EINA_TRUE );
314 // Enable Drag & Drop
315 ecore_x_dnd_aware_set( mEcoreWindow, EINA_TRUE );
317 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY, EcoreEventWindowPropertyChanged, this ) );
318 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_DELETE_REQUEST, EcoreEventWindowDeleteRequest, this ) );
320 // Register window focus events
321 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
322 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
324 // Register Window damage events
325 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_DAMAGE, EcoreEventWindowDamaged, this ) );
327 // Register Touch events
328 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
329 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
330 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
331 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, this ) ); // process mouse out event like up event
333 // Register Mouse wheel events
334 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
336 // Register Key events
337 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
338 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
340 // Register Selection event
341 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_CLEAR, EcoreEventSelectionClear, this ) );
342 mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, this ) );
345 Eina_Bool WindowBaseEcoreX::OnWindowPropertyChanged( void* data, int type, void* event )
347 Ecore_X_Event_Window_Property* propertyChangedEvent = static_cast< Ecore_X_Event_Window_Property* >( event );
348 Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
350 if( propertyChangedEvent->win == mEcoreWindow )
352 Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
356 case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
358 // Window was hidden.
359 mIconifyChangedSignal.Emit( true );
360 handled = ECORE_CALLBACK_DONE;
363 case ECORE_X_WINDOW_STATE_HINT_ICONIC:
365 // Window was iconified (minimised).
366 mIconifyChangedSignal.Emit( true );
367 handled = ECORE_CALLBACK_DONE;
370 case ECORE_X_WINDOW_STATE_HINT_NORMAL:
373 mIconifyChangedSignal.Emit( false );
374 handled = ECORE_CALLBACK_DONE;
388 void WindowBaseEcoreX::OnDeleteRequest()
390 mDeleteRequestSignal.Emit();
393 void WindowBaseEcoreX::OnFocusIn( void* data, int type, void* event )
395 Ecore_X_Event_Window_Focus_In* focusInEvent = static_cast< Ecore_X_Event_Window_Focus_In* >( event );
397 if( focusInEvent->win == mEcoreWindow )
399 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
401 mFocusChangedSignal.Emit( true );
405 void WindowBaseEcoreX::OnFocusOut( void* data, int type, void* event )
407 Ecore_X_Event_Window_Focus_Out* focusOutEvent = static_cast< Ecore_X_Event_Window_Focus_Out* >( event );
409 // If the window loses focus then hide the keyboard.
410 if( focusOutEvent->win == mEcoreWindow )
412 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
414 mFocusChangedSignal.Emit( false );
418 void WindowBaseEcoreX::OnWindowDamaged( void* data, int type, void* event )
420 Ecore_X_Event_Window_Damage* windowDamagedEvent = static_cast< Ecore_X_Event_Window_Damage* >( event );
422 if( windowDamagedEvent->win == mEcoreWindow )
425 area.x = windowDamagedEvent->x;
426 area.y = windowDamagedEvent->y;
427 area.width = windowDamagedEvent->w;
428 area.height = windowDamagedEvent->h;
430 mWindowDamagedSignal.Emit( area );
434 void WindowBaseEcoreX::OnMouseButtonDown( void* data, int type, void* event )
436 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
438 if( touchEvent->window == mEcoreWindow )
440 PointState::Type state ( PointState::DOWN );
442 // Check if the buttons field is set and ensure it's the primary touch button.
443 // If this event was triggered by buttons other than the primary button (used for touch), then
444 // just send an interrupted event to Core.
445 if( touchEvent->buttons && ( touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
447 state = PointState::INTERRUPTED;
450 Integration::Point point;
451 point.SetDeviceId( touchEvent->multi.device );
452 point.SetState( state );
453 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
454 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
455 point.SetPressure( touchEvent->multi.pressure );
456 point.SetAngle( Degree( touchEvent->multi.angle ) );
458 mTouchEventSignal.Emit( point, touchEvent->timestamp );
462 void WindowBaseEcoreX::OnMouseButtonUp( void* data, int type, void* event )
464 Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
466 if( touchEvent->window == mEcoreWindow )
468 Integration::Point point;
469 point.SetDeviceId( touchEvent->multi.device );
470 point.SetState( PointState::UP );
471 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
472 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
473 point.SetPressure( touchEvent->multi.pressure );
474 point.SetAngle( Degree( touchEvent->multi.angle ) );
476 mTouchEventSignal.Emit( point, touchEvent->timestamp );
480 void WindowBaseEcoreX::OnMouseButtonMove( void* data, int type, void* event )
482 Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
484 if( touchEvent->window == mEcoreWindow )
486 Integration::Point point;
487 point.SetDeviceId( touchEvent->multi.device );
488 point.SetState( PointState::MOTION );
489 point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
490 point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
491 point.SetPressure( touchEvent->multi.pressure );
492 point.SetAngle( Degree( touchEvent->multi.angle ) );
494 mTouchEventSignal.Emit( point, touchEvent->timestamp );
498 void WindowBaseEcoreX::OnMouseWheel( void* data, int type, void* event )
500 Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
502 if( mouseWheelEvent->window == mEcoreWindow )
504 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreX::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
506 WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
508 mWheelEventSignal.Emit( wheelEvent );
512 void WindowBaseEcoreX::OnKeyDown( void* data, int type, void* event )
514 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
516 if( keyEvent->window == mEcoreWindow )
518 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreX::OnKeyDown\n" );
520 std::string keyName( keyEvent->keyname );
521 std::string keyString( "" );
522 std::string compose( "" );
524 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
525 if( keyEvent->compose )
527 compose = keyEvent->compose;
530 int keyCode = ecore_x_keysym_keycode_get( keyEvent->keyname );
531 int modifier( keyEvent->modifiers );
532 unsigned long time = keyEvent->timestamp;
534 // Ensure key event string is not NULL as keys like SHIFT have a null string.
535 if( keyEvent->string )
537 keyString = keyEvent->string;
540 Integration::KeyEvent keyEvent( keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
542 mKeyEventSignal.Emit( keyEvent );
546 void WindowBaseEcoreX::OnKeyUp( void* data, int type, void* event )
548 Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
550 if ( keyEvent->window == mEcoreWindow )
552 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, " WindowBaseEcoreX::OnKeyUp\n" );
554 std::string keyName( keyEvent->keyname );
555 std::string keyString( "" );
556 std::string compose( "" );
558 // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
559 if( keyEvent->compose )
561 compose = keyEvent->compose;
563 int keyCode = ecore_x_keysym_keycode_get( keyEvent->keyname );
564 int modifier( keyEvent->modifiers );
565 unsigned long time( keyEvent->timestamp );
567 // Ensure key event string is not NULL as keys like SHIFT have a null string.
568 if( keyEvent->string )
570 keyString = keyEvent->string;
573 Integration::KeyEvent keyEvent( keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
575 mKeyEventSignal.Emit( keyEvent );
579 void WindowBaseEcoreX::OnSelectionClear( void* data, int type, void* event )
581 Ecore_X_Event_Selection_Clear* selectionClearEvent = static_cast< Ecore_X_Event_Selection_Clear* >( event );
583 if( selectionClearEvent->win == mEcoreWindow )
585 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, " WindowBaseEcoreX::OnSelectionClear\n" );
587 if( selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY )
589 // Request to get the content from Ecore.
590 ecore_x_selection_secondary_request( selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT );
595 void WindowBaseEcoreX::OnSelectionNotify( void* data, int type, void* event )
597 Ecore_X_Event_Selection_Notify* selectionNotifyEvent = static_cast< Ecore_X_Event_Selection_Notify* >( event );
599 if( selectionNotifyEvent->win == mEcoreWindow )
601 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, " WindowBaseEcoreX::OnSelectionNotify\n" );
603 Ecore_X_Selection_Data* selectionData = static_cast< Ecore_X_Selection_Data* >( selectionNotifyEvent->data );
604 if( selectionData->data )
606 if( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY )
608 mSelectionDataReceivedSignal.Emit( event );
614 Any WindowBaseEcoreX::GetNativeWindow()
619 int WindowBaseEcoreX::GetNativeWindowId()
624 EGLNativeWindowType WindowBaseEcoreX::CreateEglWindow( int width, int height )
626 // need to create X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
627 XWindow window( mEcoreWindow );
628 return reinterpret_cast< EGLNativeWindowType >( window );
631 void WindowBaseEcoreX::DestroyEglWindow()
635 void WindowBaseEcoreX::SetEglWindowRotation( int angle )
639 void WindowBaseEcoreX::SetEglWindowBufferTransform( int angle )
643 void WindowBaseEcoreX::SetEglWindowTransform( int angle )
647 void WindowBaseEcoreX::ResizeEglWindow( PositionSize positionSize )
651 bool WindowBaseEcoreX::IsEglWindowRotationSupported()
656 void WindowBaseEcoreX::Move( PositionSize positionSize )
658 ecore_x_window_move( mEcoreWindow, positionSize.x, positionSize.y );
661 void WindowBaseEcoreX::Resize( PositionSize positionSize )
663 ecore_x_window_resize( mEcoreWindow, positionSize.width, positionSize.height );
666 void WindowBaseEcoreX::MoveResize( PositionSize positionSize )
668 ecore_x_window_move_resize( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
671 void WindowBaseEcoreX::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
673 DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
675 if( visibleMode == Dali::Window::VISIBLE )
677 // when the indicator is visible, set proper mode for indicator server according to bg mode
678 if( opacityMode == Dali::Window::OPAQUE )
680 ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_OPAQUE );
682 else if( opacityMode == Dali::Window::TRANSLUCENT )
684 ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT );
689 // when the indicator is not visible, set TRANSPARENT mode for indicator server
690 ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSPARENT ); // it means hidden indicator
694 void WindowBaseEcoreX::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
696 int show_state = static_cast< int >( isShow );
697 ecore_x_window_prop_property_set( mEcoreWindow, ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
698 ECORE_X_ATOM_CARDINAL, 32, &show_state, 1 );
702 ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_ON );
706 ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_OFF );
710 void WindowBaseEcoreX::IndicatorTypeChanged( IndicatorInterface::Type type )
714 void WindowBaseEcoreX::SetClass( const std::string& name, const std::string& className )
716 ecore_x_icccm_title_set( mEcoreWindow, name.c_str() );
717 ecore_x_netwm_name_set( mEcoreWindow, name.c_str() );
718 ecore_x_icccm_name_class_set( mEcoreWindow, name.c_str(), className.c_str() );
721 void WindowBaseEcoreX::Raise()
723 ecore_x_window_raise( mEcoreWindow );
726 void WindowBaseEcoreX::Lower()
728 ecore_x_window_lower( mEcoreWindow );
731 void WindowBaseEcoreX::Activate()
733 ecore_x_netwm_client_active_request( ecore_x_window_root_get( mEcoreWindow ), mEcoreWindow, 1 /* request type, 1:application, 2:pager */, 0 );
736 void WindowBaseEcoreX::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
740 void WindowBaseEcoreX::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
744 void WindowBaseEcoreX::SetAcceptFocus( bool accept )
748 void WindowBaseEcoreX::Show()
750 ecore_x_window_show( mEcoreWindow );
753 void WindowBaseEcoreX::Hide()
755 ecore_x_window_hide( mEcoreWindow );
758 unsigned int WindowBaseEcoreX::GetSupportedAuxiliaryHintCount() const
763 std::string WindowBaseEcoreX::GetSupportedAuxiliaryHint( unsigned int index ) const
765 return std::string();
768 unsigned int WindowBaseEcoreX::AddAuxiliaryHint( const std::string& hint, const std::string& value )
773 bool WindowBaseEcoreX::RemoveAuxiliaryHint( unsigned int id )
778 bool WindowBaseEcoreX::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
783 std::string WindowBaseEcoreX::GetAuxiliaryHintValue( unsigned int id ) const
785 return std::string();
788 unsigned int WindowBaseEcoreX::GetAuxiliaryHintId( const std::string& hint ) const
793 void WindowBaseEcoreX::SetInputRegion( const Rect< int >& inputRegion )
797 void WindowBaseEcoreX::SetType( Dali::Window::Type type )
801 bool WindowBaseEcoreX::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
806 Dali::Window::NotificationLevel::Type WindowBaseEcoreX::GetNotificationLevel() const
808 return Dali::Window::NotificationLevel::NONE;
811 void WindowBaseEcoreX::SetOpaqueState( bool opaque )
815 bool WindowBaseEcoreX::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
820 Dali::Window::ScreenOffMode::Type WindowBaseEcoreX::GetScreenOffMode() const
822 return Dali::Window::ScreenOffMode::TIMEOUT;
825 bool WindowBaseEcoreX::SetBrightness( int brightness )
830 int WindowBaseEcoreX::GetBrightness() const
835 bool WindowBaseEcoreX::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
840 bool WindowBaseEcoreX::UngrabKey( Dali::KEY key )
845 bool WindowBaseEcoreX::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
850 bool WindowBaseEcoreX::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
855 void WindowBaseEcoreX::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
860 // 1 inch = 25.4 millimeters
861 xres = ecore_x_dpi_get();
862 yres = ecore_x_dpi_get();
864 dpiHorizontal = int( xres + 0.5f ); // rounding
865 dpiVertical = int( yres + 0.5f );
868 void WindowBaseEcoreX::SetViewMode( ViewMode viewMode )
870 Ecore_X_Atom viewModeAtom( ecore_x_atom_get( "_E_COMP_3D_APP_WIN" ) );
872 if( viewModeAtom != None )
874 unsigned int value( static_cast< unsigned int >( viewMode ) );
875 ecore_x_window_prop_card32_set( mEcoreWindow, viewModeAtom, &value, 1 );
879 int WindowBaseEcoreX::GetScreenRotationAngle()
884 void WindowBaseEcoreX::SetWindowRotationAngle( int degree )
888 void WindowBaseEcoreX::WindowRotationCompleted( int degree, int width, int height )
892 void WindowBaseEcoreX::SetTransparency( bool transparent )
896 unsigned int WindowBaseEcoreX::GetSurfaceId( Any surface ) const
898 unsigned int surfaceId = 0;
900 if ( surface.Empty() == false )
902 // check we have a valid type
903 DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) || (surface.GetType() == typeid (Ecore_X_Window) ) )
904 && "Surface type is invalid" );
906 if ( surface.GetType() == typeid (Ecore_X_Window) )
908 surfaceId = AnyCast< Ecore_X_Window >( surface );
912 surfaceId = AnyCast< XWindow >( surface );
918 void WindowBaseEcoreX::CreateWindow( PositionSize positionSize, bool isTransparent )
922 // create 32 bit window
923 mEcoreWindow = ecore_x_window_argb_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
924 mIsTransparent = true;
928 // create 24 bit window
929 mEcoreWindow = ecore_x_window_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
932 if ( mEcoreWindow == 0 )
934 DALI_ASSERT_ALWAYS( 0 && "Failed to create X window" );
938 } // namespace Adaptor
940 } // namespace Internal
944 #pragma GCC diagnostic pop