1 /*******************************************************************
2  *
3  * @file lv_wayland.h - Public functions of the LVGL Wayland client
4  *
5  * Based on the original file from the repository.
6  *
7  * Porting to LVGL 9.1
8  * 2024 EDGEMTech Ltd.
9  *
10  * See LICENCE.txt for details
11  *
12  * Author(s): EDGEMTech Ltd, Erik Tagirov (erik.tagirov@edgemtech.ch)
13  *
14  ******************************************************************/
15 #ifndef LV_WAYLAND_H
16 #define LV_WAYLAND_H
17 
18 #ifndef _WIN32
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /*********************
25  *      INCLUDES
26  *********************/
27 
28 #include "../../display/lv_display.h"
29 #include "../../indev/lv_indev.h"
30 #include "../../indev/lv_indev_gesture.h"
31 
32 #if LV_USE_WAYLAND
33 
34 /*********************
35  *      DEFINES
36  *********************/
37 
38 /**********************
39  *      TYPEDEFS
40  **********************/
41 
42 typedef bool (*lv_wayland_display_close_f_t)(lv_display_t * disp);
43 
44 /**********************
45  * GLOBAL PROTOTYPES
46  **********************/
47 
48 /**
49  * Retrieves the file descriptor of the wayland socket
50  */
51 int lv_wayland_get_fd(void);
52 
53 /**
54  * Creates a window
55  * @param hor_res The width of the window in pixels
56  * @param ver_res The height of the window in pixels
57  * @param title The title of the window
58  * @param close_cb The callback that will be execute when the user closes the window
59  * @return The LVGL display associated to the window
60  */
61 lv_display_t * lv_wayland_window_create(uint32_t hor_res, uint32_t ver_res, char * title,
62                                         lv_wayland_display_close_f_t close_cb);
63 
64 /**
65  * Closes the window programmatically
66  * @param disp Reference to the LVGL display associated to the window
67  */
68 void lv_wayland_window_close(lv_display_t * disp);
69 
70 /**
71  * Check if the window is open
72  * @param disp Reference to the LVGL display associated to the window
73  * @return true: The window is open
74  */
75 bool lv_wayland_window_is_open(lv_display_t * disp);
76 
77 /**
78  * Sets the fullscreen state of the window
79  * @param disp Reference to the LVGL display associated to the window
80  * @param fullscreen If true the window enters fullscreen
81  */
82 void lv_wayland_window_set_fullscreen(lv_display_t * disp, bool fullscreen);
83 
84 /**
85  * Sets the maximized state of the window
86  * @param disp Reference to the LVGL display associated to the window
87  * @param fullscreen If true the window is maximized
88  */
89 void lv_wayland_window_set_maximized(lv_display_t * disp, bool maximize);
90 
91 /**
92  * Obtains the input device of the mouse pointer
93  * @note It is used to create an input group on application start
94  * @param disp Reference to the LVGL display associated to the window
95  * @return The input device
96  */
97 lv_indev_t * lv_wayland_get_pointer(lv_display_t * disp);
98 
99 /**
100  * Obtains the input device of the encoder
101  * @note It is used to create an input group on application start
102  * @param disp Reference to the LVGL display associated to the window
103  * @return The input device
104  */
105 lv_indev_t * lv_wayland_get_pointeraxis(lv_display_t * disp);
106 
107 /**
108  * Obtains the input device of the keyboard
109  * @note It is used to create an input group on application start
110  * @param disp Reference to the LVGL display associated to the window
111  * @return The input device
112  */
113 lv_indev_t * lv_wayland_get_keyboard(lv_display_t * disp);
114 
115 /**
116  * Obtains the input device of the touch screen
117  * @note It is used to create an input group on application start
118  * @param disp Reference to the LVGL display associated to the window
119  * @return The input device
120  */
121 lv_indev_t * lv_wayland_get_touchscreen(lv_display_t * disp);
122 
123 /**
124  * Wrapper around lv_timer_handler
125  * @note Must be called in the application run loop instead of the
126  * regular lv_timer_handler provided by LVGL
127  * @return true: if the cycle was completed, false if the application
128  * went to sleep because the last frame wasn't completed
129  */
130 bool lv_wayland_timer_handler(void);
131 
132 /**********************
133  *      MACROS
134  **********************/
135 
136 #endif /* LV_USE_WAYLAND */
137 
138 #ifdef __cplusplus
139 } /* extern "C" */
140 #endif
141 
142 #endif /* _WIN32 */
143 #endif /* WAYLAND_H */
144