|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#ifdef __cplusplus |
| 4 | +extern "C" { |
| 5 | +#endif |
| 6 | + |
| 7 | +#include <stdbool.h> |
| 8 | +#include <stdint.h> |
| 9 | + |
| 10 | +/** |
| 11 | + * Point is a 2D point in the coordinate system. |
| 12 | + */ |
| 13 | +typedef struct { |
| 14 | + double x; |
| 15 | + double y; |
| 16 | +} nativeapi_point_t; |
| 17 | + |
| 18 | +/** |
| 19 | + * Size is a 2D size in the coordinate system. |
| 20 | + */ |
| 21 | +typedef struct { |
| 22 | + double width; |
| 23 | + double height; |
| 24 | +} nativeapi_size_t; |
| 25 | + |
| 26 | +/** |
| 27 | + * Rectangle is a 2D rectangle in the coordinate system. |
| 28 | + */ |
| 29 | +typedef struct { |
| 30 | + double x; |
| 31 | + double y; |
| 32 | + double width; |
| 33 | + double height; |
| 34 | +} nativeapi_rectangle_t; |
| 35 | + |
| 36 | +/** |
| 37 | + * Display orientation enumeration |
| 38 | + */ |
| 39 | +typedef enum { |
| 40 | + NATIVEAPI_DISPLAY_ORIENTATION_PORTRAIT = 0, |
| 41 | + NATIVEAPI_DISPLAY_ORIENTATION_LANDSCAPE = 90, |
| 42 | + NATIVEAPI_DISPLAY_ORIENTATION_PORTRAIT_FLIPPED = 180, |
| 43 | + NATIVEAPI_DISPLAY_ORIENTATION_LANDSCAPE_FLIPPED = 270 |
| 44 | +} nativeapi_display_orientation_t; |
| 45 | + |
| 46 | +/** |
| 47 | + * Representation of a display/monitor |
| 48 | + */ |
| 49 | +typedef struct { |
| 50 | + // Basic identification |
| 51 | + char* id; // Unique identifier for the display |
| 52 | + char* name; // Human-readable display name |
| 53 | + |
| 54 | + // Physical properties |
| 55 | + nativeapi_point_t position; // Display position in virtual desktop coordinates |
| 56 | + nativeapi_size_t size; // Full display size in logical pixels |
| 57 | + nativeapi_rectangle_t work_area; // Available work area (excluding taskbars, docks, etc.) |
| 58 | + double scale_factor; // Display scaling factor (1.0 = 100%, 2.0 = 200%, etc.) |
| 59 | + |
| 60 | + // Additional properties |
| 61 | + bool is_primary; // Whether this is the primary display |
| 62 | + nativeapi_display_orientation_t orientation; // Current display orientation |
| 63 | + int refresh_rate; // Refresh rate in Hz (0 if unknown) |
| 64 | + int bit_depth; // Color bit depth (0 if unknown) |
| 65 | + |
| 66 | + // Hardware information |
| 67 | + char* manufacturer; // Display manufacturer |
| 68 | + char* model; // Display model |
| 69 | + char* serial_number; // Display serial number (if available) |
| 70 | +} nativeapi_display_t; |
| 71 | + |
| 72 | +/** |
| 73 | + * Create a new display structure with default values |
| 74 | + * @return Pointer to newly allocated display structure, or NULL on failure |
| 75 | + */ |
| 76 | +nativeapi_display_t* nativeapi_display_create(void); |
| 77 | + |
| 78 | +/** |
| 79 | + * Free a display structure and all its allocated strings |
| 80 | + * @param display Pointer to display structure to free |
| 81 | + */ |
| 82 | +void nativeapi_display_destroy(nativeapi_display_t* display); |
| 83 | + |
| 84 | +/** |
| 85 | + * Set the ID of a display |
| 86 | + * @param display Pointer to display structure |
| 87 | + * @param id ID string (will be copied) |
| 88 | + * @return true on success, false on failure |
| 89 | + */ |
| 90 | +bool nativeapi_display_set_id(nativeapi_display_t* display, const char* id); |
| 91 | + |
| 92 | +/** |
| 93 | + * Set the name of a display |
| 94 | + * @param display Pointer to display structure |
| 95 | + * @param name Name string (will be copied) |
| 96 | + * @return true on success, false on failure |
| 97 | + */ |
| 98 | +bool nativeapi_display_set_name(nativeapi_display_t* display, const char* name); |
| 99 | + |
| 100 | +/** |
| 101 | + * Set the manufacturer of a display |
| 102 | + * @param display Pointer to display structure |
| 103 | + * @param manufacturer Manufacturer string (will be copied) |
| 104 | + * @return true on success, false on failure |
| 105 | + */ |
| 106 | +bool nativeapi_display_set_manufacturer(nativeapi_display_t* display, const char* manufacturer); |
| 107 | + |
| 108 | +/** |
| 109 | + * Set the model of a display |
| 110 | + * @param display Pointer to display structure |
| 111 | + * @param model Model string (will be copied) |
| 112 | + * @return true on success, false on failure |
| 113 | + */ |
| 114 | +bool nativeapi_display_set_model(nativeapi_display_t* display, const char* model); |
| 115 | + |
| 116 | +/** |
| 117 | + * Set the serial number of a display |
| 118 | + * @param display Pointer to display structure |
| 119 | + * @param serial_number Serial number string (will be copied) |
| 120 | + * @return true on success, false on failure |
| 121 | + */ |
| 122 | +bool nativeapi_display_set_serial_number(nativeapi_display_t* display, const char* serial_number); |
| 123 | + |
| 124 | +/** |
| 125 | + * Set the position of a display |
| 126 | + * @param display Pointer to display structure |
| 127 | + * @param x X coordinate |
| 128 | + * @param y Y coordinate |
| 129 | + */ |
| 130 | +void nativeapi_display_set_position(nativeapi_display_t* display, double x, double y); |
| 131 | + |
| 132 | +/** |
| 133 | + * Set the size of a display |
| 134 | + * @param display Pointer to display structure |
| 135 | + * @param width Width in logical pixels |
| 136 | + * @param height Height in logical pixels |
| 137 | + */ |
| 138 | +void nativeapi_display_set_size(nativeapi_display_t* display, double width, double height); |
| 139 | + |
| 140 | +/** |
| 141 | + * Set the work area of a display |
| 142 | + * @param display Pointer to display structure |
| 143 | + * @param x X coordinate of work area |
| 144 | + * @param y Y coordinate of work area |
| 145 | + * @param width Width of work area |
| 146 | + * @param height Height of work area |
| 147 | + */ |
| 148 | +void nativeapi_display_set_work_area(nativeapi_display_t* display, double x, double y, double width, double height); |
| 149 | + |
| 150 | +/** |
| 151 | + * Set the scale factor of a display |
| 152 | + * @param display Pointer to display structure |
| 153 | + * @param scale_factor Scale factor (1.0 = 100%, 2.0 = 200%, etc.) |
| 154 | + */ |
| 155 | +void nativeapi_display_set_scale_factor(nativeapi_display_t* display, double scale_factor); |
| 156 | + |
| 157 | +/** |
| 158 | + * Set whether a display is primary |
| 159 | + * @param display Pointer to display structure |
| 160 | + * @param is_primary true if primary display, false otherwise |
| 161 | + */ |
| 162 | +void nativeapi_display_set_primary(nativeapi_display_t* display, bool is_primary); |
| 163 | + |
| 164 | +/** |
| 165 | + * Set the orientation of a display |
| 166 | + * @param display Pointer to display structure |
| 167 | + * @param orientation Display orientation |
| 168 | + */ |
| 169 | +void nativeapi_display_set_orientation(nativeapi_display_t* display, nativeapi_display_orientation_t orientation); |
| 170 | + |
| 171 | +/** |
| 172 | + * Set the refresh rate of a display |
| 173 | + * @param display Pointer to display structure |
| 174 | + * @param refresh_rate Refresh rate in Hz (0 if unknown) |
| 175 | + */ |
| 176 | +void nativeapi_display_set_refresh_rate(nativeapi_display_t* display, int refresh_rate); |
| 177 | + |
| 178 | +/** |
| 179 | + * Set the bit depth of a display |
| 180 | + * @param display Pointer to display structure |
| 181 | + * @param bit_depth Color bit depth (0 if unknown) |
| 182 | + */ |
| 183 | +void nativeapi_display_set_bit_depth(nativeapi_display_t* display, int bit_depth); |
| 184 | + |
| 185 | +#ifdef __cplusplus |
| 186 | +} |
| 187 | +#endif |
0 commit comments