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