[Tizen] Add a method to update the screen size
[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) 2022 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 Get the screen size
45  */
46 void GetScreenSize(int32_t& width, int32_t& height);
47
48 /**
49  * @brief Update the screen size
50  * @note The screen size may be updated while application is running. So update the stored size.
51  */
52 void UpdateScreenSize();
53
54 /**
55  * @copydoc Dali::Keyboard::SetRepeatInfo()
56  */
57 bool SetKeyboardRepeatInfo(float rate, float delay);
58
59 /**
60  * @copydoc Dali::Keyboard::GetRepeatInfo()
61  */
62 bool GetKeyboardRepeatInfo(float& rate, float& delay);
63
64 } // namespace WindowSystem
65
66 /**
67  * Base class for window system. The minimal set of events and properties that should be received/set on the window
68  */
69 class WindowSystemBase
70 {
71 public:
72   /**
73    * Event types that can be received from the window manager for a given window
74    */
75   enum class Event
76   {
77     PROPERTY_NOTIFY,
78     DELETE_REQUEST,
79     MOVE_RESIZE_REQUEST,
80     FOCUS_IN,
81     FOCUS_OUT,
82     DAMAGE,
83     MOUSE_WHEEL,
84     MOUSE_MOVE,
85     MOUSE_BUTTON_DOWN,
86     MOUSE_BUTTON_UP,
87     MOUSE_OUT,
88     KEY_DOWN,
89     KEY_UP,
90     SELECTION_CLEAR,
91     SELECTION_NOTIFY
92   };
93
94   /**
95    * Base ptr for events - implementation can downcast to platform specific event structure
96    */
97   struct EventBase
98   {
99   };
100
101   /**
102    * Callback function signature. Platform implementation can call generic handler on a given window
103    */
104   using EventHandlerCallback = bool (*)(void* data, Event eventType, EventBase* event);
105
106   /**
107    * Struct to define an event handler in a window implementation
108    */
109   struct EventHandler
110   {
111     EventHandlerCallback callback;  ///< User callback.
112     void*                data;      ///< user data
113     Event                event;     ///< Event the handler is listening to
114     int                  handlerId; ///< Id of the handler
115   };
116
117   /**
118    * @return Get the current display of this application
119    */
120   virtual Dali::Any GetDisplay() = 0;
121
122   /**
123    * Add an event handler to the window system
124    * @param event The window system event to listen for
125    * @param callback A callback to handle the event
126    * @param data User data to pass to the callback
127    * @return A handler object that may be passed to DeleteEventHandler.
128    *
129    * When the callback is executed, if it returns true, then the invoker will stop calling
130    * other event handlers that have registered with that event type. If it returns false,
131    * then it will continue with other registered handlers.
132    */
133   virtual EventHandler* AddEventHandler(Event event, EventHandlerCallback callback, void* data) = 0;
134
135   /**
136    * Delete an event handler from the window system.
137    * @param eventHandler The event handler to delete.
138    */
139   virtual void DeleteEventHandler(EventHandler* eventHandler) = 0;
140
141   /**
142    * Get the screen size for this window system.
143    *
144    * @param[out] width The width of the screen
145    * @param[out] height The height of the screen
146    */
147   virtual void GetScreenSize(int32_t& width, int32_t& height) = 0;
148 };
149
150 } // namespace Adaptor
151 } // namespace Internal
152 } // namespace Dali
153
154 #endif // DALI_INTERNAL_WINDOW_SYSTEM_COMMON_WINDOW_SYSTEM_H