Merge "spec fix: version check error" into tizen
[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   mIsFocusAcceptable( true ),
113   mIndicator( NULL ),
114   mIndicatorOrientation( Dali::Window::PORTRAIT ),
115   mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
116   mIndicatorOpacityMode( Dali::Window::OPAQUE ),
117   mOverlay( NULL ),
118   mAdaptor( NULL ),
119   mPreferredOrientation( Dali::Window::PORTRAIT )
120 {
121   mEventHandler = NULL;
122 }
123
124 Window::~Window()
125 {
126   delete mEventHandler;
127
128   if ( mAdaptor )
129   {
130     mAdaptor->RemoveObserver( *this );
131     mAdaptor->SetDragAndDropDetector( NULL );
132     mAdaptor = NULL;
133   }
134
135   delete mSurface;
136 }
137
138 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
139 {
140   // create an Wayland window by default
141   Any surface;
142   Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
143
144   mSurface = windowSurface;
145
146   mOrientation = Orientation::New(this);
147
148 }
149
150 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
151 {
152
153 }
154
155 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
156 {
157
158 }
159
160 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
161 {
162 }
163
164 void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
165 {
166 }
167
168 void Window::IndicatorClosed( IndicatorInterface* indicator )
169 {
170
171 }
172
173 void Window::IndicatorVisibilityChanged(bool isVisible)
174 {
175
176 }
177
178 void Window::SetIndicatorActorRotation()
179 {
180
181 }
182
183 void Window::Raise()
184 {
185 }
186
187 void Window::Lower()
188 {
189 }
190
191 void Window::Activate()
192 {
193 }
194
195 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
196 {
197   return mDragAndDropDetector;
198 }
199
200 Dali::Any Window::GetNativeHandle() const
201 {
202   Wayland::RenderSurface* surface = static_cast<  Wayland::RenderSurface* >( mSurface );
203
204   return surface->GetWindow();
205 }
206
207 void Window::OnStart()
208 {
209 }
210
211 void Window::OnPause()
212 {
213 }
214
215 void Window::OnResume()
216 {
217 }
218
219 void Window::OnStop()
220 {
221 }
222
223 void Window::OnDestroy()
224 {
225   mAdaptor = NULL;
226 }
227
228 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
229 {
230   bool found = false;
231
232   for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
233   {
234     if(mAvailableOrientations[i] == orientation)
235     {
236       found = true;
237       break;
238     }
239   }
240
241   if( ! found )
242   {
243     mAvailableOrientations.push_back(orientation);
244     SetAvailableOrientations( mAvailableOrientations );
245   }
246 }
247
248 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
249 {
250   for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
251        iter != mAvailableOrientations.end(); ++iter )
252   {
253     if( *iter == orientation )
254     {
255       mAvailableOrientations.erase( iter );
256       break;
257     }
258   }
259   SetAvailableOrientations( mAvailableOrientations );
260 }
261
262 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
263 {
264   DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
265 }
266
267 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
268 {
269   return mAvailableOrientations;
270 }
271
272 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
273 {
274   mPreferredOrientation = orientation;
275 }
276
277 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
278 {
279   return mPreferredOrientation;
280 }
281
282 void Window::SetAcceptFocus( bool accept )
283 {
284   mIsFocusAcceptable = accept;
285 }
286
287 bool Window::IsFocusAcceptable()
288 {
289   return mIsFocusAcceptable;
290 }
291
292 void Window::RotationDone( int orientation, int width, int height )
293 {
294 }
295
296 } // Adaptor
297 } // Internal
298 } // Dali