Merge "Fixed Svace Issue" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / window-impl-wl.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "window-impl.h"
20
21 // EXTERNAL HEADERS
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>
27
28 // INTERNAL HEADERS
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>
33
34
35
36 namespace Dali
37 {
38 namespace Internal
39 {
40 namespace Adaptor
41 {
42 #if defined(DEBUG_ENABLED)
43 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
44 #endif
45
46 struct Window::EventHandler
47 {
48   // place holder
49 };
50
51 Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
52 {
53   Window* window = new Window();
54   window->mIsTransparent = isTransparent;
55   window->Initialize(posSize, name, className);
56   return window;
57 }
58
59 void Window::SetAdaptor(Dali::Adaptor& adaptor)
60 {
61   DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
62   mStarted = true;
63
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();
68
69   Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
70   taskList.CreateTask();
71
72   mAdaptor = &adaptorImpl;
73   mAdaptor->AddObserver( *this );
74
75   // Can only create the detector when we know the Core has been instantiated.
76   mDragAndDropDetector = DragAndDropDetector::New();
77   mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
78
79
80 }
81
82 RenderSurface* Window::GetSurface()
83 {
84   return mSurface;
85 }
86
87 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
88 {
89
90 }
91
92 void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
93 {
94 }
95
96 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
97 {
98 }
99
100 void Window::SetClass(std::string name, std::string klass)
101 {
102 }
103
104 Window::Window()
105 : mSurface(NULL),
106   mIndicatorVisible(Dali::Window::VISIBLE),
107   mIndicatorIsShown(false),
108   mShowRotatedIndicatorOnClose(false),
109   mStarted(false),
110   mIsTransparent(false),
111   mWMRotationAppSet(false),
112   mIndicator(NULL),
113   mIndicatorOrientation(Dali::Window::PORTRAIT),
114   mNextIndicatorOrientation(Dali::Window::PORTRAIT),
115   mIndicatorOpacityMode(Dali::Window::OPAQUE),
116   mOverlay(NULL),
117   mAdaptor(NULL),
118   mPreferredOrientation(Dali::Window::PORTRAIT)
119 {
120   mEventHandler = NULL;
121 }
122
123 Window::~Window()
124 {
125   delete mEventHandler;
126
127   if ( mAdaptor )
128   {
129     mAdaptor->RemoveObserver( *this );
130     mAdaptor->SetDragAndDropDetector( NULL );
131     mAdaptor = NULL;
132   }
133
134   delete mSurface;
135 }
136
137 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
138 {
139   // create an Wayland window by default
140   Any surface;
141   Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
142
143   mSurface = windowSurface;
144
145   mOrientation = Orientation::New(this);
146
147 }
148
149 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
150 {
151
152 }
153
154 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
155 {
156
157 }
158
159 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
160 {
161 }
162
163 void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
164 {
165 }
166
167 void Window::IndicatorClosed( IndicatorInterface* indicator )
168 {
169
170 }
171
172 void Window::IndicatorVisibilityChanged(bool isVisible)
173 {
174
175 }
176
177 void Window::SetIndicatorActorRotation()
178 {
179
180 }
181
182 void Window::Raise()
183 {
184 }
185
186 void Window::Lower()
187 {
188 }
189
190 void Window::Activate()
191 {
192 }
193
194 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
195 {
196   return mDragAndDropDetector;
197 }
198
199 Dali::Any Window::GetNativeHandle() const
200 {
201   Wayland::RenderSurface* surface = static_cast<  Wayland::RenderSurface* >( mSurface );
202
203   return surface->GetWindow();
204 }
205
206 void Window::OnStart()
207 {
208 }
209
210 void Window::OnPause()
211 {
212 }
213
214 void Window::OnResume()
215 {
216 }
217
218 void Window::OnStop()
219 {
220 }
221
222 void Window::OnDestroy()
223 {
224   mAdaptor = NULL;
225 }
226
227 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
228 {
229   bool found = false;
230
231   for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
232   {
233     if(mAvailableOrientations[i] == orientation)
234     {
235       found = true;
236       break;
237     }
238   }
239
240   if( ! found )
241   {
242     mAvailableOrientations.push_back(orientation);
243     SetAvailableOrientations( mAvailableOrientations );
244   }
245 }
246
247 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
248 {
249   for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
250        iter != mAvailableOrientations.end(); ++iter )
251   {
252     if( *iter == orientation )
253     {
254       mAvailableOrientations.erase( iter );
255       break;
256     }
257   }
258   SetAvailableOrientations( mAvailableOrientations );
259 }
260
261 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
262 {
263   DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
264 }
265
266 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
267 {
268   return mAvailableOrientations;
269 }
270
271 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
272 {
273   mPreferredOrientation = orientation;
274 }
275
276 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
277 {
278   return mPreferredOrientation;
279 }
280
281 void Window::RotationDone( int orientation, int width, int height )
282 {
283 }
284
285
286 } // Adaptor
287 } // Internal
288 } // Dali