DALi Version 2.2.41
[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) 2023 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/mouse-in-out-event.h>
31 #include <dali/devel-api/adaptor-framework/window-devel.h>
32 #include <dali/internal/graphics/gles/egl-implementation.h>
33 #include <dali/internal/window-system/common/damage-observer.h>
34 #include <dali/internal/window-system/common/rotation-event.h>
35 #include <dali/public-api/adaptor-framework/key-grab.h>
36 #include <dali/public-api/adaptor-framework/style-change.h>
37 #include <dali/public-api/adaptor-framework/window-enumerations.h>
38 #include <dali/public-api/adaptor-framework/window.h>
39
40 namespace Dali
41 {
42 namespace Internal
43 {
44 namespace Adaptor
45 {
46 /**
47  * WindowBase interface
48  */
49 class WindowBase
50 {
51 public:
52   /**
53    * @brief Struct used to retrieve accessibility information
54    */
55   struct AccessibilityInfo
56   {
57     int gestureValue;
58     int startX;
59     int startY;
60     int endX;
61     int endY;
62     int state;
63     int eventTime;
64   };
65
66   // Window
67   typedef Signal<void(bool)>                                                           IconifySignalType;
68   typedef Signal<void(bool)>                                                           MaximizeSignalType;
69   typedef Signal<void(bool)>                                                           FocusSignalType;
70   typedef Signal<void()>                                                               OutputSignalType;
71   typedef Signal<void()>                                                               DeleteSignalType;
72   typedef Signal<void(const DamageArea&)>                                              DamageSignalType;
73   typedef Signal<void(const RotationEvent&)>                                           RotationSignalType;
74   typedef Signal<void(WindowEffectState, WindowEffectType)>                            TransitionEffectEventSignalType;
75   typedef Signal<void()>                                                               KeyboardRepeatSettingsChangedSignalType;
76   typedef Signal<void()>                                                               WindowRedrawRequestSignalType;
77   typedef Signal<void(Dali::PositionSize&)>                                            UpdatePositionSizeType;
78   typedef Signal<void(const std::string&, const std::string&, const Property::Array&)> AuxiliaryMessageSignalType;
79   typedef Signal<void(const Dali::DevelWindow::MouseInOutEvent&)>                      MouseInOutEventSignalType;
80   typedef Signal<void(const Dali::DevelWindow::MouseRelativeEvent&)>                   MouseRelativeEventSignalType;
81   typedef Signal<void(Dali::Int32Pair&)>                                               MoveCompletedSignalType;
82   typedef Signal<void(Dali::Uint16Pair&)>                                              ResizeCompletedSignalType;
83   typedef Signal<void(WindowInsetsPartType, WindowInsetsPartState, const Extents&)>    InsetsChangedSignalType;
84
85   // Input events
86   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
87   typedef Signal<void(Integration::WheelEvent&)>      WheelEventSignalType;
88   typedef Signal<void(Integration::KeyEvent&)>        KeyEventSignalType;
89
90   // Clipboard
91   typedef Signal<void(void*)> SelectionSignalType;
92
93   // Accessibility
94   typedef Signal<void(StyleChange::Type)> StyleSignalType;
95
96   /**
97    * @brief Default constructor
98    */
99   WindowBase();
100
101   /**
102    * @brief Destructor
103    */
104   virtual ~WindowBase();
105
106 public:
107   /**
108    * @brief Get the native window handle
109    * @return The native window handle
110    */
111   virtual Any GetNativeWindow() = 0;
112
113   /**
114    * @brief Get the native window id
115    * @return The native window id
116    */
117   virtual int GetNativeWindowId() = 0;
118
119   /**
120    * @brief Get the native window resource id assinged by window manager
121    * @return The native window resource id
122    */
123   virtual std::string GetNativeWindowResourceId() = 0;
124
125   /**
126    * @brief Create the egl window
127    */
128   virtual EGLNativeWindowType CreateEglWindow(int width, int height) = 0;
129
130   /**
131    * @brief Destroy the egl window
132    */
133   virtual void DestroyEglWindow() = 0;
134
135   /**
136    * @brief Set the egl window rotation
137    */
138   virtual void SetEglWindowRotation(int angle) = 0;
139
140   /**
141    * @brief Set the egl window buffer transform
142    */
143   virtual void SetEglWindowBufferTransform(int angle) = 0;
144
145   /**
146    * @brief Set the egl window transform
147    */
148   virtual void SetEglWindowTransform(int angle) = 0;
149
150   /**
151    * @brief Resize the egl window
152    */
153   virtual void ResizeEglWindow(Dali::PositionSize positionSize) = 0;
154
155   /**
156    * @brief Returns whether the egl window support rotation or not
157    */
158   virtual bool IsEglWindowRotationSupported() = 0;
159
160   /**
161    * @brief Move the window
162    */
163   virtual void Move(Dali::PositionSize positionSize) = 0;
164
165   /**
166    * @brief Resize the window
167    */
168   virtual void Resize(Dali::PositionSize positionSize) = 0;
169
170   /**
171    * @brief Move and resize the window
172    */
173   virtual void MoveResize(Dali::PositionSize positionSize) = 0;
174
175   /**
176    * @copydoc Dali::Window::SetLayout()
177    */
178   virtual void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) = 0;
179
180   /**
181    * @copydoc Dali::Window::SetClass()
182    */
183   virtual void SetClass(const std::string& name, const std::string& className) = 0;
184
185   /**
186    * @copydoc Dali::Window::Raise()
187    */
188   virtual void Raise() = 0;
189
190   /**
191    * @copydoc Dali::Window::Lower()
192    */
193   virtual void Lower() = 0;
194
195   /**
196    * @copydoc Dali::Window::Activate()
197    */
198   virtual void Activate() = 0;
199
200   /**
201    * @copydoc Dali::DevelWindow::Maximize()
202    */
203   virtual void Maximize(bool maximize) = 0;
204
205   /**
206    * @copydoc Dali::DevelWindow::IsMaximized()
207    */
208   virtual bool IsMaximized() const = 0;
209
210   /**
211    * @copydoc Dali::DevelWindow::SetMaximumSize()
212    */
213   virtual void SetMaximumSize(Dali::Window::WindowSize size) = 0;
214
215   /**
216    * @copydoc Dali::DevelWindow::Minimize()
217    */
218   virtual void Minimize(bool minimize) = 0;
219
220   /**
221    * @copydoc Dali::DevelWindow::IsMinimized()
222    */
223   virtual bool IsMinimized() const = 0;
224
225   /**
226    * @copydoc Dali::DevelWindow::SetMimimumSize()
227    */
228   virtual void SetMimimumSize(Dali::Window::WindowSize size) = 0;
229
230   /**
231    * @copydoc Dali::Window::SetAvailableOrientations()
232    */
233   virtual void SetAvailableAnlges(const std::vector<int>& angles) = 0;
234
235   /**
236    * @copydoc Dali::Window::SetPreferredOrientation()
237    */
238   virtual void SetPreferredAngle(int angle) = 0;
239
240   /**
241    * @copydoc Dali::Window::SetAcceptFocus()
242    */
243   virtual void SetAcceptFocus(bool accept) = 0;
244
245   /**
246    * @copydoc Dali::Window::Show()
247    */
248   virtual void Show() = 0;
249
250   /**
251    * @copydoc Dali::Window::Hide()
252    */
253   virtual void Hide() = 0;
254
255   /**
256    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
257    */
258   virtual unsigned int GetSupportedAuxiliaryHintCount() const = 0;
259
260   /**
261    * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
262    */
263   virtual std::string GetSupportedAuxiliaryHint(unsigned int index) const = 0;
264
265   /**
266    * @copydoc Dali::Window::AddAuxiliaryHint()
267    */
268   virtual unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) = 0;
269
270   /**
271    * @copydoc Dali::Window::RemoveAuxiliaryHint()
272    */
273   virtual bool RemoveAuxiliaryHint(unsigned int id) = 0;
274
275   /**
276    * @copydoc Dali::Window::SetAuxiliaryHintValue()
277    */
278   virtual bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) = 0;
279
280   /**
281    * @copydoc Dali::Window::GetAuxiliaryHintValue()
282    */
283   virtual std::string GetAuxiliaryHintValue(unsigned int id) const = 0;
284
285   /**
286    * @copydoc Dali::Window::GetAuxiliaryHintId()
287    */
288   virtual unsigned int GetAuxiliaryHintId(const std::string& hint) const = 0;
289
290   /**
291    * @copydoc Dali::Window::SetInputRegion()
292    */
293   virtual void SetInputRegion(const Rect<int>& inputRegion) = 0;
294
295   /**
296    * @copydoc Dali::Window::SetType()
297    */
298   virtual void SetType(Dali::WindowType type) = 0;
299
300   /**
301    * @copydoc Dali::Window::GetType()
302    */
303   virtual Dali::WindowType GetType() const = 0;
304
305   /**
306    * @copydoc Dali::Window::SetNotificationLevel()
307    */
308   virtual Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) = 0;
309
310   /**
311    * @copydoc Dali::Window::GetNotificationLevel()
312    */
313   virtual Dali::WindowNotificationLevel GetNotificationLevel() const = 0;
314
315   /**
316    * @copydoc Dali::Window::SetOpaqueState()
317    */
318   virtual void SetOpaqueState(bool opaque) = 0;
319
320   /**
321    * @copydoc Dali::Window::SetScreenOffMode()
322    */
323   virtual Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) = 0;
324
325   /**
326    * @copydoc Dali::Window::GetScreenOffMode()
327    */
328   virtual WindowScreenOffMode GetScreenOffMode() const = 0;
329
330   /**
331    * @copydoc Dali::Window::SetBrightness()
332    */
333   virtual Dali::WindowOperationResult SetBrightness(int brightness) = 0;
334
335   /**
336    * @copydoc Dali::Window::GetBrightness()
337    */
338   virtual int GetBrightness() const = 0;
339
340   /**
341    * @copydoc Dali::KeyGrab::GrabKey()
342    */
343   virtual bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) = 0;
344
345   /**
346    * @copydoc Dali::KeyGrab::UngrabKey()
347    */
348   virtual bool UngrabKey(Dali::KEY key) = 0;
349
350   /**
351    * @copydoc Dali::KeyGrab::GrabKeyList()
352    */
353   virtual bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) = 0;
354
355   /**
356    * @copydoc Dali::KeyGrab::UngrabKeyList()
357    */
358   virtual bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) = 0;
359
360   /**
361    * @brief Get DPI
362    * @param[out] dpiHorizontal set to the horizontal dpi
363    * @param[out] dpiVertical set to the vertical dpi
364    */
365   virtual void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) = 0;
366
367   /**
368    * @brief Return the angle of the window's rotation.
369    * @return The window orientation
370    */
371   virtual int GetWindowRotationAngle() const = 0;
372
373   /**
374    * @brief Get the angle of screen rotation for the window
375    * @return The screen orientation
376    */
377   virtual int GetScreenRotationAngle() = 0;
378
379   /**
380    * @brief Set the screen rotation angle of the window
381    */
382   virtual void SetWindowRotationAngle(int degree) = 0;
383
384   /**
385    * @brief Inform the window rotation is completed
386    */
387   virtual void WindowRotationCompleted(int degree, int width, int height) = 0;
388
389   /**
390    * @brief starts the window is moved by display server
391    */
392   virtual void RequestMoveToServer() = 0;
393
394   /**
395    * @brief starts the window is resized by display server
396    *
397    * @param[in] direction It is direction of the started edge/side.
398    */
399   virtual void RequestResizeToServer(WindowResizeDirection direction) = 0;
400
401   /**
402    * @brief Enables the floating mode of window.
403    *
404    * The floating mode is to support making partial size window easliy.
405    * It is useful to make popup style window
406    * and this window is always upper than the other normal window.
407    *
408    * A special display server(as a Tizen display server) supports this mode.
409    *
410    * @param[in] enable Enable floating mode or not.
411    */
412   virtual void EnableFloatingMode(bool enable) = 0;
413
414   /**
415    * @brief Gets whether floating mode is enabled or not.
416    */
417   virtual bool IsFloatingModeEnabled() const = 0;
418
419   /**
420    * @copydoc Dali::Window::SetTransparency()
421    */
422   virtual void SetTransparency(bool transparent) = 0;
423
424   /**
425    * @copydoc Dali::Window::SetParent()
426    */
427   virtual void SetParent(WindowBase* parentWinBase, bool belowParent) = 0;
428
429   /**
430    * @brief Create a sync fence that can tell the frame is rendered by the graphics driver.
431    * @return The file descriptor that tells when it is rendered.
432    */
433   virtual int CreateFrameRenderedSyncFence() = 0;
434
435   /**
436    * @brief Create a sync fence that can tell the frame is presented by the display server.
437    * @return The file descriptor that tells when it is presented.
438    */
439   virtual int CreateFramePresentedSyncFence() = 0;
440
441   /**
442    * @copydoc Dali::Window::SetPositionSizeWithAngle()
443    */
444   virtual void SetPositionSizeWithAngle(PositionSize positionSize, int angle) = 0;
445
446   /**
447    * @brief Initialize for Ime window.
448    * It should be called when the window is only used for Ime keyboard window.
449    */
450   virtual void InitializeIme() = 0;
451
452   /**
453    * @brief Send the signal to display server for Ime Window is ready to render.
454    * It is used for compositing by display server.
455    */
456   virtual void ImeWindowReadyToRender() = 0;
457
458   /**
459    * @brief Includes input region.
460    * @param[in] inputRegion The added region to accept input events.
461    */
462   virtual void IncludeInputRegion(const Rect<int>& inputRegion) = 0;
463
464   /**
465    * @brief Excludes input region.
466    * @param[in] inputRegion The subtracted region to except input events.
467    */
468   virtual void ExcludeInputRegion(const Rect<int>& inputRegion) = 0;
469
470   /**
471    * @brief Sets the pointer constraints lock.
472    * @return Returns true if PointerConstraintsLock succeeds.
473    */
474   virtual bool PointerConstraintsLock() = 0;
475
476   /**
477    * @brief Sets the pointer constraints unlock.
478    * @return Returns true if PointerConstraintsUnlock succeeds.
479    */
480   virtual bool PointerConstraintsUnlock() = 0;
481
482   /**
483    * @brief Sets the locked pointer region
484    *
485    * @param[in] x The x position.
486    * @param[in] y The y position.
487    * @param[in] width The width.
488    * @param[in] height The height
489    */
490   virtual void LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height) = 0;
491
492   /**
493    * @brief Sets the locked pointer cursor position hintset
494    *
495    * @param[in] x The x position.
496    * @param[in] y The y position.
497    */
498   virtual void LockedPointerCursorPositionHintSet(int32_t x, int32_t y) = 0;
499
500   /**
501    * @brief Sets the pointer warp. The pointer moves to the set coordinates.
502    *
503    * @param[in] x The x position.
504    * @param[in] y The y position.
505    * @return Returns true if PointerWarp succeeds.
506    */
507   virtual bool PointerWarp(int32_t x, int32_t y) = 0;
508
509   // Signals
510
511   /**
512    * @brief This signal is emitted when the window becomes iconified or deiconified.
513    */
514   IconifySignalType& IconifyChangedSignal();
515
516   /**
517    * @brief This signal is emitted when the window becomes maximized or unmaximized.
518    */
519   MaximizeSignalType& MaximizeChangedSignal();
520
521   /**
522    * @brief This signal is emitted when the window focus is changed.
523    */
524   FocusSignalType& FocusChangedSignal();
525
526   /**
527    * @brief This signal is emitted when the output is transformed.
528    */
529   OutputSignalType& OutputTransformedSignal();
530
531   /**
532    * @brief This signal is emitted when the window receives a delete request.
533    */
534   DeleteSignalType& DeleteRequestSignal();
535
536   /**
537    * @brief This signal is emitted when the window is damaged.
538    */
539   DamageSignalType& WindowDamagedSignal();
540
541   /**
542    * @brief This signal is emitted when a rotation event is recevied.
543    */
544   RotationSignalType& RotationSignal();
545
546   /**
547    * @brief This signal is emitted when a touch event is received.
548    */
549   TouchEventSignalType& TouchEventSignal();
550
551   /**
552    * @brief This signal is emitted when a mouse wheel is received.
553    */
554   WheelEventSignalType& WheelEventSignal();
555
556   /**
557    * @brief This signal is emitted when a key event is received.
558    */
559   KeyEventSignalType& KeyEventSignal();
560
561   /**
562    * @brief This signal is emitted when the source window notifies us the content in clipboard is selected.
563    */
564   SelectionSignalType& SelectionDataSendSignal();
565
566   /**
567    * @brief This signal is emitted when the source window sends us about the selected content.
568    */
569   SelectionSignalType& SelectionDataReceivedSignal();
570
571   /**
572    * @brief This signal is emitted when the style is changed.
573    */
574   StyleSignalType& StyleChangedSignal();
575
576   /**
577    * @brief This signal is emitted when window's transition animation is started or ended.
578    */
579   TransitionEffectEventSignalType& TransitionEffectEventSignal();
580
581   /**
582    * @brief This signal is emitted when the keyboard repeat is changed.
583    */
584   KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal();
585
586   /**
587    * @brief This signal is emitted when the window redraw is requested.
588    */
589   WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
590
591   /**
592    * @brief This signal is emitted when the window's geometry data is changed by display server or client.
593    * It is based on configure noification event.
594    */
595   UpdatePositionSizeType& UpdatePositionSizeSignal();
596
597   /**
598    * @brief This signal is emitted when the window is received the auxiliary message from display server.
599    */
600   AuxiliaryMessageSignalType& AuxiliaryMessageSignal();
601
602   /**
603    * @brief This signal is emitted when a mouse in or out event is recevied.
604    */
605   MouseInOutEventSignalType& MouseInOutEventSignal();
606
607   /**
608    * @brief This signal is emitted when a mouse relative event is recevied.
609    */
610   MouseRelativeEventSignalType& MouseRelativeEventSignal();
611
612   /**
613    * @brief This signal is emitted when window has been moved by then display server.
614    * To be moved the window by display server, RequestMoveToServer() should be called.
615    * After the moving job is finished, this function will be called.
616    */
617   MoveCompletedSignalType& MoveCompletedSignal();
618
619   /**
620    * @brief This signal is emitted when window has been resized by then display server.
621    * To be resized the window by display server, RequestResizeToServer() should be called.
622    * After the resizing job is finished, this function will be called.
623    */
624   ResizeCompletedSignalType& ResizeCompletedSignal();
625
626   /**
627    * @brief This signal is emitted when window insets are changed by appearing or disappearing indicator, virtual keyboard, or clipboard.
628    */
629   InsetsChangedSignalType& InsetsChangedSignal();
630
631 protected:
632   // Undefined
633   WindowBase(const WindowBase&) = delete;
634
635   // Undefined
636   WindowBase& operator=(const WindowBase& rhs) = delete;
637
638 protected:
639   IconifySignalType                       mIconifyChangedSignal;
640   MaximizeSignalType                      mMaximizeChangedSignal;
641   FocusSignalType                         mFocusChangedSignal;
642   OutputSignalType                        mOutputTransformedSignal;
643   DeleteSignalType                        mDeleteRequestSignal;
644   DamageSignalType                        mWindowDamagedSignal;
645   RotationSignalType                      mRotationSignal;
646   TouchEventSignalType                    mTouchEventSignal;
647   WheelEventSignalType                    mWheelEventSignal;
648   KeyEventSignalType                      mKeyEventSignal;
649   SelectionSignalType                     mSelectionDataSendSignal;
650   SelectionSignalType                     mSelectionDataReceivedSignal;
651   StyleSignalType                         mStyleChangedSignal;
652   TransitionEffectEventSignalType         mTransitionEffectEventSignal;
653   KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
654   WindowRedrawRequestSignalType           mWindowRedrawRequestSignal;
655   UpdatePositionSizeType                  mUpdatePositionSizeSignal;
656   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
657   MouseInOutEventSignalType               mMouseInOutEventSignal;
658   MouseRelativeEventSignalType            mMouseRelativeEventSignal;
659   MoveCompletedSignalType                 mMoveCompletedSignal;
660   ResizeCompletedSignalType               mResizeCompletedSignal;
661   InsetsChangedSignalType                 mInsetsChangedSignal;
662 };
663
664 } // namespace Adaptor
665
666 } // namespace Internal
667
668 } // namespace Dali
669
670 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H