2 * Copyright (c) 2017 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 "window-impl.h"
22 #include <dali/integration-api/core.h>
23 #include <dali/integration-api/system-overlay.h>
24 #include <dali/public-api/render-tasks/render-task.h>
25 #include <dali/public-api/render-tasks/render-task-list.h>
26 #include <orientation.h>
29 #include "render-surface/render-surface-wl.h"
30 #include <drag-and-drop-detector-impl.h>
31 #include <window-visibility-observer.h>
32 #include <orientation-impl.h>
42 #if defined(DEBUG_ENABLED)
43 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
46 struct Window::EventHandler
51 Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
53 Window* window = new Window();
54 window->mIsTransparent = isTransparent;
55 window->Initialize(posSize, name, className);
59 void Window::SetAdaptor(Dali::Adaptor& adaptor)
61 DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
64 // Only create one overlay per window
65 Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
66 Integration::Core& core = adaptorImpl.GetCore();
67 mOverlay = &core.GetSystemOverlay();
69 Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
70 taskList.CreateTask();
72 mAdaptor = &adaptorImpl;
73 mAdaptor->AddObserver( *this );
75 // Can only create the detector when we know the Core has been instantiated.
76 mDragAndDropDetector = DragAndDropDetector::New();
77 mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
82 RenderSurface* Window::GetSurface()
87 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
92 void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
96 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
100 void Window::SetClass(std::string name, std::string klass)
106 mIndicatorVisible( Dali::Window::VISIBLE ),
107 mIndicatorIsShown( false ),
108 mShowRotatedIndicatorOnClose( false ),
110 mIsTransparent( false ),
111 mWMRotationAppSet( false ),
112 mIsFocusAcceptable( true ),
114 mOpaqueState( false ),
116 mIndicatorOrientation( Dali::Window::PORTRAIT ),
117 mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
118 mIndicatorOpacityMode( Dali::Window::OPAQUE ),
121 mType( Dali::DevelWindow::NORMAL ),
122 mPreferredOrientation( Dali::Window::PORTRAIT ),
123 mSupportedAuxiliaryHints(),
126 mEventHandler = NULL;
131 delete mEventHandler;
135 mAdaptor->RemoveObserver( *this );
136 mAdaptor->SetDragAndDropDetector( NULL );
143 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
145 // create an Wayland window by default
147 Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
149 mSurface = windowSurface;
151 mOrientation = Orientation::New(this);
155 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
160 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
165 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
169 void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
173 void Window::IndicatorClosed( IndicatorInterface* indicator )
178 void Window::IndicatorVisibilityChanged(bool isVisible)
183 void Window::SetIndicatorActorRotation()
196 void Window::Activate()
200 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
202 return mDragAndDropDetector;
205 Dali::Any Window::GetNativeHandle() const
207 Wayland::RenderSurface* surface = static_cast< Wayland::RenderSurface* >( mSurface );
209 return surface->GetWindow();
212 void Window::OnStart()
216 void Window::OnPause()
220 void Window::OnResume()
224 void Window::OnStop()
228 void Window::OnDestroy()
233 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
237 for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
239 if(mAvailableOrientations[i] == orientation)
248 mAvailableOrientations.push_back(orientation);
249 SetAvailableOrientations( mAvailableOrientations );
253 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
255 for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
256 iter != mAvailableOrientations.end(); ++iter )
258 if( *iter == orientation )
260 mAvailableOrientations.erase( iter );
264 SetAvailableOrientations( mAvailableOrientations );
267 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
269 DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
272 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
274 return mAvailableOrientations;
277 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
279 mPreferredOrientation = orientation;
282 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
284 return mPreferredOrientation;
287 void Window::SetAcceptFocus( bool accept )
289 mIsFocusAcceptable = accept;
292 bool Window::IsFocusAcceptable()
294 return mIsFocusAcceptable;
307 bool Window::IsVisible() const
312 void Window::RotationDone( int orientation, int width, int height )
316 unsigned int Window::GetSupportedAuxiliaryHintCount()
321 std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
323 return std::string();
326 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
331 bool Window::RemoveAuxiliaryHint( unsigned int id )
336 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
341 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
343 return std::string();
346 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
351 void Window::SetInputRegion( const Rect< int >& inputRegion )
355 void Window::SetType( Dali::DevelWindow::Type type )
360 Dali::DevelWindow::Type Window::GetType() const
365 bool Window::SetNotificationLevel( Dali::DevelWindow::NotificationLevel::Type level )
370 Dali::DevelWindow::NotificationLevel::Type Window::GetNotificationLevel()
372 return Dali::DevelWindow::NotificationLevel::NONE;
375 void Window::SetOpaqueState( bool opaque )
377 mOpaqueState = opaque;
380 bool Window::IsOpaqueState()
385 bool Window::SetScreenMode( Dali::DevelWindow::ScreenMode::Type screenMode )
390 Dali::DevelWindow::ScreenMode::Type Window::GetScreenMode()
392 return Dali::DevelWindow::ScreenMode::DEFAULT;
395 bool Window::SetBrightness( int brightness )
400 int Window::GetBrightness()
405 void* Window::GetNativeWindowHandler()