Skip to content

Commit d017d99

Browse files
committed
Remove hardware info getters from Display API and C bindings
1 parent 27d0e7b commit d017d99

File tree

10 files changed

+205
-477
lines changed

10 files changed

+205
-477
lines changed

examples/display_c_example/main.c

Lines changed: 96 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -7,120 +7,103 @@
77
#include "../../src/capi/geometry_c.h"
88

99
int main() {
10-
printf("=== Native API C Display Example ===\n\n");
11-
12-
// Test getting all displays
13-
native_display_list_t display_list = native_display_manager_get_all();
14-
15-
if (display_list.displays != NULL && display_list.count > 0) {
16-
printf("Found %ld display(s):\n\n", display_list.count);
17-
18-
for (size_t i = 0; i < display_list.count; i++) {
19-
native_display_t display = display_list.displays[i];
20-
21-
printf("Display %zu:\n", i + 1);
22-
23-
// Use getter functions for all properties
24-
char* name = native_display_get_name(display);
25-
printf(" Name: %s\n", name ? name : "Unknown");
26-
native_display_free_string(name);
27-
28-
char* id = native_display_get_id(display);
29-
printf(" ID: %s\n", id ? id : "Unknown");
30-
native_display_free_string(id);
31-
32-
native_point_t position = native_display_get_position(display);
33-
printf(" Position: (%.0f, %.0f)\n", position.x, position.y);
34-
35-
native_size_t size = native_display_get_size(display);
36-
printf(" Size: %.0f x %.0f\n", size.width, size.height);
37-
38-
native_rectangle_t work_area = native_display_get_work_area(display);
39-
printf(" Work Area: (%.0f, %.0f) %.0f x %.0f\n",
40-
work_area.x, work_area.y, work_area.width, work_area.height);
41-
42-
double scale_factor = native_display_get_scale_factor(display);
43-
printf(" Scale Factor: %.2f\n", scale_factor);
44-
45-
bool is_primary = native_display_is_primary(display);
46-
printf(" Primary: %s\n", is_primary ? "Yes" : "No");
47-
48-
// Display orientation
49-
printf(" Orientation: ");
50-
native_display_orientation_t orientation = native_display_get_orientation(display);
51-
switch (orientation) {
52-
case NATIVE_DISPLAY_ORIENTATION_PORTRAIT:
53-
printf("Portrait (0°)");
54-
break;
55-
case NATIVE_DISPLAY_ORIENTATION_LANDSCAPE:
56-
printf("Landscape (90°)");
57-
break;
58-
case NATIVE_DISPLAY_ORIENTATION_PORTRAIT_FLIPPED:
59-
printf("Portrait Flipped (180°)");
60-
break;
61-
case NATIVE_DISPLAY_ORIENTATION_LANDSCAPE_FLIPPED:
62-
printf("Landscape Flipped (270°)");
63-
break;
64-
default:
65-
printf("Unknown");
66-
break;
67-
}
68-
printf("\n");
69-
70-
int refresh_rate = native_display_get_refresh_rate(display);
71-
printf(" Refresh Rate: %d Hz\n", refresh_rate);
72-
73-
int bit_depth = native_display_get_bit_depth(display);
74-
printf(" Bit Depth: %d bits\n", bit_depth);
75-
76-
char* manufacturer = native_display_get_manufacturer(display);
77-
if (manufacturer) {
78-
printf(" Manufacturer: %s\n", manufacturer);
79-
}
80-
native_display_free_string(manufacturer);
81-
82-
char* model = native_display_get_model(display);
83-
if (model) {
84-
printf(" Model: %s\n", model);
85-
}
86-
native_display_free_string(model);
87-
88-
char* serial_number = native_display_get_serial_number(display);
89-
if (serial_number) {
90-
printf(" Serial Number: %s\n", serial_number);
91-
}
92-
native_display_free_string(serial_number);
93-
94-
printf("\n");
95-
}
96-
97-
// Clean up memory
98-
native_display_list_free(&display_list);
99-
} else {
100-
printf("No displays found or error occurred\n");
101-
}
10+
printf("=== Native API C Display Example ===\n\n");
11+
12+
// Test getting all displays
13+
native_display_list_t display_list = native_display_manager_get_all();
14+
15+
if (display_list.displays != NULL && display_list.count > 0) {
16+
printf("Found %ld display(s):\n\n", display_list.count);
17+
18+
for (size_t i = 0; i < display_list.count; i++) {
19+
native_display_t display = display_list.displays[i];
20+
21+
printf("Display %zu:\n", i + 1);
22+
23+
// Use getter functions for all properties
24+
char* name = native_display_get_name(display);
25+
printf(" Name: %s\n", name ? name : "Unknown");
26+
free(name);
27+
28+
char* id = native_display_get_id(display);
29+
printf(" ID: %s\n", id ? id : "Unknown");
30+
free(id);
31+
32+
native_point_t position = native_display_get_position(display);
33+
printf(" Position: (%.0f, %.0f)\n", position.x, position.y);
34+
35+
native_size_t size = native_display_get_size(display);
36+
printf(" Size: %.0f x %.0f\n", size.width, size.height);
37+
38+
native_rectangle_t work_area = native_display_get_work_area(display);
39+
printf(" Work Area: (%.0f, %.0f) %.0f x %.0f\n", work_area.x,
40+
work_area.y, work_area.width, work_area.height);
10241

103-
// Test getting primary display
104-
printf("=== Primary Display ===\n");
105-
native_display_t primary = native_display_manager_get_primary();
106-
if (primary) {
107-
char* name = native_display_get_name(primary);
108-
printf("Primary display: %s\n", name ? name : "Unknown");
109-
native_display_free_string(name);
110-
111-
native_size_t size = native_display_get_size(primary);
112-
printf("Size: %.0f x %.0f\n", size.width, size.height);
113-
114-
// Free the primary display handle
115-
native_display_free(primary);
116-
} else {
117-
printf("Failed to get primary display\n");
42+
double scale_factor = native_display_get_scale_factor(display);
43+
printf(" Scale Factor: %.2f\n", scale_factor);
44+
45+
bool is_primary = native_display_is_primary(display);
46+
printf(" Primary: %s\n", is_primary ? "Yes" : "No");
47+
48+
// Display orientation
49+
printf(" Orientation: ");
50+
native_display_orientation_t orientation =
51+
native_display_get_orientation(display);
52+
switch (orientation) {
53+
case NATIVE_DISPLAY_ORIENTATION_PORTRAIT:
54+
printf("Portrait (0°)");
55+
break;
56+
case NATIVE_DISPLAY_ORIENTATION_LANDSCAPE:
57+
printf("Landscape (90°)");
58+
break;
59+
case NATIVE_DISPLAY_ORIENTATION_PORTRAIT_FLIPPED:
60+
printf("Portrait Flipped (180°)");
61+
break;
62+
case NATIVE_DISPLAY_ORIENTATION_LANDSCAPE_FLIPPED:
63+
printf("Landscape Flipped (270°)");
64+
break;
65+
default:
66+
printf("Unknown");
67+
break;
68+
}
69+
printf("\n");
70+
71+
int refresh_rate = native_display_get_refresh_rate(display);
72+
printf(" Refresh Rate: %d Hz\n", refresh_rate);
73+
74+
int bit_depth = native_display_get_bit_depth(display);
75+
printf(" Bit Depth: %d bits\n", bit_depth);
76+
77+
printf("\n");
11878
}
11979

120-
// Test getting cursor position
121-
printf("\n=== Cursor Position ===\n");
122-
native_point_t cursor_pos = native_display_manager_get_cursor_position();
123-
printf("Cursor position: (%.0f, %.0f)\n", cursor_pos.x, cursor_pos.y);
80+
// Clean up memory
81+
native_display_list_free(&display_list);
82+
} else {
83+
printf("No displays found or error occurred\n");
84+
}
85+
86+
// Test getting primary display
87+
printf("=== Primary Display ===\n");
88+
native_display_t primary = native_display_manager_get_primary();
89+
if (primary) {
90+
char* name = native_display_get_name(primary);
91+
printf("Primary display: %s\n", name ? name : "Unknown");
92+
free(name);
93+
94+
native_size_t size = native_display_get_size(primary);
95+
printf("Size: %.0f x %.0f\n", size.width, size.height);
96+
97+
// Free the primary display handle
98+
native_display_free(primary);
99+
} else {
100+
printf("Failed to get primary display\n");
101+
}
102+
103+
// Test getting cursor position
104+
printf("\n=== Cursor Position ===\n");
105+
native_point_t cursor_pos = native_display_manager_get_cursor_position();
106+
printf("Cursor position: (%.0f, %.0f)\n", cursor_pos.x, cursor_pos.y);
124107

125-
return 0;
126-
}
108+
return 0;
109+
}

0 commit comments

Comments
 (0)