Add Window::SetLayout method
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / android / window-base-android.cpp
1 /*
2  * Copyright (c) 2022 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 std::string WindowBaseAndroid::GetNativeWindowResourceId()
129 {
130   return std::string();
131 }
132
133 EGLNativeWindowType WindowBaseAndroid::CreateEglWindow(int width, int height)
134 {
135   // from eglplatform.h header
136   // typedef struct ANativeWindow* EGLNativeWindowType;
137   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Returns the window created for us.\n");
138   return mWindow;
139 }
140
141 void WindowBaseAndroid::DestroyEglWindow()
142 {
143   DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Does nothing, the window is not owned by us.\n");
144 }
145
146 void WindowBaseAndroid::SetEglWindowRotation(int angle)
147 {
148 }
149
150 void WindowBaseAndroid::SetEglWindowBufferTransform(int angle)
151 {
152 }
153
154 void WindowBaseAndroid::SetEglWindowTransform(int angle)
155 {
156 }
157
158 void WindowBaseAndroid::ResizeEglWindow(PositionSize positionSize)
159 {
160 }
161
162 bool WindowBaseAndroid::IsEglWindowRotationSupported()
163 {
164   return false;
165 }
166
167 void WindowBaseAndroid::Move(PositionSize positionSize)
168 {
169 }
170
171 void WindowBaseAndroid::Resize(PositionSize positionSize)
172 {
173 }
174
175 void WindowBaseAndroid::MoveResize(PositionSize positionSize)
176 {
177 }
178
179 void WindowBaseAndroid::SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan)
180 {
181 }
182
183 void WindowBaseAndroid::SetClass(const std::string& name, const std::string& className)
184 {
185 }
186
187 void WindowBaseAndroid::Raise()
188 {
189 }
190
191 void WindowBaseAndroid::Lower()
192 {
193 }
194
195 void WindowBaseAndroid::Activate()
196 {
197 }
198
199 void WindowBaseAndroid::Maximize(bool maximize)
200 {
201 }
202
203 bool WindowBaseAndroid::IsMaximized() const
204 {
205   return false;
206 }
207
208 void WindowBaseAndroid::SetMaximumSize(Dali::Window::WindowSize size)
209 {
210 }
211
212 void WindowBaseAndroid::Minimize(bool minimize)
213 {
214 }
215
216 bool WindowBaseAndroid::IsMinimized() const
217 {
218   return false;
219 }
220
221 void WindowBaseAndroid::SetMimimumSize(Dali::Window::WindowSize size)
222 {
223 }
224
225 void WindowBaseAndroid::SetAvailableAnlges(const std::vector<int>& angles)
226 {
227 }
228
229 void WindowBaseAndroid::SetPreferredAngle(int angle)
230 {
231 }
232
233 void WindowBaseAndroid::SetAcceptFocus(bool accept)
234 {
235 }
236
237 void WindowBaseAndroid::Show()
238 {
239 }
240
241 void WindowBaseAndroid::Hide()
242 {
243 }
244
245 unsigned int WindowBaseAndroid::GetSupportedAuxiliaryHintCount() const
246 {
247   return 0;
248 }
249
250 std::string WindowBaseAndroid::GetSupportedAuxiliaryHint(unsigned int index) const
251 {
252   return std::string();
253 }
254
255 unsigned int WindowBaseAndroid::AddAuxiliaryHint(const std::string& hint, const std::string& value)
256 {
257   return 0;
258 }
259
260 bool WindowBaseAndroid::RemoveAuxiliaryHint(unsigned int id)
261 {
262   return false;
263 }
264
265 bool WindowBaseAndroid::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
266 {
267   return false;
268 }
269
270 std::string WindowBaseAndroid::GetAuxiliaryHintValue(unsigned int id) const
271 {
272   return std::string();
273 }
274
275 unsigned int WindowBaseAndroid::GetAuxiliaryHintId(const std::string& hint) const
276 {
277   return 0;
278 }
279
280 void WindowBaseAndroid::SetInputRegion(const Rect<int>& inputRegion)
281 {
282 }
283
284 void WindowBaseAndroid::SetType(Dali::WindowType type)
285 {
286 }
287
288 Dali::WindowType WindowBaseAndroid::GetType() const
289 {
290   return Dali::WindowType::NORMAL;
291 }
292
293 Dali::WindowOperationResult WindowBaseAndroid::SetNotificationLevel(Dali::WindowNotificationLevel level)
294 {
295   return Dali::WindowOperationResult::NOT_SUPPORTED;
296 }
297
298 Dali::WindowNotificationLevel WindowBaseAndroid::GetNotificationLevel() const
299 {
300   return Dali::WindowNotificationLevel::NONE;
301 }
302
303 void WindowBaseAndroid::SetOpaqueState(bool opaque)
304 {
305 }
306
307 Dali::WindowOperationResult WindowBaseAndroid::SetScreenOffMode(WindowScreenOffMode screenOffMode)
308 {
309   return Dali::WindowOperationResult::NOT_SUPPORTED;
310 }
311
312 WindowScreenOffMode WindowBaseAndroid::GetScreenOffMode() const
313 {
314   return WindowScreenOffMode::TIMEOUT;
315 }
316
317 Dali::WindowOperationResult WindowBaseAndroid::SetBrightness(int brightness)
318 {
319   return Dali::WindowOperationResult::NOT_SUPPORTED;
320 }
321
322 int WindowBaseAndroid::GetBrightness() const
323 {
324   return 0;
325 }
326
327 bool WindowBaseAndroid::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
328 {
329   return false;
330 }
331
332 bool WindowBaseAndroid::UngrabKey(Dali::KEY key)
333 {
334   return false;
335 }
336
337 bool WindowBaseAndroid::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
338 {
339   return false;
340 }
341
342 bool WindowBaseAndroid::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
343 {
344   return false;
345 }
346
347 void WindowBaseAndroid::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
348 {
349   AConfiguration* config = Dali::Integration::AndroidFramework::Get().GetApplicationConfiguration();
350
351   int32_t density = AConfiguration_getDensity(config);
352   if(density == ACONFIGURATION_DENSITY_ANY)
353   {
354     DALI_LOG_ERROR("Failed to get Android DPI, use 0 instead.");
355     density = 0;
356   }
357
358   dpiHorizontal = density;
359   dpiVertical   = density;
360 }
361
362 int WindowBaseAndroid::GetScreenRotationAngle()
363 {
364   return 0;
365 }
366
367 void WindowBaseAndroid::SetWindowRotationAngle(int degree)
368 {
369 }
370
371 void WindowBaseAndroid::WindowRotationCompleted(int degree, int width, int height)
372 {
373 }
374
375 void WindowBaseAndroid::SetTransparency(bool transparent)
376 {
377 }
378
379 void WindowBaseAndroid::SetParent(WindowBase* parentWinBase, bool belowParent)
380 {
381 }
382
383 int WindowBaseAndroid::CreateFrameRenderedSyncFence()
384 {
385   return -1;
386 }
387
388 int WindowBaseAndroid::CreateFramePresentedSyncFence()
389 {
390   return -1;
391 }
392
393 int WindowBaseAndroid::GetWindowRotationAngle() const
394 {
395   return 0;
396 }
397
398 void WindowBaseAndroid::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
399 {
400 }
401
402 void WindowBaseAndroid::InitializeIme()
403 {
404 }
405
406 void WindowBaseAndroid::ImeWindowReadyToRender()
407 {
408 }
409
410 void WindowBaseAndroid::RequestMoveToServer()
411 {
412 }
413
414 void WindowBaseAndroid::RequestResizeToServer(WindowResizeDirection direction)
415 {
416 }
417
418 void WindowBaseAndroid::EnableFloatingMode(bool enable)
419 {
420 }
421
422 bool WindowBaseAndroid::IsFloatingModeEnabled() const
423 {
424   return false;
425 }
426
427 void WindowBaseAndroid::IncludeInputRegion(const Rect<int>& inputRegion)
428 {
429 }
430
431 void WindowBaseAndroid::ExcludeInputRegion(const Rect<int>& inputRegion)
432 {
433 }
434
435 } // namespace Adaptor
436
437 } // namespace Internal
438
439 } // namespace Dali