2 * Copyright (c) 2015 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),
113 mIndicatorOrientation(Dali::Window::PORTRAIT),
114 mNextIndicatorOrientation(Dali::Window::PORTRAIT),
115 mIndicatorOpacityMode(Dali::Window::OPAQUE),
119 mEventHandler = NULL;
124 delete mEventHandler;
128 mAdaptor->RemoveObserver( *this );
129 mAdaptor->SetDragAndDropDetector( NULL );
136 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
138 // create an Wayland window by default
140 Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
142 mSurface = windowSurface;
144 mOrientation = Orientation::New(this);
148 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
153 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
158 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
162 void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
166 void Window::IndicatorClosed( IndicatorInterface* indicator )
171 void Window::IndicatorVisibilityChanged(bool isVisible)
176 void Window::SetIndicatorActorRotation()
189 void Window::Activate()
193 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
195 return mDragAndDropDetector;
198 Dali::Any Window::GetNativeHandle() const
200 Wayland::RenderSurface* surface = static_cast< Wayland::RenderSurface* >( mSurface );
202 return surface->GetWindow();
205 void Window::OnStart()
209 void Window::OnPause()
213 void Window::OnResume()
217 void Window::OnStop()
221 void Window::OnDestroy()
226 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
230 for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
232 if(mAvailableOrientations[i] == orientation)
241 mAvailableOrientations.push_back(orientation);
242 SetAvailableOrientations( mAvailableOrientations );
246 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
248 for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
249 iter != mAvailableOrientations.end(); ++iter )
251 if( *iter == orientation )
253 mAvailableOrientations.erase( iter );
257 SetAvailableOrientations( mAvailableOrientations );
260 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
262 DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
265 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
267 return mAvailableOrientations;
270 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
272 mPreferredOrientation = orientation;
275 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
277 return mPreferredOrientation;
280 void Window::RotationDone( int orientation, int width, int height )