Merge "Use existing callback ID for recurring callbacks" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / android / window-base-android.cpp
1 /*
2  * Copyright (c) 2019 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 // CLASS HEADER
19 #include <dali/internal/window-system/android/window-base-android.h>
20
21 // INTERNAL HEADERS
22 #include <dali/internal/window-system/common/window-impl.h>
23 #include <dali/internal/window-system/common/window-render-surface.h>
24
25 // EXTERNAL_HEADERS
26 #include <dali/public-api/object/any.h>
27 #include <dali/public-api/events/mouse-button.h>
28 #include <dali/integration-api/debug.h>
29 #include <dali/integration-api/adaptor-framework/android/android-framework.h>
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40 #if defined(DEBUG_ENABLED)
41 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
42 #endif
43
44 WindowBaseAndroid::WindowBaseAndroid( Dali::PositionSize positionSize, Any surface, bool isTransparent )
45 : mWindow( nullptr ),
46   mOwnSurface( false ),
47   mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
48   mRotationAppSet( false )
49 {
50   Initialize( positionSize, surface, isTransparent );
51 }
52
53 WindowBaseAndroid::~WindowBaseAndroid() = default;
54
55 void WindowBaseAndroid::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
56 {
57   if( !surface.Empty() )
58   {
59     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Initialising using supplied Android native window\n" );
60     mWindow = static_cast< ANativeWindow* >( AnyCast< void* >( surface ) );
61   }
62   else
63   {
64     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Initialising using default Android native window\n" );
65     mWindow = Dali::Integration::AndroidFramework::Get().GetApplicationWindow();
66   }
67
68   DALI_ASSERT_ALWAYS( mWindow && "Failed to get Android window" );
69   mIsTransparent = true;
70 }
71
72 void WindowBaseAndroid::OnDeleteRequest()
73 {
74   mDeleteRequestSignal.Emit();
75 }
76
77 void WindowBaseAndroid::OnFocusIn( void* data, int type, void* event )
78 {
79 }
80
81 void WindowBaseAndroid::OnFocusOut( void* data, int type, void* event )
82 {
83 }
84
85 void WindowBaseAndroid::OnWindowDamaged( void* data, int type, void* event )
86 {
87 }
88
89 void WindowBaseAndroid::OnMouseButtonDown( void* data, int type, void* event )
90 {
91 }
92
93 void WindowBaseAndroid::OnMouseButtonUp( void* data, int type, void* event )
94 {
95 }
96
97 void WindowBaseAndroid::OnMouseButtonMove( void* data, int type, void* event )
98 {
99 }
100
101 void WindowBaseAndroid::OnMouseWheel( void* data, int type, void* event )
102 {
103 }
104
105 void WindowBaseAndroid::OnKeyDown( void* data, int type, void* event )
106 {
107 }
108
109 void WindowBaseAndroid::OnKeyUp( void* data, int type, void* event )
110 {
111 }
112
113 void WindowBaseAndroid::OnSelectionClear( void* data, int type, void* event )
114 {
115 }
116
117 void WindowBaseAndroid::OnSelectionNotify( void* data, int type, void* event )
118 {
119 }
120
121 Any WindowBaseAndroid::GetNativeWindow()
122 {
123   return static_cast< void* >( mWindow );
124 }
125
126 int WindowBaseAndroid::GetNativeWindowId()
127 {
128   return 0;
129 }
130
131 EGLNativeWindowType WindowBaseAndroid::CreateEglWindow( int width, int height )
132 {
133   // from eglplatform.h header
134   // typedef struct ANativeWindow* EGLNativeWindowType;
135   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Returns the window created for us.\n" );
136   return mWindow;
137 }
138
139 void WindowBaseAndroid::DestroyEglWindow()
140 {
141   DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Does nothing, the window is not owned by us.\n" );
142 }
143
144 void WindowBaseAndroid::SetEglWindowRotation( int angle )
145 {
146 }
147
148 void WindowBaseAndroid::SetEglWindowBufferTransform( int angle )
149 {
150 }
151
152 void WindowBaseAndroid::SetEglWindowTransform( int angle )
153 {
154 }
155
156 void WindowBaseAndroid::ResizeEglWindow( PositionSize positionSize )
157 {
158 }
159
160 bool WindowBaseAndroid::IsEglWindowRotationSupported()
161 {
162   return false;
163 }
164
165 void WindowBaseAndroid::Move( PositionSize positionSize )
166 {
167 }
168
169 void WindowBaseAndroid::Resize( PositionSize positionSize )
170 {
171 }
172
173 void WindowBaseAndroid::MoveResize( PositionSize positionSize )
174 {
175 }
176
177 void WindowBaseAndroid::SetClass( const std::string& name, const std::string& className )
178 {
179 }
180
181 void WindowBaseAndroid::Raise()
182 {
183 }
184
185 void WindowBaseAndroid::Lower()
186 {
187 }
188
189 void WindowBaseAndroid::Activate()
190 {
191 }
192
193 void WindowBaseAndroid::SetAvailableAnlges( const std::vector< int >& angles )
194 {
195 }
196
197 void WindowBaseAndroid::SetPreferredAngle( int angle )
198 {
199 }
200
201 void WindowBaseAndroid::SetAcceptFocus( bool accept )
202 {
203 }
204
205 void WindowBaseAndroid::Show()
206 {
207 }
208
209 void WindowBaseAndroid::Hide()
210 {
211 }
212
213 unsigned int WindowBaseAndroid::GetSupportedAuxiliaryHintCount() const
214 {
215   return 0;
216 }
217
218 std::string WindowBaseAndroid::GetSupportedAuxiliaryHint( unsigned int index ) const
219 {
220   return std::string();
221 }
222
223 unsigned int WindowBaseAndroid::AddAuxiliaryHint( const std::string& hint, const std::string& value )
224 {
225   return 0;
226 }
227
228 bool WindowBaseAndroid::RemoveAuxiliaryHint( unsigned int id )
229 {
230   return false;
231 }
232
233 bool WindowBaseAndroid::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
234 {
235   return false;
236 }
237
238 std::string WindowBaseAndroid::GetAuxiliaryHintValue( unsigned int id ) const
239 {
240   return std::string();
241 }
242
243 unsigned int WindowBaseAndroid::GetAuxiliaryHintId( const std::string& hint ) const
244 {
245   return 0;
246 }
247
248 void WindowBaseAndroid::SetInputRegion( const Rect< int >& inputRegion )
249 {
250 }
251
252 void WindowBaseAndroid::SetType( Dali::WindowType type )
253 {
254 }
255
256 bool WindowBaseAndroid::SetNotificationLevel( Dali::WindowNotificationLevel level )
257 {
258   return false;
259 }
260
261 Dali::WindowNotificationLevel WindowBaseAndroid::GetNotificationLevel() const
262 {
263   return Dali::WindowNotificationLevel::NONE;
264 }
265
266 void WindowBaseAndroid::SetOpaqueState( bool opaque )
267 {
268 }
269
270 bool WindowBaseAndroid::SetScreenOffMode(WindowScreenOffMode screenOffMode)
271 {
272   return false;
273 }
274
275 WindowScreenOffMode WindowBaseAndroid::GetScreenOffMode() const
276 {
277   return WindowScreenOffMode::TIMEOUT;
278 }
279
280 bool WindowBaseAndroid::SetBrightness( int brightness )
281 {
282   return false;
283 }
284
285 int WindowBaseAndroid::GetBrightness() const
286 {
287   return 0;
288 }
289
290 bool WindowBaseAndroid::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
291 {
292   return false;
293 }
294
295 bool WindowBaseAndroid::UngrabKey( Dali::KEY key )
296 {
297   return false;
298 }
299
300 bool WindowBaseAndroid::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
301 {
302   return false;
303 }
304
305 bool WindowBaseAndroid::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
306 {
307   return false;
308 }
309
310 void WindowBaseAndroid::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
311 {
312   AConfiguration* config = Dali::Integration::AndroidFramework::Get().GetApplicationConfiguration();
313
314   int32_t density = AConfiguration_getDensity( config );
315   if( density == ACONFIGURATION_DENSITY_ANY )
316   {
317     DALI_LOG_ERROR( "Failed to get Android DPI, use 0 instead." );
318     density = 0;
319   }
320
321   dpiHorizontal = density;
322   dpiVertical   = density;
323 }
324
325 int WindowBaseAndroid::GetScreenRotationAngle()
326 {
327   return 0;
328 }
329
330 void WindowBaseAndroid::SetWindowRotationAngle( int degree )
331 {
332 }
333
334 void WindowBaseAndroid::WindowRotationCompleted( int degree, int width, int height )
335 {
336 }
337
338 void WindowBaseAndroid::SetTransparency( bool transparent )
339 {
340 }
341
342 void WindowBaseAndroid::SetParent( WindowBase* parentWinBase )
343 {
344 }
345
346 int WindowBaseAndroid::CreateFrameRenderedSyncFence()
347 {
348   return -1;
349 }
350
351 int WindowBaseAndroid::CreateFramePresentedSyncFence()
352 {
353   return -1;
354 }
355
356 } // namespace Adaptor
357
358 } // namespace Internal
359
360 } // namespace Dali
361