Revert "[Tizen] keygrab & ecore-wl-window-handle c# binding"
[platform/core/uifw/dali-adaptor.git] / adaptors / common / window-impl.h
1 #ifndef __DALI_INTERNAL_WINDOW_H__
2 #define __DALI_INTERNAL_WINDOW_H__
3
4 /*
5  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <base/lifecycle-observer.h>
27 #include <base/interfaces/indicator-interface.h>
28 #include <adaptor-impl.h>
29 #include <window.h>
30 #include <orientation.h>
31 #include <render-surface.h>
32 #include <drag-and-drop-detector.h>
33 #include <window-devel.h>
34
35 namespace Dali
36 {
37 class Adaptor;
38 class RenderSurface;
39
40 namespace Integration
41 {
42 class SystemOverlay;
43 }
44
45 namespace Internal
46 {
47 namespace Adaptor
48 {
49 class Orientation;
50
51 class Window;
52 typedef IntrusivePtr<Window> WindowPtr;
53 typedef IntrusivePtr<Orientation> OrientationPtr;
54
55 /**
56  * Window provides a surface to render onto with orientation & indicator properties.
57  */
58 class Window : public Dali::BaseObject, public IndicatorInterface::Observer, public LifeCycleObserver
59 {
60 public:
61   typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
62   typedef Dali::DevelWindow::FocusSignalType FocusSignalType;
63   typedef Signal< void () > SignalType;
64
65   /**
66    * Create a new Window. This should only be called once by the Application class
67    * @param[in] windowPosition The position and size of the window
68    * @param[in] name The window title
69    * @param[in] className The window class name
70    * @param[in] isTransparent Whether window is transparent
71    * @return A newly allocated Window
72    */
73   static Window* New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent = false);
74
75   /**
76    * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
77    * @param[in] adaptor An initialized adaptor
78    */
79   void SetAdaptor(Dali::Adaptor& adaptor);
80
81   /**
82    * Get the window surface
83    * @return The render surface
84    */
85   RenderSurface* GetSurface();
86
87   /**
88    * @copydoc Dali::Window::ShowIndicator()
89    */
90   void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
91
92   /**
93    * @copydoc Dali::Window::SetIndicatorBgOpacity()
94    */
95   void SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacity );
96
97   /**
98    * @copydoc Dali::Window::RotateIndicator()
99    */
100   void RotateIndicator( Dali::Window::WindowOrientation orientation );
101
102   /**
103    * @copydoc Dali::Window::SetClass()
104    */
105   void SetClass( std::string name, std::string klass );
106
107   /**
108    * @copydoc Dali::Window::Raise()
109    */
110   void Raise();
111
112   /**
113    * @copydoc Dali::Window::Lower()
114    */
115   void Lower();
116
117   /**
118    * @copydoc Dali::Window::Activate()
119    */
120   void Activate();
121
122   /**
123    * @copydoc Dali::Window::AddAvailableOrientation()
124    */
125   void AddAvailableOrientation(Dali::Window::WindowOrientation orientation);
126
127   /**
128    * @copydoc Dali::Window::RemoveAvailableOrientation()
129    */
130   void RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation);
131
132   /**
133    * @copydoc Dali::Window::SetAvailableOrientations()
134    */
135   void SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations);
136
137   /**
138    * @copydoc Dali::Window::GetAvailableOrientations()
139    */
140   const std::vector<Dali::Window::WindowOrientation>& GetAvailableOrientations();
141
142   /**
143    * @copydoc Dali::Window::SetPreferredOrientation()
144    */
145   void SetPreferredOrientation(Dali::Window::WindowOrientation orientation);
146
147   /**
148    * @copydoc Dali::Window::GetPreferredOrientation()
149    */
150   Dali::Window::WindowOrientation GetPreferredOrientation();
151
152   /**
153    * @copydoc Dali::Window::GetDragAndDropDetector() const
154    */
155   Dali::DragAndDropDetector GetDragAndDropDetector() const;
156
157   /**
158    * @copydoc Dali::Window::GetNativeHandle() const
159    */
160   Dali::Any GetNativeHandle() const;
161
162   /**
163    * @copydoc Dali::DevelWindow::SetAcceptFocus()
164    */
165   void SetAcceptFocus( bool accept );
166
167   /**
168    * @copydoc Dali::DevelWindow::IsFocusAcceptable()
169    */
170   bool IsFocusAcceptable();
171
172   /**
173    * @copydoc Dali::DevelWindow::Show()
174    */
175   void Show();
176
177   /**
178    * @copydoc Dali::DevelWindow::Hide()
179    */
180   void Hide();
181
182   /**
183    * @copydoc Dali::DevelWindow::IsVisible() const
184    */
185   bool IsVisible() const;
186
187   /**
188    * @copydoc Dali::DevelWindow::GetSupportedAuxiliaryHintCount()
189    */
190    unsigned int GetSupportedAuxiliaryHintCount();
191
192    /**
193     * @copydoc Dali::DevelWindow::GetSupportedAuxiliaryHint()
194     */
195   std::string GetSupportedAuxiliaryHint( unsigned int index );
196
197   /**
198    * @copydoc Dali::DevelWindow::AddAuxiliaryHint()
199    */
200   unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
201
202   /**
203    * @copydoc Dali::DevelWindow::RemoveAuxiliaryHint()
204    */
205   bool RemoveAuxiliaryHint( unsigned int id );
206
207   /**
208    * @copydoc Dali::DevelWindow::SetAuxiliaryHintValue()
209    */
210   bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
211
212   /**
213    * @copydoc Dali::DevelWindow::GetAuxiliaryHintValue()
214    */
215   std::string GetAuxiliaryHintValue( unsigned int id ) const;
216
217   /**
218    * @copydoc Dali::DevelWindow::GetAuxiliaryHintId()
219    */
220   unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
221
222   /**
223    * @copydoc Dali::DevelWindow::SetInputRegion()
224    */
225   void SetInputRegion( const Rect< int >& inputRegion );
226
227   /**
228    * @copydoc Dali::DevelWindow::SetType()
229    */
230   void SetType( Dali::DevelWindow::Type type );
231
232   /**
233    * @copydoc Dali::DevelWindow::GetType() const
234    */
235   Dali::DevelWindow::Type GetType() const;
236
237   /**
238    * @copydoc Dali::DevelWindow::SetNotificationLevel()
239    */
240   bool SetNotificationLevel( Dali::DevelWindow::NotificationLevel::Type level );
241
242   /**
243    * @copydoc Dali::DevelWindow::GetNotificationLevel()
244    */
245   Dali::DevelWindow::NotificationLevel::Type GetNotificationLevel();
246
247   /**
248    * @copydoc Dali::DevelWindow::SetOpaqueState()
249    */
250   void SetOpaqueState( bool opaque );
251
252   /**
253    * @copydoc Dali::DevelWindow::IsOpaqueState()
254    */
255   bool IsOpaqueState();
256
257   /**
258    * @copydoc Dali::DevelWindow::SetScreenMode()
259    */
260   bool SetScreenMode( Dali::DevelWindow::ScreenMode::Type screenMode );
261
262   /**
263    * @copydoc Dali::DevelWindow::GetScreenMode()
264    */
265   Dali::DevelWindow::ScreenMode::Type GetScreenMode();
266
267   /**
268    * @copydoc Dali::DevelWindow::SetBrightness()
269    */
270   bool SetBrightness( int brightness );
271
272   /**
273    * @copydoc Dali::DevelWindow::GetBrightness()
274    */
275   int GetBrightness();
276
277   /**
278    * Called from Orientation after the Change signal has been sent
279    */
280   void RotationDone( int orientation, int width, int height );
281
282 private:
283   /**
284    * Private constructor.
285    * @sa Window::New()
286    */
287   Window();
288
289   /**
290    * Destructor
291    */
292   virtual ~Window();
293
294   /**
295    * Second stage initialization
296    */
297   void Initialize(const PositionSize& posSize, const std::string& name, const std::string& className);
298
299   /**
300    * Shows / hides the indicator bar.
301    * Handles close/open if rotation changes whilst hidden
302    */
303   void DoShowIndicator( Dali::Window::WindowOrientation lastOrientation );
304
305   /**
306    * Close current indicator and open a connection onto the new indicator service.
307    * Effect may not be synchronous if waiting for an indicator update on existing connection.
308    */
309   void DoRotateIndicator( Dali::Window::WindowOrientation orientation );
310
311   /**
312    * Change the indicator actor's rotation to match the current orientation
313    */
314   void SetIndicatorActorRotation();
315
316   /**
317    * Set the indicator properties on the window
318    */
319   void SetIndicatorProperties( bool isShown, Dali::Window::WindowOrientation lastOrientation );
320
321 private: // IndicatorInterface::Observer interface
322
323   /**
324    * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorTypeChanged()
325    */
326   virtual void IndicatorTypeChanged( IndicatorInterface::Type type );
327
328   /**
329    * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorClosed()
330    */
331   virtual void IndicatorClosed( IndicatorInterface* indicator);
332
333   /**
334    * @copydoc Dali::Internal::Adaptor::IndicatorInterface::Observer::IndicatorVisibilityChanged()
335    */
336   virtual void IndicatorVisibilityChanged( bool isVisible );
337
338 private: // Adaptor::Observer interface
339
340   /**
341    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
342    */
343   virtual void OnStart();
344
345   /**
346    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
347    */
348   virtual void OnPause();
349
350   /**
351    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
352    */
353   virtual void OnResume();
354
355   /**
356    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
357    */
358   virtual void OnStop();
359
360   /**
361    * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
362    */
363   virtual void OnDestroy();
364
365 public: // Signals
366
367   /**
368    * The user should connect to this signal to get a timing when indicator was shown / hidden.
369    */
370   IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
371
372   /**
373    * The user should connect to this signal to get a timing when window gains focus or loses focus.
374    */
375   FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
376
377   /**
378    * This signal is emitted when the window is requesting to be deleted
379    */
380   SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
381
382 private:
383
384   typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
385
386   RenderSurface*                   mSurface;
387   Dali::Window::IndicatorVisibleMode mIndicatorVisible; ///< public state
388   bool                             mIndicatorIsShown:1; ///< private state
389   bool                             mShowRotatedIndicatorOnClose:1;
390   bool                             mStarted:1;
391   bool                             mIsTransparent:1;
392   bool                             mWMRotationAppSet:1;
393   bool                             mEcoreEventHander:1;
394   bool                             mIsFocusAcceptable:1;
395   bool                             mVisible:1;
396   bool                             mOpaqueState:1;
397   IndicatorInterface*              mIndicator;
398   Dali::Window::WindowOrientation  mIndicatorOrientation;
399   Dali::Window::WindowOrientation  mNextIndicatorOrientation;
400   Dali::Window::IndicatorBgOpacity mIndicatorOpacityMode;
401   Integration::SystemOverlay*      mOverlay;
402   Adaptor*                         mAdaptor;
403   Dali::DragAndDropDetector        mDragAndDropDetector;
404   Dali::DevelWindow::Type          mType;
405
406   struct EventHandler;
407   EventHandler*                    mEventHandler;
408
409   OrientationPtr                               mOrientation;
410   std::vector<Dali::Window::WindowOrientation> mAvailableOrientations;
411   Dali::Window::WindowOrientation              mPreferredOrientation;
412
413   std::vector< std::string >        mSupportedAuxiliaryHints;
414   AuxiliaryHints                    mAuxiliaryHints;
415
416   // Signals
417   IndicatorSignalType mIndicatorVisibilityChangedSignal;
418   FocusSignalType     mFocusChangedSignal;
419   SignalType          mDeleteRequestSignal;
420 };
421
422 } // namespace Adaptor
423 } // namepsace Internal
424
425 // Helpers for public-api forwarding methods
426
427 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
428 {
429   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
430   BaseObject& object = window.GetBaseObject();
431   return static_cast<Internal::Adaptor::Window&>(object);
432 }
433
434 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
435 {
436   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
437   const BaseObject& object = window.GetBaseObject();
438   return static_cast<const Internal::Adaptor::Window&>(object);
439 }
440
441 } // namespace Dali
442
443
444 #endif // __DALI_INTERNAL_WINDOW_H__