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