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(),
125 mIndicatorVisibilityChangedSignal(),
126 mFocusChangedSignal(),
128 mDeleteRequestSignal()
130 mEventHandler = NULL;
135 delete mEventHandler;
139 mAdaptor->RemoveObserver( *this );
140 mAdaptor->SetDragAndDropDetector( NULL );
147 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
149 // create an Wayland window by default
151 Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
153 mSurface = windowSurface;
155 mOrientation = Orientation::New(this);
159 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
164 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
169 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
173 void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
177 void Window::IndicatorClosed( IndicatorInterface* indicator )
182 void Window::IndicatorVisibilityChanged(bool isVisible)
187 void Window::SetIndicatorActorRotation()
200 void Window::Activate()
204 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
206 return mDragAndDropDetector;
209 Dali::Any Window::GetNativeHandle() const
211 Wayland::RenderSurface* surface = static_cast< Wayland::RenderSurface* >( mSurface );
213 return surface->GetWindow();
216 void Window::OnStart()
220 void Window::OnPause()
224 void Window::OnResume()
228 void Window::OnStop()
232 void Window::OnDestroy()
237 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
241 for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
243 if(mAvailableOrientations[i] == orientation)
252 mAvailableOrientations.push_back(orientation);
253 SetAvailableOrientations( mAvailableOrientations );
257 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
259 for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
260 iter != mAvailableOrientations.end(); ++iter )
262 if( *iter == orientation )
264 mAvailableOrientations.erase( iter );
268 SetAvailableOrientations( mAvailableOrientations );
271 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
273 DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
276 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
278 return mAvailableOrientations;
281 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
283 mPreferredOrientation = orientation;
286 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
288 return mPreferredOrientation;
291 void Window::SetAcceptFocus( bool accept )
293 mIsFocusAcceptable = accept;
296 bool Window::IsFocusAcceptable()
298 return mIsFocusAcceptable;
311 bool Window::IsVisible() const
317 void Window::RotationDone( int orientation, int width, int height )
321 unsigned int Window::GetSupportedAuxiliaryHintCount()
326 std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
328 return std::string();
331 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
336 bool Window::RemoveAuxiliaryHint( unsigned int id )
341 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
346 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
348 return std::string();
351 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
356 void Window::SetInputRegion( const Rect< int >& inputRegion )
360 void Window::SetType( Dali::DevelWindow::Type type )
365 Dali::DevelWindow::Type Window::GetType() const
370 bool Window::SetNotificationLevel( Dali::DevelWindow::NotificationLevel::Type level )
375 Dali::DevelWindow::NotificationLevel::Type Window::GetNotificationLevel()
377 return Dali::DevelWindow::NotificationLevel::NONE;
380 void Window::SetOpaqueState( bool opaque )
382 mOpaqueState = opaque;
385 bool Window::IsOpaqueState()
390 bool Window::SetScreenMode( Dali::DevelWindow::ScreenMode::Type screenMode )
395 Dali::DevelWindow::ScreenMode::Type Window::GetScreenMode()
397 return Dali::DevelWindow::ScreenMode::DEFAULT;
400 bool Window::SetBrightness( int brightness )
405 int Window::GetBrightness()