Revert "[Tizen] keygrab & ecore-wl-window-handle c# binding"
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / window-impl-wl.cpp
1 /*
2  * Copyright (c) 2017 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   mVisible( true ),
114   mOpaqueState( false ),
115   mIndicator( NULL ),
116   mIndicatorOrientation( Dali::Window::PORTRAIT ),
117   mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
118   mIndicatorOpacityMode( Dali::Window::OPAQUE ),
119   mOverlay( NULL ),
120   mAdaptor( NULL ),
121   mType( Dali::DevelWindow::NORMAL ),
122   mPreferredOrientation( Dali::Window::PORTRAIT ),
123   mSupportedAuxiliaryHints(),
124   mAuxiliaryHints()
125 {
126   mEventHandler = NULL;
127 }
128
129 Window::~Window()
130 {
131   delete mEventHandler;
132
133   if ( mAdaptor )
134   {
135     mAdaptor->RemoveObserver( *this );
136     mAdaptor->SetDragAndDropDetector( NULL );
137     mAdaptor = NULL;
138   }
139
140   delete mSurface;
141 }
142
143 void Window::Initialize(const PositionSize& windowPosition, const std::string& name, const std::string& className)
144 {
145   // create an Wayland window by default
146   Any surface;
147   Wayland::RenderSurface* windowSurface = new Wayland::RenderSurface( windowPosition, surface, name, mIsTransparent );
148
149   mSurface = windowSurface;
150
151   mOrientation = Orientation::New(this);
152
153 }
154
155 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
156 {
157
158 }
159
160 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
161 {
162
163 }
164
165 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
166 {
167 }
168
169 void Window::IndicatorTypeChanged(IndicatorInterface::Type type)
170 {
171 }
172
173 void Window::IndicatorClosed( IndicatorInterface* indicator )
174 {
175
176 }
177
178 void Window::IndicatorVisibilityChanged(bool isVisible)
179 {
180
181 }
182
183 void Window::SetIndicatorActorRotation()
184 {
185
186 }
187
188 void Window::Raise()
189 {
190 }
191
192 void Window::Lower()
193 {
194 }
195
196 void Window::Activate()
197 {
198 }
199
200 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
201 {
202   return mDragAndDropDetector;
203 }
204
205 Dali::Any Window::GetNativeHandle() const
206 {
207   Wayland::RenderSurface* surface = static_cast<  Wayland::RenderSurface* >( mSurface );
208
209   return surface->GetWindow();
210 }
211
212 void Window::OnStart()
213 {
214 }
215
216 void Window::OnPause()
217 {
218 }
219
220 void Window::OnResume()
221 {
222 }
223
224 void Window::OnStop()
225 {
226 }
227
228 void Window::OnDestroy()
229 {
230   mAdaptor = NULL;
231 }
232
233 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
234 {
235   bool found = false;
236
237   for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
238   {
239     if(mAvailableOrientations[i] == orientation)
240     {
241       found = true;
242       break;
243     }
244   }
245
246   if( ! found )
247   {
248     mAvailableOrientations.push_back(orientation);
249     SetAvailableOrientations( mAvailableOrientations );
250   }
251 }
252
253 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
254 {
255   for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
256        iter != mAvailableOrientations.end(); ++iter )
257   {
258     if( *iter == orientation )
259     {
260       mAvailableOrientations.erase( iter );
261       break;
262     }
263   }
264   SetAvailableOrientations( mAvailableOrientations );
265 }
266
267 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
268 {
269   DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
270 }
271
272 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
273 {
274   return mAvailableOrientations;
275 }
276
277 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
278 {
279   mPreferredOrientation = orientation;
280 }
281
282 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
283 {
284   return mPreferredOrientation;
285 }
286
287 void Window::SetAcceptFocus( bool accept )
288 {
289   mIsFocusAcceptable = accept;
290 }
291
292 bool Window::IsFocusAcceptable()
293 {
294   return mIsFocusAcceptable;
295 }
296
297 void Window::Show()
298 {
299   mVisible = true;
300 }
301
302 void Window::Hide()
303 {
304   mVisible = false;
305 }
306
307 bool Window::IsVisible() const
308 {
309   return mVisible;
310 }
311
312
313 void Window::RotationDone( int orientation, int width, int height )
314 {
315 }
316
317 unsigned int Window::GetSupportedAuxiliaryHintCount()
318 {
319   return 0;
320 }
321
322 std::string Window::GetSupportedAuxiliaryHint( unsigned int index )
323 {
324   return std::string();
325 }
326
327 unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
328 {
329   return -1;
330 }
331
332 bool Window::RemoveAuxiliaryHint( unsigned int id )
333 {
334   return false;
335 }
336
337 bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
338 {
339   return false;
340 }
341
342 std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
343 {
344   return std::string();
345 }
346
347 unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
348 {
349   return -1;
350 }
351
352 void Window::SetInputRegion( const Rect< int >& inputRegion )
353 {
354 }
355
356 void Window::SetType( Dali::DevelWindow::Type type )
357 {
358   mType = type;
359 }
360
361 Dali::DevelWindow::Type Window::GetType() const
362 {
363   return mType;
364 }
365
366 bool Window::SetNotificationLevel( Dali::DevelWindow::NotificationLevel::Type level )
367 {
368   return false;
369 }
370
371 Dali::DevelWindow::NotificationLevel::Type Window::GetNotificationLevel()
372 {
373   return Dali::DevelWindow::NotificationLevel::NONE;
374 }
375
376 void Window::SetOpaqueState( bool opaque )
377 {
378   mOpaqueState = opaque;
379 }
380
381 bool Window::IsOpaqueState()
382 {
383   return mOpaqueState;
384 }
385
386 bool Window::SetScreenMode( Dali::DevelWindow::ScreenMode::Type screenMode )
387 {
388   return false;
389 }
390
391 Dali::DevelWindow::ScreenMode::Type Window::GetScreenMode()
392 {
393   return Dali::DevelWindow::ScreenMode::DEFAULT;
394 }
395
396 bool Window::SetBrightness( int brightness )
397 {
398   return false;
399 }
400
401 int Window::GetBrightness()
402 {
403   return 0;
404 }
405
406 } // Adaptor
407 } // Internal
408 } // Dali