[Tizen] Add codes for Dali Windows Backend
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / windows / window-base-ecore-win.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // Ecore is littered with C style cast
19 #pragma GCC diagnostic push
20 #pragma GCC diagnostic ignored "-Wold-style-cast"
21
22 // CLASS HEADER
23 #include <dali/internal/window-system/windows/window-base-ecore-win.h>
24
25 // INTERNAL HEADERS
26 #include <dali/internal/window-system/common/window-impl.h>
27 #include <dali/internal/window-system/windows/window-render-surface-ecore-win.h>
28
29 // EXTERNAL_HEADERS
30 #include <dali/public-api/object/any.h>
31 #include <dali/integration-api/debug.h>
32
33 namespace Dali
34 {
35
36 namespace Internal
37 {
38
39 namespace Adaptor
40 {
41
42 namespace
43 {
44
45 #if defined(DEBUG_ENABLED)
46 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
47 #endif
48
49 static bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
50 {
51   WindowBaseEcoreWin* windowBase = static_cast< WindowBaseEcoreWin* >( data );
52   if( windowBase )
53   {
54     return windowBase->OnWindowPropertyChanged( data, type, event );
55   }
56
57   return true;
58 }
59
60 /// Called when the window receives a delete request
61 static bool EcoreEventWindowDeleteRequest( void* data, int type, void* event )
62 {
63   WindowBaseEcoreWin* windowBase = static_cast< WindowBaseEcoreWin* >( data );
64   if( windowBase )
65   {
66     windowBase->OnDeleteRequest();
67   }
68   return true;
69 }
70
71 } // unnamed namespace
72
73 WindowBaseEcoreWin::WindowBaseEcoreWin( Window* window, WindowRenderSurface* windowRenderSurface )
74 : mEcoreEventHandler(),
75   mWindow( window ),
76   mWindowSurface( NULL ),
77   mEcoreWindow( 0 ),
78   mRotationAppSet( false )
79 {
80   mWindowSurface = dynamic_cast< WindowRenderSurfaceEcoreWin* >( windowRenderSurface );
81 }
82
83 WindowBaseEcoreWin::~WindowBaseEcoreWin()
84 {
85   for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
86   {
87     ecore_event_handler_del( **iter );
88   }
89   mEcoreEventHandler.Clear();
90 }
91
92 void WindowBaseEcoreWin::Initialize()
93 {
94   if( !mWindowSurface )
95   {
96     DALI_ASSERT_ALWAYS( "Invalid window surface" );
97   }
98
99   mEcoreWindow = mWindowSurface->GetWinWindow();
100   DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no EcoreWin window" );
101
102   //ecore_x_input_multi_select( mEcoreWindow );
103
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 );
106
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 ) );
109 }
110
111 bool WindowBaseEcoreWin::OnWindowPropertyChanged( void* data, int type, void* event )
112 {
113   //Ecore_X_Event_Window_Property* propertyChangedEvent = static_cast< Ecore_X_Event_Window_Property* >( event );
114   //bool handled( ECORE_CALLBACK_PASS_ON );
115
116   //if( propertyChangedEvent->win == mEcoreWindow )
117   //{
118   //  Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
119
120   //  switch( state )
121   //  {
122   //    case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
123   //    {
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;
128   //      break;
129   //    }
130   //    case ECORE_X_WINDOW_STATE_HINT_ICONIC:
131   //    {
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;
136   //      break;
137   //    }
138   //    case ECORE_X_WINDOW_STATE_HINT_NORMAL:
139   //    {
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;
144   //      break;
145   //    }
146   //    default:
147   //    {
148   //      // Ignore
149   //      break;
150   //    }
151   //  }
152   //}
153
154   //return handled;
155   return true;
156 }
157
158 void WindowBaseEcoreWin::OnDeleteRequest()
159 {
160   mWindow->OnDeleteRequest();
161 }
162
163 void WindowBaseEcoreWin::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
164 {
165 //  DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode );
166 //
167 //  if( visibleMode == Dali::Window::VISIBLE )
168 //  {
169 //    // when the indicator is visible, set proper mode for indicator server according to bg mode
170 //    if( opacityMode == Dali::Window::OPAQUE )
171 //    {
172 //      ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_OPAQUE );
173 //    }
174 //    else if( opacityMode == Dali::Window::TRANSLUCENT )
175 //    {
176 //      ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT );
177 //    }
178 //#if defined (DALI_PROFILE_MOBILE)
179 //    else if( opacityMode == Dali::Window::TRANSPARENT )
180 //    {
181 //      ecore_x_e_illume_indicator_opacity_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_OPAQUE );
182 //    }
183 //#endif
184 //  }
185 //  else
186 //  {
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
189 //  }
190 }
191
192 void WindowBaseEcoreWin::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
193 {
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 );
197
198   if( isShow )
199   {
200     ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_ON );
201   }
202   else
203   {
204     ecore_x_e_illume_indicator_state_set( mEcoreWindow, ECORE_X_ILLUME_INDICATOR_STATE_OFF );
205   }*/
206 }
207
208 void WindowBaseEcoreWin::IndicatorTypeChanged( IndicatorInterface::Type type )
209 {
210 }
211
212 void WindowBaseEcoreWin::SetClass( std::string name, std::string className )
213 {
214   //ecore_x_icccm_name_class_set( mEcoreWindow, name.c_str(), className.c_str() );
215 }
216
217 void WindowBaseEcoreWin::Raise()
218 {
219   //ecore_x_window_raise( mEcoreWindow );
220 }
221
222 void WindowBaseEcoreWin::Lower()
223 {
224   //ecore_x_window_lower( mEcoreWindow );
225 }
226
227 void WindowBaseEcoreWin::Activate()
228 {
229   //ecore_x_netwm_client_active_request( ecore_x_window_root_get( mEcoreWindow ), mEcoreWindow, 1 /* request type, 1:application, 2:pager */, 0 );
230 }
231
232 void WindowBaseEcoreWin::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
233 {
234 }
235
236 void WindowBaseEcoreWin::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
237 {
238 }
239
240 void WindowBaseEcoreWin::SetAcceptFocus( bool accept )
241 {
242 }
243
244 void WindowBaseEcoreWin::Show()
245 {
246   //ecore_x_window_show( mEcoreWindow );
247 }
248
249 void WindowBaseEcoreWin::Hide()
250 {
251   //ecore_x_window_hide( mEcoreWindow );
252 }
253
254 unsigned int WindowBaseEcoreWin::GetSupportedAuxiliaryHintCount() const
255 {
256   return 0;
257 }
258
259 std::string WindowBaseEcoreWin::GetSupportedAuxiliaryHint( unsigned int index ) const
260 {
261   return std::string();
262 }
263
264 unsigned int WindowBaseEcoreWin::AddAuxiliaryHint( const std::string& hint, const std::string& value )
265 {
266   return 0;
267 }
268
269 bool WindowBaseEcoreWin::RemoveAuxiliaryHint( unsigned int id )
270 {
271   return false;
272 }
273
274 bool WindowBaseEcoreWin::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
275 {
276   return false;
277 }
278
279 std::string WindowBaseEcoreWin::GetAuxiliaryHintValue( unsigned int id ) const
280 {
281   return std::string();
282 }
283
284 unsigned int WindowBaseEcoreWin::GetAuxiliaryHintId( const std::string& hint ) const
285 {
286   return 0;
287 }
288
289 void WindowBaseEcoreWin::SetInputRegion( const Rect< int >& inputRegion )
290 {
291 }
292
293 void WindowBaseEcoreWin::SetType( Dali::Window::Type type )
294 {
295 }
296
297 bool WindowBaseEcoreWin::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
298 {
299   return false;
300 }
301
302 Dali::Window::NotificationLevel::Type WindowBaseEcoreWin::GetNotificationLevel() const
303 {
304   return Dali::Window::NotificationLevel::NONE;
305 }
306
307 void WindowBaseEcoreWin::SetOpaqueState( bool opaque )
308 {
309 }
310
311 bool WindowBaseEcoreWin::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
312 {
313   return false;
314 }
315
316 Dali::Window::ScreenOffMode::Type WindowBaseEcoreWin::GetScreenOffMode() const
317 {
318   return Dali::Window::ScreenOffMode::TIMEOUT;
319 }
320
321 bool WindowBaseEcoreWin::SetBrightness( int brightness )
322 {
323   return false;
324 }
325
326 int WindowBaseEcoreWin::GetBrightness() const
327 {
328   return 0;
329 }
330
331 bool WindowBaseEcoreWin::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
332 {
333   return false;
334 }
335
336 bool WindowBaseEcoreWin::UngrabKey( Dali::KEY key )
337 {
338   return false;
339 }
340
341 bool WindowBaseEcoreWin::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
342 {
343   return false;
344 }
345
346 bool WindowBaseEcoreWin::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
347 {
348   return false;
349 }
350
351 } // namespace Adaptor
352
353 } // namespace Internal
354
355 } // namespace Dali
356
357 #pragma GCC diagnostic pop