1 /**
2  * @file lv_windows_context.h
3  *
4  */
5 
6 #ifndef LV_WINDOWS_CONTEXT_H
7 #define LV_WINDOWS_CONTEXT_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 
17 #include "../../display/lv_display.h"
18 #include "../../indev/lv_indev.h"
19 
20 #if LV_USE_WINDOWS
21 
22 #if LV_USE_OS != LV_OS_WINDOWS
23 #error [lv_windows] LV_OS_WINDOWS is required. Enable it in lv_conf.h (LV_USE_OS LV_OS_WINDOWS)
24 #endif
25 
26 #include <windows.h>
27 
28 #ifndef CREATE_WAITABLE_TIMER_MANUAL_RESET
29 #define CREATE_WAITABLE_TIMER_MANUAL_RESET  0x00000001
30 #endif
31 
32 #ifndef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
33 #define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x00000002
34 #endif
35 
36 /*********************
37  *      DEFINES
38  *********************/
39 
40 /**********************
41  *      TYPEDEFS
42  **********************/
43 
44 typedef struct _lv_windows_pointer_context_t {
45     lv_indev_state_t state;
46     lv_point_t point;
47     lv_indev_t * indev;
48 } lv_windows_pointer_context_t;
49 
50 typedef struct _lv_windows_keypad_queue_item_t {
51     uint32_t key;
52     lv_indev_state_t state;
53 } lv_windows_keypad_queue_item_t;
54 
55 typedef struct _lv_windows_keypad_context_t {
56     lv_ll_t queue;
57     uint16_t utf16_high_surrogate;
58     uint16_t utf16_low_surrogate;
59     lv_indev_t * indev;
60 } lv_windows_keypad_context_t;
61 
62 typedef struct _lv_windows_encoder_context_t {
63     lv_indev_state_t state;
64     int16_t enc_diff;
65     lv_indev_t * indev;
66 } lv_windows_encoder_context_t;
67 
68 typedef struct _lv_windows_window_context_t {
69     lv_display_t * display_device_object;
70     lv_timer_t * display_timer_object;
71 
72     int32_t window_dpi;
73     int32_t zoom_level;
74     bool allow_dpi_override;
75     bool simulator_mode;
76     bool display_resolution_changed;
77     lv_point_t requested_display_resolution;
78 
79     HDC display_framebuffer_context_handle;
80     uint32_t * display_framebuffer_base;
81     size_t display_framebuffer_size;
82 
83     lv_windows_pointer_context_t pointer;
84     lv_windows_keypad_context_t keypad;
85     lv_windows_encoder_context_t encoder;
86 
87 } lv_windows_window_context_t;
88 
89 typedef struct _lv_windows_create_display_data_t {
90     const wchar_t * title;
91     int32_t hor_res;
92     int32_t ver_res;
93     int32_t zoom_level;
94     bool allow_dpi_override;
95     bool simulator_mode;
96     HANDLE mutex;
97     lv_display_t * display;
98 } lv_windows_create_display_data_t;
99 
100 /**********************
101  * GLOBAL PROTOTYPES
102  **********************/
103 
104 /**
105  * @brief Initialize the LVGL Windows backend.
106  * @remark This is a private API which is used for LVGL Windows backend
107  *         implementation. LVGL users shouldn't use that because the
108  *         LVGL has already used it in lv_init.
109 */
110 void lv_windows_platform_init(void);
111 
112 /**
113  * @brief Get the window context from specific LVGL display window.
114  * @param window_handle The window handle of specific LVGL display window.
115  * @return The window context from specific LVGL display window.
116  * @remark This is a private API which is used for LVGL Windows backend
117  *         implementation. LVGL users shouldn't use that because the
118  *         maintainer doesn't promise the application binary interface
119  *         compatibility for this API.
120 */
121 lv_windows_window_context_t * lv_windows_get_window_context(
122     HWND window_handle);
123 
124 /**********************
125  *      MACROS
126  **********************/
127 
128 #endif // LV_USE_WINDOWS
129 
130 #ifdef __cplusplus
131 } /*extern "C"*/
132 #endif
133 
134 #endif /*LV_WINDOWS_CONTEXT_H*/
135