2 * Copyright (c) 2021 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.
19 #include <dali/internal/window-system/android/window-base-android.h>
22 #include <dali/internal/window-system/common/window-impl.h>
23 #include <dali/internal/window-system/common/window-render-surface.h>
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>
37 #if defined(DEBUG_ENABLED)
38 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
41 WindowBaseAndroid::WindowBaseAndroid(Dali::PositionSize positionSize, Any surface, bool isTransparent)
44 mIsTransparent(false), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
45 mRotationAppSet(false)
47 Initialize(positionSize, surface, isTransparent);
50 WindowBaseAndroid::~WindowBaseAndroid() = default;
52 void WindowBaseAndroid::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
56 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Initialising using supplied Android native window\n");
57 mWindow = static_cast<ANativeWindow*>(AnyCast<void*>(surface));
61 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Initialising using default Android native window\n");
62 mWindow = Dali::Integration::AndroidFramework::Get().GetApplicationWindow();
65 DALI_ASSERT_ALWAYS(mWindow && "Failed to get Android window");
66 mIsTransparent = true;
69 void WindowBaseAndroid::OnDeleteRequest()
71 mDeleteRequestSignal.Emit();
74 void WindowBaseAndroid::OnFocusIn(void* data, int type, void* event)
78 void WindowBaseAndroid::OnFocusOut(void* data, int type, void* event)
82 void WindowBaseAndroid::OnWindowDamaged(void* data, int type, void* event)
86 void WindowBaseAndroid::OnMouseButtonDown(void* data, int type, void* event)
90 void WindowBaseAndroid::OnMouseButtonUp(void* data, int type, void* event)
94 void WindowBaseAndroid::OnMouseButtonMove(void* data, int type, void* event)
98 void WindowBaseAndroid::OnMouseWheel(void* data, int type, void* event)
102 void WindowBaseAndroid::OnKeyDown(void* data, int type, void* event)
106 void WindowBaseAndroid::OnKeyUp(void* data, int type, void* event)
110 void WindowBaseAndroid::OnSelectionClear(void* data, int type, void* event)
114 void WindowBaseAndroid::OnSelectionNotify(void* data, int type, void* event)
118 Any WindowBaseAndroid::GetNativeWindow()
120 return static_cast<void*>(mWindow);
123 int WindowBaseAndroid::GetNativeWindowId()
128 EGLNativeWindowType WindowBaseAndroid::CreateEglWindow(int width, int height)
130 // from eglplatform.h header
131 // typedef struct ANativeWindow* EGLNativeWindowType;
132 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Returns the window created for us.\n");
136 void WindowBaseAndroid::DestroyEglWindow()
138 DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Does nothing, the window is not owned by us.\n");
141 void WindowBaseAndroid::SetEglWindowRotation(int angle)
145 void WindowBaseAndroid::SetEglWindowBufferTransform(int angle)
149 void WindowBaseAndroid::SetEglWindowTransform(int angle)
153 void WindowBaseAndroid::ResizeEglWindow(PositionSize positionSize)
157 bool WindowBaseAndroid::IsEglWindowRotationSupported()
162 void WindowBaseAndroid::Move(PositionSize positionSize)
166 void WindowBaseAndroid::Resize(PositionSize positionSize)
170 void WindowBaseAndroid::MoveResize(PositionSize positionSize)
174 void WindowBaseAndroid::SetClass(const std::string& name, const std::string& className)
178 void WindowBaseAndroid::Raise()
182 void WindowBaseAndroid::Lower()
186 void WindowBaseAndroid::Activate()
190 void WindowBaseAndroid::SetAvailableAnlges(const std::vector<int>& angles)
194 void WindowBaseAndroid::SetPreferredAngle(int angle)
198 void WindowBaseAndroid::SetAcceptFocus(bool accept)
202 void WindowBaseAndroid::Show()
206 void WindowBaseAndroid::Hide()
210 unsigned int WindowBaseAndroid::GetSupportedAuxiliaryHintCount() const
215 std::string WindowBaseAndroid::GetSupportedAuxiliaryHint(unsigned int index) const
217 return std::string();
220 unsigned int WindowBaseAndroid::AddAuxiliaryHint(const std::string& hint, const std::string& value)
225 bool WindowBaseAndroid::RemoveAuxiliaryHint(unsigned int id)
230 bool WindowBaseAndroid::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
235 std::string WindowBaseAndroid::GetAuxiliaryHintValue(unsigned int id) const
237 return std::string();
240 unsigned int WindowBaseAndroid::GetAuxiliaryHintId(const std::string& hint) const
245 void WindowBaseAndroid::SetInputRegion(const Rect<int>& inputRegion)
249 void WindowBaseAndroid::SetType(Dali::WindowType type)
253 Dali::WindowType WindowBaseAndroid::GetType() const
255 return Dali::WindowType::NORMAL;
258 Dali::WindowOperationResult WindowBaseAndroid::SetNotificationLevel(Dali::WindowNotificationLevel level)
260 return Dali::WindowOperationResult::NOT_SUPPORTED;
263 Dali::WindowNotificationLevel WindowBaseAndroid::GetNotificationLevel() const
265 return Dali::WindowNotificationLevel::NONE;
268 void WindowBaseAndroid::SetOpaqueState(bool opaque)
272 Dali::WindowOperationResult WindowBaseAndroid::SetScreenOffMode(WindowScreenOffMode screenOffMode)
274 return Dali::WindowOperationResult::NOT_SUPPORTED;
277 WindowScreenOffMode WindowBaseAndroid::GetScreenOffMode() const
279 return WindowScreenOffMode::TIMEOUT;
282 Dali::WindowOperationResult WindowBaseAndroid::SetBrightness(int brightness)
284 return Dali::WindowOperationResult::NOT_SUPPORTED;
287 int WindowBaseAndroid::GetBrightness() const
292 bool WindowBaseAndroid::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
297 bool WindowBaseAndroid::UngrabKey(Dali::KEY key)
302 bool WindowBaseAndroid::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
307 bool WindowBaseAndroid::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
312 void WindowBaseAndroid::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
314 AConfiguration* config = Dali::Integration::AndroidFramework::Get().GetApplicationConfiguration();
316 int32_t density = AConfiguration_getDensity(config);
317 if(density == ACONFIGURATION_DENSITY_ANY)
319 DALI_LOG_ERROR("Failed to get Android DPI, use 0 instead.");
323 dpiHorizontal = density;
324 dpiVertical = density;
327 int WindowBaseAndroid::GetScreenRotationAngle()
332 void WindowBaseAndroid::SetWindowRotationAngle(int degree)
336 void WindowBaseAndroid::WindowRotationCompleted(int degree, int width, int height)
340 void WindowBaseAndroid::SetTransparency(bool transparent)
344 void WindowBaseAndroid::SetParent(WindowBase* parentWinBase)
348 int WindowBaseAndroid::CreateFrameRenderedSyncFence()
353 int WindowBaseAndroid::CreateFramePresentedSyncFence()
358 int WindowBaseAndroid::GetOrientation() const
363 void WindowBaseAndroid::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
367 void WindowBaseAndroid::InitializeIme()
371 void WindowBaseAndroid::ImeWindowReadyToRender()
375 void WindowBaseAndroid::RequestMoveToServer()
379 void WindowBaseAndroid::RequestResizeToServer(WindowResizeDirection direction)
383 void WindowBaseAndroid::EnableFloatingMode(bool enable)
387 bool WindowBaseAndroid::IsFloatingModeEnabled() const
392 void WindowBaseAndroid::IncludeInputRegion(const Rect<int>& inputRegion)
396 void WindowBaseAndroid::ExcludeInputRegion(const Rect<int>& inputRegion)
400 } // namespace Adaptor
402 } // namespace Internal