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/windows/window-base-ecore-win.h>
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/windows/window-render-surface-ecore-win.h>
30 #include <dali/public-api/object/any.h>
31 #include <dali/integration-api/debug.h>
45 #if defined(DEBUG_ENABLED)
46 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
49 static bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
51 WindowBaseEcoreWin* windowBase = static_cast< WindowBaseEcoreWin* >( data );
54 return windowBase->OnWindowPropertyChanged( data, type, event );
60 /// Called when the window receives a delete request
61 static bool EcoreEventWindowDeleteRequest( void* data, int type, void* event )
63 WindowBaseEcoreWin* windowBase = static_cast< WindowBaseEcoreWin* >( data );
66 windowBase->OnDeleteRequest();
71 } // unnamed namespace
73 WindowBaseEcoreWin::WindowBaseEcoreWin( Window* window, WindowRenderSurface* windowRenderSurface )
74 : mEcoreEventHandler(),
76 mWindowSurface( NULL ),
78 mRotationAppSet( false )
80 mWindowSurface = dynamic_cast< WindowRenderSurfaceEcoreWin* >( windowRenderSurface );
83 WindowBaseEcoreWin::~WindowBaseEcoreWin()
85 for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
87 ecore_event_handler_del( **iter );
89 mEcoreEventHandler.Clear();
92 void WindowBaseEcoreWin::Initialize()
96 DALI_ASSERT_ALWAYS( "Invalid window surface" );
99 mEcoreWindow = mWindowSurface->GetWinWindow();
100 DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no EcoreWin window" );
102 //ecore_x_input_multi_select( mEcoreWindow );
104 // This ensures that we catch the window close (or delete) request
105 //ecore_x_icccm_protocol_set( mEcoreWindow, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, EINA_TRUE );
107 //mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY, EcoreEventWindowPropertyChanged, this ) );
108 //mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_DELETE_REQUEST, EcoreEventWindowDeleteRequest, this ) );
111 bool WindowBaseEcoreWin::OnWindowPropertyChanged( void* data, int type, void* event )
113 //Ecore_X_Event_Window_Property* propertyChangedEvent = static_cast< Ecore_X_Event_Window_Property* >( event );
114 //bool handled( ECORE_CALLBACK_PASS_ON );
116 //if( propertyChangedEvent->win == mEcoreWindow )
118 // Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
122 // case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
124 // // Window was hidden.
125 // mWindow->OnIconifyChanged( true );
126 // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%d) Withdrawn\n", mWindow );
127 // handled = ECORE_CALLBACK_DONE;
130 // case ECORE_X_WINDOW_STATE_HINT_ICONIC:
132 // // Window was iconified (minimised).
133 // mWindow->OnIconifyChanged( true );
134 // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%d) Iconfied\n", mWindow );
135 // handled = ECORE_CALLBACK_DONE;
138 // case ECORE_X_WINDOW_STATE_HINT_NORMAL:
140 // // Window was shown.
141 // mWindow->OnIconifyChanged( false );
142 // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%d) Shown\n", mWindow );
143 // handled = ECORE_CALLBACK_DONE;
158 void WindowBaseEcoreWin::OnDeleteRequest()
160 mWindow->OnDeleteRequest();
163 void WindowBaseEcoreWin::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
165 // DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
167 // if( visibleMode == Dali::Window::VISIBLE )
169 // // when the indicator is visible, set proper mode for indicator server according to bg mode
170 // if( opacityMode == Dali::Window::OPAQUE )
172 // ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_OPAQUE );
174 // else if( opacityMode == Dali::Window::TRANSLUCENT )
176 // ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT );
178 //#if defined (DALI_PROFILE_MOBILE)
179 // else if( opacityMode == Dali::Window::TRANSPARENT )
181 // ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_OPAQUE );
187 // // when the indicator is not visible, set TRANSPARENT mode for indicator server
188 // ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSPARENT ); // it means hidden indicator
192 void WindowBaseEcoreWin::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
194 /*int show_state = static_cast< int >( isShow );
195 ecore_x_window_prop_property_set( mEcoreWindow, ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
196 ECORE_X_ATOM_CARDINAL, 32, &show_state, 1 );
200 ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_ON );
204 ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_OFF );
208 void WindowBaseEcoreWin::IndicatorTypeChanged( IndicatorInterface::Type type )
212 void WindowBaseEcoreWin::SetClass( std::string name, std::string className )
214 //ecore_x_icccm_name_class_set( mEcoreWindow, name.c_str(), className.c_str() );
217 void WindowBaseEcoreWin::Raise()
219 //ecore_x_window_raise( mEcoreWindow );
222 void WindowBaseEcoreWin::Lower()
224 //ecore_x_window_lower( mEcoreWindow );
227 void WindowBaseEcoreWin::Activate()
229 //ecore_x_netwm_client_active_request( ecore_x_window_root_get( mEcoreWindow ), mEcoreWindow, 1 /* request type, 1:application, 2:pager */, 0 );
232 void WindowBaseEcoreWin::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
236 void WindowBaseEcoreWin::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
240 void WindowBaseEcoreWin::SetAcceptFocus( bool accept )
244 void WindowBaseEcoreWin::Show()
246 //ecore_x_window_show( mEcoreWindow );
249 void WindowBaseEcoreWin::Hide()
251 //ecore_x_window_hide( mEcoreWindow );
254 unsigned int WindowBaseEcoreWin::GetSupportedAuxiliaryHintCount() const
259 std::string WindowBaseEcoreWin::GetSupportedAuxiliaryHint( unsigned int index ) const
261 return std::string();
264 unsigned int WindowBaseEcoreWin::AddAuxiliaryHint( const std::string& hint, const std::string& value )
269 bool WindowBaseEcoreWin::RemoveAuxiliaryHint( unsigned int id )
274 bool WindowBaseEcoreWin::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
279 std::string WindowBaseEcoreWin::GetAuxiliaryHintValue( unsigned int id ) const
281 return std::string();
284 unsigned int WindowBaseEcoreWin::GetAuxiliaryHintId( const std::string& hint ) const
289 void WindowBaseEcoreWin::SetInputRegion( const Rect< int >& inputRegion )
293 void WindowBaseEcoreWin::SetType( Dali::Window::Type type )
297 bool WindowBaseEcoreWin::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
302 Dali::Window::NotificationLevel::Type WindowBaseEcoreWin::GetNotificationLevel() const
304 return Dali::Window::NotificationLevel::NONE;
307 void WindowBaseEcoreWin::SetOpaqueState( bool opaque )
311 bool WindowBaseEcoreWin::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
316 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWin::GetScreenOffMode() const
318 return Dali::Window::ScreenOffMode::TIMEOUT;
321 bool WindowBaseEcoreWin::SetBrightness( int brightness )
326 int WindowBaseEcoreWin::GetBrightness() const
331 bool WindowBaseEcoreWin::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
336 bool WindowBaseEcoreWin::UngrabKey( Dali::KEY key )
341 bool WindowBaseEcoreWin::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
346 bool WindowBaseEcoreWin::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
351 } // namespace Adaptor
353 } // namespace Internal
357 #pragma GCC diagnostic pop