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