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