Add SetGeometryHittestEnabled and IsGeometryHittestEnabled
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-system.h
1 #ifndef DALI_INTERNAL_WINDOW_SYSTEM_COMMON_WINDOW_SYSTEM_H
2 #define DALI_INTERNAL_WINDOW_SYSTEM_COMMON_WINDOW_SYSTEM_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_HEADERS
22 #include <dali/public-api/object/any.h>
23 #include <cstdint>
24
25 namespace Dali
26 {
27 namespace Internal
28 {
29 namespace Adaptor
30 {
31 namespace WindowSystem
32 {
33 /**
34  * @brief Initialize a window system
35  */
36 void Initialize();
37
38 /**
39  * @brief Shutdown a window system
40  */
41 void Shutdown();
42
43 /**
44  * @brief Set the DPI of the target screen.
45  *
46  * @note Multiple screens are not currently supported.
47  * @param[in] horizontalDpi The horizontal resolution in DPI.
48  * @param[in] verticalDpi The vertical resolution in DPI.
49  */
50 void SetDpi(uint32_t dpiHorizontal, uint32_t dpiVertical);
51
52 /**
53  * @brief Retrieves the DPI previously set to the target screen.
54  *
55  * @note Multiple screens are not currently supported.
56  * @param[out] horizontalDpi The horizontal resolution in DPI.
57  * @param[out] verticalDpi The vertical resolution in DPI.
58  */
59 void GetDpi(uint32_t& dpiHorizontal, uint32_t& dpiVertical);
60
61 /**
62  * @brief Get the screen size
63  */
64 void GetScreenSize(int32_t& width, int32_t& height);
65
66 /**
67  * @brief Update the screen size
68  * @note The screen size may be updated while application is running. So update the stored size.
69  */
70 void UpdateScreenSize();
71
72 /**
73  * @copydoc Dali::Keyboard::SetRepeatInfo()
74  */
75 bool SetKeyboardRepeatInfo(float rate, float delay);
76
77 /**
78  * @copydoc Dali::Keyboard::GetRepeatInfo()
79  */
80 bool GetKeyboardRepeatInfo(float& rate, float& delay);
81
82 /**
83  * @copydoc Dali::Keyboard::SetHorizontalRepeatInfo()
84  */
85 bool SetKeyboardHorizontalRepeatInfo(float rate, float delay);
86
87 /**
88  * @copydoc Dali::Keyboard::GetHorizontalRepeatInfo()
89  */
90 bool GetKeyboardHorizontalRepeatInfo(float& rate, float& delay);
91
92 /**
93  * @copydoc Dali::Keyboard::SetVerticalRepeatInfo()
94  */
95 bool SetKeyboardVerticalRepeatInfo(float rate, float delay);
96
97 /**
98  * @copydoc Dali::Keyboard::GetVerticalRepeatInfo()
99  */
100 bool GetKeyboardVerticalRepeatInfo(float& rate, float& delay);
101
102 /**
103  * @brief Sets whether the processes using geometry event propagation touch and hover events.
104  *
105  * @param[in] enabled True if the processes using geometry event propagation touch and hover events.
106  */
107 void SetGeometryHittestEnabled(bool enabled);
108
109 /**
110  * @brief Queries whether the scene using geometry event propagation touch and hover events.
111  *
112  * @return True if the scene using geometry event propagation touch and hover events.
113  */
114 bool IsGeometryHittestEnabled();
115
116 } // namespace WindowSystem
117
118 /**
119  * Base class for window system. The minimal set of events and properties that should be received/set on the window
120  */
121 class WindowSystemBase
122 {
123 public:
124   /**
125    * Event types that can be received from the window manager for a given window
126    */
127   enum class Event
128   {
129     PROPERTY_NOTIFY,
130     DELETE_REQUEST,
131     MOVE_RESIZE_REQUEST,
132     FOCUS_IN,
133     FOCUS_OUT,
134     DAMAGE,
135     MOUSE_WHEEL,
136     MOUSE_MOVE,
137     MOUSE_BUTTON_DOWN,
138     MOUSE_BUTTON_UP,
139     MOUSE_OUT,
140     KEY_DOWN,
141     KEY_UP,
142     SELECTION_CLEAR,
143     SELECTION_NOTIFY,
144     CONFIGURE_NOTIFY,
145   };
146
147   /**
148    * Base ptr for events - implementation can downcast to platform specific event structure
149    */
150   struct EventBase
151   {
152   };
153
154   /**
155    * Callback function signature. Platform implementation can call generic handler on a given window
156    */
157   using EventHandlerCallback = bool (*)(void* data, Event eventType, EventBase* event);
158
159   /**
160    * Struct to define an event handler in a window implementation
161    */
162   struct EventHandler
163   {
164     EventHandlerCallback callback;  ///< User callback.
165     void*                data;      ///< user data
166     Event                event;     ///< Event the handler is listening to
167     int                  handlerId; ///< Id of the handler
168   };
169
170   /**
171    * @return Get the current display of this application
172    */
173   virtual Dali::Any GetDisplay() = 0;
174
175   /**
176    * Add an event handler to the window system
177    * @param event The window system event to listen for
178    * @param callback A callback to handle the event
179    * @param data User data to pass to the callback
180    * @return A handler object that may be passed to DeleteEventHandler.
181    *
182    * When the callback is executed, if it returns true, then the invoker will stop calling
183    * other event handlers that have registered with that event type. If it returns false,
184    * then it will continue with other registered handlers.
185    */
186   virtual EventHandler* AddEventHandler(Event event, EventHandlerCallback callback, void* data) = 0;
187
188   /**
189    * Delete an event handler from the window system.
190    * @param eventHandler The event handler to delete.
191    */
192   virtual void DeleteEventHandler(EventHandler* eventHandler) = 0;
193
194   /**
195    * Get the screen size for this window system.
196    *
197    * @param[out] width The width of the screen
198    * @param[out] height The height of the screen
199    */
200   virtual void GetScreenSize(int32_t& width, int32_t& height) = 0;
201 };
202
203 } // namespace Adaptor
204 } // namespace Internal
205 } // namespace Dali
206
207 #endif // DALI_INTERNAL_WINDOW_SYSTEM_COMMON_WINDOW_SYSTEM_H