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