2 * Copyright (c) 2019 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/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>
40 #if defined(DEBUG_ENABLED)
41 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
44 WindowBaseAndroid::WindowBaseAndroid( Dali::PositionSize positionSize, Any surface, bool isTransparent )
47 mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
48 mRotationAppSet( false )
50 Initialize( positionSize, surface, isTransparent );
53 WindowBaseAndroid::~WindowBaseAndroid() = default;
55 void WindowBaseAndroid::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
57 if( !surface.Empty() )
59 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Initialising using supplied Android native window\n" );
60 mWindow = static_cast< ANativeWindow* >( AnyCast< void* >( surface ) );
64 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Initialising using default Android native window\n" );
65 mWindow = Dali::Integration::AndroidFramework::Get().GetApplicationWindow();
68 DALI_ASSERT_ALWAYS( mWindow && "Failed to get Android window" );
69 mIsTransparent = true;
72 void WindowBaseAndroid::OnDeleteRequest()
74 mDeleteRequestSignal.Emit();
77 void WindowBaseAndroid::OnFocusIn( void* data, int type, void* event )
81 void WindowBaseAndroid::OnFocusOut( void* data, int type, void* event )
85 void WindowBaseAndroid::OnWindowDamaged( void* data, int type, void* event )
89 void WindowBaseAndroid::OnMouseButtonDown( void* data, int type, void* event )
93 void WindowBaseAndroid::OnMouseButtonUp( void* data, int type, void* event )
97 void WindowBaseAndroid::OnMouseButtonMove( void* data, int type, void* event )
101 void WindowBaseAndroid::OnMouseWheel( void* data, int type, void* event )
105 void WindowBaseAndroid::OnKeyDown( void* data, int type, void* event )
109 void WindowBaseAndroid::OnKeyUp( void* data, int type, void* event )
113 void WindowBaseAndroid::OnSelectionClear( void* data, int type, void* event )
117 void WindowBaseAndroid::OnSelectionNotify( void* data, int type, void* event )
121 Any WindowBaseAndroid::GetNativeWindow()
123 return static_cast< void* >( mWindow );
126 int WindowBaseAndroid::GetNativeWindowId()
131 EGLNativeWindowType WindowBaseAndroid::CreateEglWindow( int width, int height )
133 // from eglplatform.h header
134 // typedef struct ANativeWindow* EGLNativeWindowType;
135 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Returns the window created for us.\n" );
139 void WindowBaseAndroid::DestroyEglWindow()
141 DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Does nothing, the window is not owned by us.\n" );
144 void WindowBaseAndroid::SetEglWindowRotation( int angle )
148 void WindowBaseAndroid::SetEglWindowBufferTransform( int angle )
152 void WindowBaseAndroid::SetEglWindowTransform( int angle )
156 void WindowBaseAndroid::ResizeEglWindow( PositionSize positionSize )
160 bool WindowBaseAndroid::IsEglWindowRotationSupported()
165 void WindowBaseAndroid::Move( PositionSize positionSize )
169 void WindowBaseAndroid::Resize( PositionSize positionSize )
173 void WindowBaseAndroid::MoveResize( PositionSize positionSize )
177 void WindowBaseAndroid::SetClass( const std::string& name, const std::string& className )
181 void WindowBaseAndroid::Raise()
185 void WindowBaseAndroid::Lower()
189 void WindowBaseAndroid::Activate()
193 void WindowBaseAndroid::SetAvailableAnlges( const std::vector< int >& angles )
197 void WindowBaseAndroid::SetPreferredAngle( int angle )
201 void WindowBaseAndroid::SetAcceptFocus( bool accept )
205 void WindowBaseAndroid::Show()
209 void WindowBaseAndroid::Hide()
213 unsigned int WindowBaseAndroid::GetSupportedAuxiliaryHintCount() const
218 std::string WindowBaseAndroid::GetSupportedAuxiliaryHint( unsigned int index ) const
220 return std::string();
223 unsigned int WindowBaseAndroid::AddAuxiliaryHint( const std::string& hint, const std::string& value )
228 bool WindowBaseAndroid::RemoveAuxiliaryHint( unsigned int id )
233 bool WindowBaseAndroid::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
238 std::string WindowBaseAndroid::GetAuxiliaryHintValue( unsigned int id ) const
240 return std::string();
243 unsigned int WindowBaseAndroid::GetAuxiliaryHintId( const std::string& hint ) const
248 void WindowBaseAndroid::SetInputRegion( const Rect< int >& inputRegion )
252 void WindowBaseAndroid::SetType( Dali::Window::Type type )
256 bool WindowBaseAndroid::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
261 Dali::Window::NotificationLevel::Type WindowBaseAndroid::GetNotificationLevel() const
263 return Dali::Window::NotificationLevel::NONE;
266 void WindowBaseAndroid::SetOpaqueState( bool opaque )
270 bool WindowBaseAndroid::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
275 Dali::Window::ScreenOffMode::Type WindowBaseAndroid::GetScreenOffMode() const
277 return Dali::Window::ScreenOffMode::TIMEOUT;
280 bool WindowBaseAndroid::SetBrightness( int brightness )
285 int WindowBaseAndroid::GetBrightness() const
290 bool WindowBaseAndroid::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
295 bool WindowBaseAndroid::UngrabKey( Dali::KEY key )
300 bool WindowBaseAndroid::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
305 bool WindowBaseAndroid::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
310 void WindowBaseAndroid::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
312 AConfiguration* config = Dali::Integration::AndroidFramework::Get().GetApplicationConfiguration();
314 int32_t density = AConfiguration_getDensity( config );
315 if( density == ACONFIGURATION_DENSITY_ANY )
317 DALI_LOG_ERROR( "Failed to get Android DPI, use 0 instead." );
321 dpiHorizontal = density;
322 dpiVertical = density;
325 int WindowBaseAndroid::GetScreenRotationAngle()
330 void WindowBaseAndroid::SetWindowRotationAngle( int degree )
334 void WindowBaseAndroid::WindowRotationCompleted( int degree, int width, int height )
338 void WindowBaseAndroid::SetTransparency( bool transparent )
342 void WindowBaseAndroid::SetParent( WindowBase* parentWinBase )
346 } // namespace Adaptor
348 } // namespace Internal