Supports some tizen window features.
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-base.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
3
4 /*
5  * Copyright (c) 2021 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/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/point.h>
24 #include <dali/integration-api/events/wheel-event-integ.h>
25 #include <cstdint>
26 #include <string>
27 #include <vector>
28
29 // INTERNAL INCLUDES
30 #include <dali/devel-api/adaptor-framework/window-devel.h>
31 #include <dali/internal/graphics/gles/egl-implementation.h>
32 #include <dali/internal/window-system/common/damage-observer.h>
33 #include <dali/internal/window-system/common/rotation-event.h>
34 #include <dali/public-api/adaptor-framework/key-grab.h>
35 #include <dali/public-api/adaptor-framework/style-change.h>
36 #include <dali/public-api/adaptor-framework/window-enumerations.h>
37 #include <dali/public-api/adaptor-framework/window.h>
38
39 namespace Dali
40 {
41 namespace Internal
42 {
43 namespace Adaptor
44 {
45 /**
46  * WindowBase interface
47  */
48 class WindowBase
49 {
50 public:
51   /**
52    * @brief Struct used to retrieve accessibility information
53    */
54   struct AccessibilityInfo
55   {
56     int gestureValue;
57     int startX;
58     int startY;
59     int endX;
60     int endY;
61     int state;
62     int eventTime;
63   };
64
65   // Window
66   typedef Signal<void(bool)>                                IconifySignalType;
67   typedef Signal<void(bool)>                                FocusSignalType;
68   typedef Signal<void()>                                    OutputSignalType;
69   typedef Signal<void()>                                    DeleteSignalType;
70   typedef Signal<void(const DamageArea&)>                   DamageSignalType;
71   typedef Signal<void(const RotationEvent&)>                RotationSignalType;
72   typedef Signal<void(WindowEffectState, WindowEffectType)> TransitionEffectEventSignalType;
73   typedef Signal<void()>                                    KeyboardRepeatSettingsChangedSignalType;
74   typedef Signal<void()>                                    WindowRedrawRequestSignalType;
75   typedef Signal<void(Dali::PositionSize&)>                 UpdatePositionSizeType;
76
77   // Input events
78   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
79   typedef Signal<void(Integration::WheelEvent&)>      WheelEventSignalType;
80   typedef Signal<void(Integration::KeyEvent&)>        KeyEventSignalType;
81
82   // Clipboard
83   typedef Signal<void(void*)> SelectionSignalType;
84
85   // Accessibility
86   typedef Signal<void(StyleChange::Type)>        StyleSignalType;
87   typedef Signal<void(const AccessibilityInfo&)> AccessibilitySignalType;
88
89   /**
90    * @brief Default constructor
91    */
92   WindowBase();
93
94   /**
95    * @brief Destructor
96    */
97   virtual ~WindowBase();
98
99 public:
100   /**
101    * @brief Get the native window handle
102    * @return The native window handle
103    */
104   virtual Any GetNativeWindow() = 0;
105
106   /**
107    * @brief Get the native window id
108    * @return The native window id
109    */
110   virtual int GetNativeWindowId() = 0;
111
112   /**
113    * @brief Create the egl window
114    */
115   virtual EGLNativeWindowType CreateEglWindow(int width, int height) = 0;
116
117   /**
118    * @brief Destroy the egl window
119    */
120   virtual void DestroyEglWindow() = 0;
121
122   /**
123    * @brief Set the egl window rotation
124    */
125   virtual void SetEglWindowRotation(int angle) = 0;
126
127   /**
128    * @brief Set the egl window buffer transform
129    */
130   virtual void SetEglWindowBufferTransform(int angle) = 0;
131
132   /**
133    * @brief Set the egl window transform
134    */
135   virtual void SetEglWindowTransform(int angle) = 0;
136
137   /**
138    * @brief Resize the egl window
139    */
140   virtual void ResizeEglWindow(Dali::PositionSize positionSize) = 0;
141
142   /**
143    * @brief Returns whether the egl window support rotation or not
144    */
145   virtual bool IsEglWindowRotationSupported() = 0;
146
147   /**
148    * @brief Move the window
149    */
150   virtual void Move(Dali::PositionSize positionSize) = 0;
151
152   /**
153    * @brief Resize the window
154    */
155   virtual void Resize(Dali::PositionSize positionSize) = 0;
156
157   /**
158    * @brief Move and resize the window
159    */
160   virtual void MoveResize(Dali::PositionSize positionSize) = 0;
161
162   /**
163    * @copydoc Dali::Window::SetClass()
164    */
165   virtual void SetClass(const std::string& name, const std::string& className) = 0;
166
167   /**
168    * @copydoc Dali::Window::Raise()
169    */
170   virtual void Raise() = 0;
171
172   /**
173    * @copydoc Dali::Window::Lower()
174    */
175   virtual void Lower() = 0;
176
177   /**
178    * @copydoc Dali::Window::Activate()
179    */
180   virtual void Activate() = 0;
181
182   /**
183    * @copydoc Dali::Window::SetAvailableOrientations()
184    */
185   virtual void SetAvailableAnlges(const std::vector<int>& angles) = 0;
186
187   /**
188    * @copydoc Dali::Window::SetPreferredOrientation()
189    */
190   virtual void SetPreferredAngle(int angle) = 0;
191
192   /**
193    * @copydoc Dali::Window::SetAcceptFocus()
194    */
195   virtual void SetAcceptFocus(bool accept) = 0;
196
197   /**
198    * @copydoc Dali::Window::Show()
199    */
200   virtual void Show() = 0;
201
202   /**
203    * @copydoc Dali::Window::Hide()
204    */
205   virtual void Hide() = 0;
206
207   /**
208    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
209    */
210   virtual unsigned int GetSupportedAuxiliaryHintCount() const = 0;
211
212   /**
213    * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
214    */
215   virtual std::string GetSupportedAuxiliaryHint(unsigned int index) const = 0;
216
217   /**
218    * @copydoc Dali::Window::AddAuxiliaryHint()
219    */
220   virtual unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) = 0;
221
222   /**
223    * @copydoc Dali::Window::RemoveAuxiliaryHint()
224    */
225   virtual bool RemoveAuxiliaryHint(unsigned int id) = 0;
226
227   /**
228    * @copydoc Dali::Window::SetAuxiliaryHintValue()
229    */
230   virtual bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) = 0;
231
232   /**
233    * @copydoc Dali::Window::GetAuxiliaryHintValue()
234    */
235   virtual std::string GetAuxiliaryHintValue(unsigned int id) const = 0;
236
237   /**
238    * @copydoc Dali::Window::GetAuxiliaryHintId()
239    */
240   virtual unsigned int GetAuxiliaryHintId(const std::string& hint) const = 0;
241
242   /**
243    * @copydoc Dali::Window::SetInputRegion()
244    */
245   virtual void SetInputRegion(const Rect<int>& inputRegion) = 0;
246
247   /**
248    * @copydoc Dali::Window::SetType()
249    */
250   virtual void SetType(Dali::WindowType type) = 0;
251
252   /**
253    * @copydoc Dali::Window::GetType()
254    */
255   virtual Dali::WindowType GetType() const = 0;
256
257   /**
258    * @copydoc Dali::Window::SetNotificationLevel()
259    */
260   virtual Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) = 0;
261
262   /**
263    * @copydoc Dali::Window::GetNotificationLevel()
264    */
265   virtual Dali::WindowNotificationLevel GetNotificationLevel() const = 0;
266
267   /**
268    * @copydoc Dali::Window::SetOpaqueState()
269    */
270   virtual void SetOpaqueState(bool opaque) = 0;
271
272   /**
273    * @copydoc Dali::Window::SetScreenOffMode()
274    */
275   virtual Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) = 0;
276
277   /**
278    * @copydoc Dali::Window::GetScreenOffMode()
279    */
280   virtual WindowScreenOffMode GetScreenOffMode() const = 0;
281
282   /**
283    * @copydoc Dali::Window::SetBrightness()
284    */
285   virtual Dali::WindowOperationResult SetBrightness(int brightness) = 0;
286
287   /**
288    * @copydoc Dali::Window::GetBrightness()
289    */
290   virtual int GetBrightness() const = 0;
291
292   /**
293    * @copydoc Dali::KeyGrab::GrabKey()
294    */
295   virtual bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) = 0;
296
297   /**
298    * @copydoc Dali::KeyGrab::UngrabKey()
299    */
300   virtual bool UngrabKey(Dali::KEY key) = 0;
301
302   /**
303    * @copydoc Dali::KeyGrab::GrabKeyList()
304    */
305   virtual bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) = 0;
306
307   /**
308    * @copydoc Dali::KeyGrab::UngrabKeyList()
309    */
310   virtual bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) = 0;
311
312   /**
313    * @brief Get DPI
314    * @param[out] dpiHorizontal set to the horizontal dpi
315    * @param[out] dpiVertical set to the vertical dpi
316    */
317   virtual void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) = 0;
318
319   /**
320    * @brief Return the orientation of the surface.
321    * @return The orientation
322    */
323   virtual int GetOrientation() const = 0;
324
325   /**
326    * @brief Get the screen rotation angle of the window
327    */
328   virtual int GetScreenRotationAngle() = 0;
329
330   /**
331    * @brief Set the rotation angle of the window
332    */
333   virtual void SetWindowRotationAngle(int degree) = 0;
334
335   /**
336    * @brief Inform the window rotation is completed
337    */
338   virtual void WindowRotationCompleted(int degree, int width, int height) = 0;
339
340   /**
341    * @brief starts the window is moved by display server
342    */
343   virtual void RequestMoveToServer() = 0;
344
345   /**
346    * @brief starts the window is resized by display server
347    *
348    * @param[in] direction It is direction of the started edge/side.
349    */
350   virtual void RequestResizeToServer(WindowResizeDirection direction) = 0;
351
352   /**
353    * @brief Enables the floating mode of window.
354    *
355    * The floating mode is to support making partial size window easliy.
356    * It is useful to make popup style window
357    * and this window is always upper than the other normal window.
358    *
359    * A special display server(as a Tizen display server) supports this mode.
360    *
361    * @param[in] enable Enable floating mode or not.
362    */
363   virtual void EnableFloatingMode(bool enable) = 0;
364
365   /**
366    * @brief Gets whether floating mode is enabled or not.
367    */
368   virtual bool IsFloatingModeEnabled() const = 0;
369
370   /**
371    * @copydoc Dali::Window::SetTransparency()
372    */
373   virtual void SetTransparency(bool transparent) = 0;
374
375   /**
376    * @copydoc Dali::Window::SetParent()
377    */
378   virtual void SetParent(WindowBase* parentWinBase) = 0;
379
380   /**
381    * @brief Create a sync fence that can tell the frame is rendered by the graphics driver.
382    * @return The file descriptor that tells when it is rendered.
383    */
384   virtual int CreateFrameRenderedSyncFence() = 0;
385
386   /**
387    * @brief Create a sync fence that can tell the frame is presented by the display server.
388    * @return The file descriptor that tells when it is presented.
389    */
390   virtual int CreateFramePresentedSyncFence() = 0;
391
392   /**
393    * @copydoc Dali::Window::SetPositionSizeWithAngle()
394    */
395   virtual void SetPositionSizeWithAngle(PositionSize positionSize, int angle) = 0;
396
397   /**
398    * @brief Initialize for Ime window.
399    * It should be called when the window is only used for Ime keyboard window.
400    */
401   virtual void InitializeIme() = 0;
402
403   /**
404    * @brief Send the signal to display server for Ime Window is ready to render.
405    * It is used for compositing by display server.
406    */
407   virtual void ImeWindowReadyToRender() = 0;
408
409   // Signals
410
411   /**
412    * @brief This signal is emitted when the window becomes iconified or deiconified.
413    */
414   IconifySignalType& IconifyChangedSignal();
415
416   /**
417    * @brief This signal is emitted when the window focus is changed.
418    */
419   FocusSignalType& FocusChangedSignal();
420
421   /**
422    * @brief This signal is emitted when the output is transformed.
423    */
424   OutputSignalType& OutputTransformedSignal();
425
426   /**
427    * @brief This signal is emitted when the window receives a delete request.
428    */
429   DeleteSignalType& DeleteRequestSignal();
430
431   /**
432    * @brief This signal is emitted when the window is damaged.
433    */
434   DamageSignalType& WindowDamagedSignal();
435
436   /**
437    * @brief This signal is emitted when a rotation event is recevied.
438    */
439   RotationSignalType& RotationSignal();
440
441   /**
442    * @brief This signal is emitted when a touch event is received.
443    */
444   TouchEventSignalType& TouchEventSignal();
445
446   /**
447    * @brief This signal is emitted when a mouse wheel is received.
448    */
449   WheelEventSignalType& WheelEventSignal();
450
451   /**
452    * @brief This signal is emitted when a key event is received.
453    */
454   KeyEventSignalType& KeyEventSignal();
455
456   /**
457    * @brief This signal is emitted when the source window notifies us the content in clipboard is selected.
458    */
459   SelectionSignalType& SelectionDataSendSignal();
460
461   /**
462    * @brief This signal is emitted when the source window sends us about the selected content.
463    */
464   SelectionSignalType& SelectionDataReceivedSignal();
465
466   /**
467    * @brief This signal is emitted when the style is changed.
468    */
469   StyleSignalType& StyleChangedSignal();
470
471   /**
472    * @brief This signal is emitted when an accessibility event is received.
473    */
474   AccessibilitySignalType& AccessibilitySignal();
475
476   /**
477    * @brief This signal is emitted when window's transition animation is started or ended.
478    */
479   TransitionEffectEventSignalType& TransitionEffectEventSignal();
480
481   /**
482    * @brief This signal is emitted when the keyboard repeat is changed.
483    */
484   KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal();
485
486   /**
487    * @brief This signal is emitted when the window redraw is requested.
488    */
489   WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
490
491   /**
492    * @brief This signal is emitted when the window is resized or moved by display server.
493    */
494   UpdatePositionSizeType& UpdatePositionSizeSignal();
495
496 protected:
497   // Undefined
498   WindowBase(const WindowBase&) = delete;
499
500   // Undefined
501   WindowBase& operator=(const WindowBase& rhs) = delete;
502
503 protected:
504   IconifySignalType                       mIconifyChangedSignal;
505   FocusSignalType                         mFocusChangedSignal;
506   OutputSignalType                        mOutputTransformedSignal;
507   DeleteSignalType                        mDeleteRequestSignal;
508   DamageSignalType                        mWindowDamagedSignal;
509   RotationSignalType                      mRotationSignal;
510   TouchEventSignalType                    mTouchEventSignal;
511   WheelEventSignalType                    mWheelEventSignal;
512   KeyEventSignalType                      mKeyEventSignal;
513   SelectionSignalType                     mSelectionDataSendSignal;
514   SelectionSignalType                     mSelectionDataReceivedSignal;
515   StyleSignalType                         mStyleChangedSignal;
516   AccessibilitySignalType                 mAccessibilitySignal;
517   TransitionEffectEventSignalType         mTransitionEffectEventSignal;
518   KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
519   WindowRedrawRequestSignalType           mWindowRedrawRequestSignal;
520   UpdatePositionSizeType                  mUpdatePositionSizeSignal;
521 };
522
523 } // namespace Adaptor
524
525 } // namespace Internal
526
527 } // namespace Dali
528
529 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H