d0115edc069f94a4cf9738b955035b60c444599f
[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) 2022 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   typedef Signal<void(const std::string&, const std::string&, const Property::Array&)>             AuxiliaryMessageSignalType;
77
78   // Input events
79   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
80   typedef Signal<void(Integration::WheelEvent&)>      WheelEventSignalType;
81   typedef Signal<void(Integration::KeyEvent&)>        KeyEventSignalType;
82
83   // Clipboard
84   typedef Signal<void(void*)> SelectionSignalType;
85
86   // Accessibility
87   typedef Signal<void(StyleChange::Type)>        StyleSignalType;
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 Get the native window resource id assinged by window manager
114    * @return The native window resource id
115    */
116   virtual std::string GetNativeWindowResourceId() = 0;
117
118   /**
119    * @brief Create the egl window
120    */
121   virtual EGLNativeWindowType CreateEglWindow(int width, int height) = 0;
122
123   /**
124    * @brief Destroy the egl window
125    */
126   virtual void DestroyEglWindow() = 0;
127
128   /**
129    * @brief Set the egl window rotation
130    */
131   virtual void SetEglWindowRotation(int angle) = 0;
132
133   /**
134    * @brief Set the egl window buffer transform
135    */
136   virtual void SetEglWindowBufferTransform(int angle) = 0;
137
138   /**
139    * @brief Set the egl window transform
140    */
141   virtual void SetEglWindowTransform(int angle) = 0;
142
143   /**
144    * @brief Resize the egl window
145    */
146   virtual void ResizeEglWindow(Dali::PositionSize positionSize) = 0;
147
148   /**
149    * @brief Returns whether the egl window support rotation or not
150    */
151   virtual bool IsEglWindowRotationSupported() = 0;
152
153   /**
154    * @brief Move the window
155    */
156   virtual void Move(Dali::PositionSize positionSize) = 0;
157
158   /**
159    * @brief Resize the window
160    */
161   virtual void Resize(Dali::PositionSize positionSize) = 0;
162
163   /**
164    * @brief Move and resize the window
165    */
166   virtual void MoveResize(Dali::PositionSize positionSize) = 0;
167
168   /**
169    * @copydoc Dali::Window::SetClass()
170    */
171   virtual void SetClass(const std::string& name, const std::string& className) = 0;
172
173   /**
174    * @copydoc Dali::Window::Raise()
175    */
176   virtual void Raise() = 0;
177
178   /**
179    * @copydoc Dali::Window::Lower()
180    */
181   virtual void Lower() = 0;
182
183   /**
184    * @copydoc Dali::Window::Activate()
185    */
186   virtual void Activate() = 0;
187
188   /**
189    * @copydoc Dali::DevelWindow::Maximize()
190    */
191   virtual void Maximize(bool maximize) = 0;
192
193   /**
194    * @copydoc Dali::DevelWindow::IsMaximized()
195    */
196   virtual bool IsMaximized() const = 0;
197
198   /**
199    * @copydoc Dali::DevelWindow::SetMaximumSize()
200    */
201   virtual void SetMaximumSize(Dali::Window::WindowSize size) = 0;
202
203   /**
204    * @copydoc Dali::DevelWindow::Minimize()
205    */
206   virtual void Minimize(bool minimize) = 0;
207
208   /**
209    * @copydoc Dali::DevelWindow::IsMinimized()
210    */
211   virtual bool IsMinimized() const = 0;
212
213   /**
214    * @copydoc Dali::DevelWindow::SetMimimumSize()
215    */
216   virtual void SetMimimumSize(Dali::Window::WindowSize size) = 0;
217
218   /**
219    * @copydoc Dali::Window::SetAvailableOrientations()
220    */
221   virtual void SetAvailableAnlges(const std::vector<int>& angles) = 0;
222
223   /**
224    * @copydoc Dali::Window::SetPreferredOrientation()
225    */
226   virtual void SetPreferredAngle(int angle) = 0;
227
228   /**
229    * @copydoc Dali::Window::SetAcceptFocus()
230    */
231   virtual void SetAcceptFocus(bool accept) = 0;
232
233   /**
234    * @copydoc Dali::Window::Show()
235    */
236   virtual void Show() = 0;
237
238   /**
239    * @copydoc Dali::Window::Hide()
240    */
241   virtual void Hide() = 0;
242
243   /**
244    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
245    */
246   virtual unsigned int GetSupportedAuxiliaryHintCount() const = 0;
247
248   /**
249    * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
250    */
251   virtual std::string GetSupportedAuxiliaryHint(unsigned int index) const = 0;
252
253   /**
254    * @copydoc Dali::Window::AddAuxiliaryHint()
255    */
256   virtual unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) = 0;
257
258   /**
259    * @copydoc Dali::Window::RemoveAuxiliaryHint()
260    */
261   virtual bool RemoveAuxiliaryHint(unsigned int id) = 0;
262
263   /**
264    * @copydoc Dali::Window::SetAuxiliaryHintValue()
265    */
266   virtual bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) = 0;
267
268   /**
269    * @copydoc Dali::Window::GetAuxiliaryHintValue()
270    */
271   virtual std::string GetAuxiliaryHintValue(unsigned int id) const = 0;
272
273   /**
274    * @copydoc Dali::Window::GetAuxiliaryHintId()
275    */
276   virtual unsigned int GetAuxiliaryHintId(const std::string& hint) const = 0;
277
278   /**
279    * @copydoc Dali::Window::SetInputRegion()
280    */
281   virtual void SetInputRegion(const Rect<int>& inputRegion) = 0;
282
283   /**
284    * @copydoc Dali::Window::SetType()
285    */
286   virtual void SetType(Dali::WindowType type) = 0;
287
288   /**
289    * @copydoc Dali::Window::GetType()
290    */
291   virtual Dali::WindowType GetType() const = 0;
292
293   /**
294    * @copydoc Dali::Window::SetNotificationLevel()
295    */
296   virtual Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) = 0;
297
298   /**
299    * @copydoc Dali::Window::GetNotificationLevel()
300    */
301   virtual Dali::WindowNotificationLevel GetNotificationLevel() const = 0;
302
303   /**
304    * @copydoc Dali::Window::SetOpaqueState()
305    */
306   virtual void SetOpaqueState(bool opaque) = 0;
307
308   /**
309    * @copydoc Dali::Window::SetScreenOffMode()
310    */
311   virtual Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) = 0;
312
313   /**
314    * @copydoc Dali::Window::GetScreenOffMode()
315    */
316   virtual WindowScreenOffMode GetScreenOffMode() const = 0;
317
318   /**
319    * @copydoc Dali::Window::SetBrightness()
320    */
321   virtual Dali::WindowOperationResult SetBrightness(int brightness) = 0;
322
323   /**
324    * @copydoc Dali::Window::GetBrightness()
325    */
326   virtual int GetBrightness() const = 0;
327
328   /**
329    * @copydoc Dali::KeyGrab::GrabKey()
330    */
331   virtual bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) = 0;
332
333   /**
334    * @copydoc Dali::KeyGrab::UngrabKey()
335    */
336   virtual bool UngrabKey(Dali::KEY key) = 0;
337
338   /**
339    * @copydoc Dali::KeyGrab::GrabKeyList()
340    */
341   virtual bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) = 0;
342
343   /**
344    * @copydoc Dali::KeyGrab::UngrabKeyList()
345    */
346   virtual bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) = 0;
347
348   /**
349    * @brief Get DPI
350    * @param[out] dpiHorizontal set to the horizontal dpi
351    * @param[out] dpiVertical set to the vertical dpi
352    */
353   virtual void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) = 0;
354
355   /**
356    * @brief Return the angle of the window's rotation.
357    * @return The window orientation
358    */
359   virtual int GetWindowRotationAngle() const = 0;
360
361   /**
362    * @brief Get the angle of screen rotation for the window
363    * @return The screen orientation
364    */
365   virtual int GetScreenRotationAngle() = 0;
366
367   /**
368    * @brief Set the screen rotation angle of the window
369    */
370   virtual void SetWindowRotationAngle(int degree) = 0;
371
372   /**
373    * @brief Inform the window rotation is completed
374    */
375   virtual void WindowRotationCompleted(int degree, int width, int height) = 0;
376
377   /**
378    * @brief starts the window is moved by display server
379    */
380   virtual void RequestMoveToServer() = 0;
381
382   /**
383    * @brief starts the window is resized by display server
384    *
385    * @param[in] direction It is direction of the started edge/side.
386    */
387   virtual void RequestResizeToServer(WindowResizeDirection direction) = 0;
388
389   /**
390    * @brief Enables the floating mode of window.
391    *
392    * The floating mode is to support making partial size window easliy.
393    * It is useful to make popup style window
394    * and this window is always upper than the other normal window.
395    *
396    * A special display server(as a Tizen display server) supports this mode.
397    *
398    * @param[in] enable Enable floating mode or not.
399    */
400   virtual void EnableFloatingMode(bool enable) = 0;
401
402   /**
403    * @brief Gets whether floating mode is enabled or not.
404    */
405   virtual bool IsFloatingModeEnabled() const = 0;
406
407   /**
408    * @copydoc Dali::Window::SetTransparency()
409    */
410   virtual void SetTransparency(bool transparent) = 0;
411
412   /**
413    * @copydoc Dali::Window::SetParent()
414    */
415   virtual void SetParent(WindowBase* parentWinBase, bool belowParent) = 0;
416
417   /**
418    * @brief Create a sync fence that can tell the frame is rendered by the graphics driver.
419    * @return The file descriptor that tells when it is rendered.
420    */
421   virtual int CreateFrameRenderedSyncFence() = 0;
422
423   /**
424    * @brief Create a sync fence that can tell the frame is presented by the display server.
425    * @return The file descriptor that tells when it is presented.
426    */
427   virtual int CreateFramePresentedSyncFence() = 0;
428
429   /**
430    * @copydoc Dali::Window::SetPositionSizeWithAngle()
431    */
432   virtual void SetPositionSizeWithAngle(PositionSize positionSize, int angle) = 0;
433
434   /**
435    * @brief Initialize for Ime window.
436    * It should be called when the window is only used for Ime keyboard window.
437    */
438   virtual void InitializeIme() = 0;
439
440   /**
441    * @brief Send the signal to display server for Ime Window is ready to render.
442    * It is used for compositing by display server.
443    */
444   virtual void ImeWindowReadyToRender() = 0;
445
446   /**
447    * @brief Includes input region.
448    * @param[in] inputRegion The added region to accept input events.
449    */
450   virtual void IncludeInputRegion(const Rect<int>& inputRegion) = 0;
451
452   /**
453    * @brief Excludes input region.
454    * @param[in] inputRegion The subtracted region to except input events.
455    */
456   virtual void ExcludeInputRegion(const Rect<int>& inputRegion) = 0;
457
458   // Signals
459
460   /**
461    * @brief This signal is emitted when the window becomes iconified or deiconified.
462    */
463   IconifySignalType& IconifyChangedSignal();
464
465   /**
466    * @brief This signal is emitted when the window focus is changed.
467    */
468   FocusSignalType& FocusChangedSignal();
469
470   /**
471    * @brief This signal is emitted when the output is transformed.
472    */
473   OutputSignalType& OutputTransformedSignal();
474
475   /**
476    * @brief This signal is emitted when the window receives a delete request.
477    */
478   DeleteSignalType& DeleteRequestSignal();
479
480   /**
481    * @brief This signal is emitted when the window is damaged.
482    */
483   DamageSignalType& WindowDamagedSignal();
484
485   /**
486    * @brief This signal is emitted when a rotation event is recevied.
487    */
488   RotationSignalType& RotationSignal();
489
490   /**
491    * @brief This signal is emitted when a touch event is received.
492    */
493   TouchEventSignalType& TouchEventSignal();
494
495   /**
496    * @brief This signal is emitted when a mouse wheel is received.
497    */
498   WheelEventSignalType& WheelEventSignal();
499
500   /**
501    * @brief This signal is emitted when a key event is received.
502    */
503   KeyEventSignalType& KeyEventSignal();
504
505   /**
506    * @brief This signal is emitted when the source window notifies us the content in clipboard is selected.
507    */
508   SelectionSignalType& SelectionDataSendSignal();
509
510   /**
511    * @brief This signal is emitted when the source window sends us about the selected content.
512    */
513   SelectionSignalType& SelectionDataReceivedSignal();
514
515   /**
516    * @brief This signal is emitted when the style is changed.
517    */
518   StyleSignalType& StyleChangedSignal();
519
520   /**
521    * @brief This signal is emitted when window's transition animation is started or ended.
522    */
523   TransitionEffectEventSignalType& TransitionEffectEventSignal();
524
525   /**
526    * @brief This signal is emitted when the keyboard repeat is changed.
527    */
528   KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal();
529
530   /**
531    * @brief This signal is emitted when the window redraw is requested.
532    */
533   WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
534
535   /**
536    * @brief This signal is emitted when the window is resized or moved by display server.
537    */
538   UpdatePositionSizeType& UpdatePositionSizeSignal();
539
540   /**
541    * @brief This signal is emitted when the window is received the auxiliary message from display server.
542    */
543   AuxiliaryMessageSignalType& AuxiliaryMessageSignal();
544
545 protected:
546   // Undefined
547   WindowBase(const WindowBase&) = delete;
548
549   // Undefined
550   WindowBase& operator=(const WindowBase& rhs) = delete;
551
552 protected:
553   IconifySignalType                       mIconifyChangedSignal;
554   FocusSignalType                         mFocusChangedSignal;
555   OutputSignalType                        mOutputTransformedSignal;
556   DeleteSignalType                        mDeleteRequestSignal;
557   DamageSignalType                        mWindowDamagedSignal;
558   RotationSignalType                      mRotationSignal;
559   TouchEventSignalType                    mTouchEventSignal;
560   WheelEventSignalType                    mWheelEventSignal;
561   KeyEventSignalType                      mKeyEventSignal;
562   SelectionSignalType                     mSelectionDataSendSignal;
563   SelectionSignalType                     mSelectionDataReceivedSignal;
564   StyleSignalType                         mStyleChangedSignal;
565   TransitionEffectEventSignalType         mTransitionEffectEventSignal;
566   KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
567   WindowRedrawRequestSignalType           mWindowRedrawRequestSignal;
568   UpdatePositionSizeType                  mUpdatePositionSizeSignal;
569   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
570 };
571
572 } // namespace Adaptor
573
574 } // namespace Internal
575
576 } // namespace Dali
577
578 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H