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/ubuntu-x11/window-render-surface-ecore-x.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 Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
51 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
54 return windowBase->OnWindowPropertyChanged( data, type, event );
57 return ECORE_CALLBACK_PASS_ON;
60 /// Called when the window receives a delete request
61 static Eina_Bool EcoreEventWindowDeleteRequest( void* data, int type, void* event )
63 WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
66 windowBase->OnDeleteRequest();
68 return ECORE_CALLBACK_DONE;
71 } // unnamed namespace
73 WindowBaseEcoreX::WindowBaseEcoreX( Window* window, WindowRenderSurface* windowRenderSurface )
74 : mEcoreEventHandler(),
76 mWindowSurface( NULL ),
78 mRotationAppSet( false )
80 mWindowSurface = dynamic_cast< WindowRenderSurfaceEcoreX* >( windowRenderSurface );
83 WindowBaseEcoreX::~WindowBaseEcoreX()
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 WindowBaseEcoreX::Initialize()
96 DALI_ASSERT_ALWAYS( "Invalid window surface" );
99 mEcoreWindow = mWindowSurface->GetXWindow();
100 DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no EcoreX 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 Eina_Bool WindowBaseEcoreX::OnWindowPropertyChanged( void* data, int type, void* event )
113 Ecore_X_Event_Window_Property* propertyChangedEvent = static_cast< Ecore_X_Event_Window_Property* >( event );
114 Eina_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:
141 mWindow->OnIconifyChanged( false );
142 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%d) Shown\n", mWindow );
143 handled = ECORE_CALLBACK_DONE;
157 void WindowBaseEcoreX::OnDeleteRequest()
159 mWindow->OnDeleteRequest();
162 void WindowBaseEcoreX::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
164 DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
166 if( visibleMode == Dali::Window::VISIBLE )
168 // when the indicator is visible, set proper mode for indicator server according to bg mode
169 if( opacityMode == Dali::Window::OPAQUE )
171 ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_OPAQUE );
173 else if( opacityMode == Dali::Window::TRANSLUCENT )
175 ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT );
177 #if defined (DALI_PROFILE_MOBILE)
178 else if( opacityMode == Dali::Window::TRANSPARENT )
180 ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_OPAQUE );
186 // when the indicator is not visible, set TRANSPARENT mode for indicator server
187 ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSPARENT ); // it means hidden indicator
191 void WindowBaseEcoreX::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
193 int show_state = static_cast< int >( isShow );
194 ecore_x_window_prop_property_set( mEcoreWindow, ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
195 ECORE_X_ATOM_CARDINAL, 32, &show_state, 1 );
199 ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_ON );
203 ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_OFF );
207 void WindowBaseEcoreX::IndicatorTypeChanged( IndicatorInterface::Type type )
211 void WindowBaseEcoreX::SetClass( std::string name, std::string className )
213 ecore_x_icccm_name_class_set( mEcoreWindow, name.c_str(), className.c_str() );
216 void WindowBaseEcoreX::Raise()
218 ecore_x_window_raise( mEcoreWindow );
221 void WindowBaseEcoreX::Lower()
223 ecore_x_window_lower( mEcoreWindow );
226 void WindowBaseEcoreX::Activate()
228 ecore_x_netwm_client_active_request( ecore_x_window_root_get( mEcoreWindow ), mEcoreWindow, 1 /* request type, 1:application, 2:pager */, 0 );
231 void WindowBaseEcoreX::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
235 void WindowBaseEcoreX::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
239 void WindowBaseEcoreX::SetAcceptFocus( bool accept )
243 void WindowBaseEcoreX::Show()
245 ecore_x_window_show( mEcoreWindow );
248 void WindowBaseEcoreX::Hide()
250 ecore_x_window_hide( mEcoreWindow );
253 unsigned int WindowBaseEcoreX::GetSupportedAuxiliaryHintCount() const
258 std::string WindowBaseEcoreX::GetSupportedAuxiliaryHint( unsigned int index ) const
260 return std::string();
263 unsigned int WindowBaseEcoreX::AddAuxiliaryHint( const std::string& hint, const std::string& value )
268 bool WindowBaseEcoreX::RemoveAuxiliaryHint( unsigned int id )
273 bool WindowBaseEcoreX::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
278 std::string WindowBaseEcoreX::GetAuxiliaryHintValue( unsigned int id ) const
280 return std::string();
283 unsigned int WindowBaseEcoreX::GetAuxiliaryHintId( const std::string& hint ) const
288 void WindowBaseEcoreX::SetInputRegion( const Rect< int >& inputRegion )
292 void WindowBaseEcoreX::SetType( Dali::Window::Type type )
296 bool WindowBaseEcoreX::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
301 Dali::Window::NotificationLevel::Type WindowBaseEcoreX::GetNotificationLevel() const
303 return Dali::Window::NotificationLevel::NONE;
306 void WindowBaseEcoreX::SetOpaqueState( bool opaque )
310 bool WindowBaseEcoreX::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
315 Dali::Window::ScreenOffMode::Type WindowBaseEcoreX::GetScreenOffMode() const
317 return Dali::Window::ScreenOffMode::TIMEOUT;
320 bool WindowBaseEcoreX::SetBrightness( int brightness )
325 int WindowBaseEcoreX::GetBrightness() const
330 } // namespace Adaptor
332 } // namespace Internal
336 #pragma GCC diagnostic pop