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