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