@@ -9,6 +9,8 @@ using nativeapi::Display;
99using nativeapi::DisplayManager;
1010using nativeapi::DisplayOrientation;
1111using nativeapi::Point;
12+ using nativeapi::Size;
13+ using nativeapi::Rectangle;
1214
1315// Helper function to convert orientation enum to string
1416std::string orientationToString (DisplayOrientation orientation) {
@@ -78,64 +80,73 @@ void printDisplayInfo(const Display& display, bool isPrimary = false) {
7880 const int tableWidth = 70 ;
7981
8082 std::cout << createTableBorder (" +" , " +" , " -" , tableWidth) << std::endl;
81- std::cout << formatTableRow (" Display: " + display.name , tableWidth)
83+ std::cout << formatTableRow (" Display: " + display.GetName () , tableWidth)
8284 << std::endl;
8385 std::cout << createTableBorder (" +" , " +" , " -" , tableWidth) << std::endl;
84- std::cout << formatTableRow (" ID: " + display.id , tableWidth) << std::endl;
86+ std::cout << formatTableRow (" ID: " + display.GetId () , tableWidth) << std::endl;
8587
86- // Format position string
88+ // Format position string using getter methods
89+ Point position = display.GetPosition ();
8790 std::string positionStr = " Position: (" +
88- std::to_string ((int )display. position .x ) + " , " +
89- std::to_string ((int )display. position .y ) + " )" ;
91+ std::to_string ((int )position.x ) + " , " +
92+ std::to_string ((int )position.y ) + " )" ;
9093 std::cout << formatTableRow (positionStr, tableWidth) << std::endl;
9194
92- // Format size string with proper separator
93- std::string sizeStr = " Size: " + std::to_string ((int )display.size .width ) +
94- " x " + std::to_string ((int )display.size .height );
95+ // Format size string with proper separator using getter methods
96+ Size size = display.GetSize ();
97+ std::string sizeStr = " Size: " + std::to_string ((int )size.width ) +
98+ " x " + std::to_string ((int )size.height );
9599 std::cout << formatTableRow (sizeStr, tableWidth) << std::endl;
96100
97- // Format work area string with proper formatting
101+ // Format work area string with proper formatting using getter methods
102+ Rectangle workArea = display.GetWorkArea ();
98103 std::string workAreaStr =
99- " Work Area: (" + std::to_string ((int )display. workArea .x ) + " , " +
100- std::to_string ((int )display. workArea .y ) + " ) " +
101- std::to_string ((int )display. workArea .width ) + " x " +
102- std::to_string ((int )display. workArea .height );
104+ " Work Area: (" + std::to_string ((int )workArea.x ) + " , " +
105+ std::to_string ((int )workArea.y ) + " ) " +
106+ std::to_string ((int )workArea.width ) + " x " +
107+ std::to_string ((int )workArea.height );
103108 std::cout << formatTableRow (workAreaStr, tableWidth) << std::endl;
104109
105- // Format scale factor string
110+ // Format scale factor string using getter methods
106111 std::stringstream scaleStream;
107112 scaleStream << " Scale Factor: " << std::fixed << std::setprecision (2 )
108- << display.scaleFactor ;
113+ << display.GetScaleFactor () ;
109114 std::cout << formatTableRow (scaleStream.str (), tableWidth) << std::endl;
110115
111- // Format primary status
116+ // Format primary status using getter methods
112117 std::string primaryStr =
113- " Primary: " + std::string (display.isPrimary ? " Yes" : " No" );
118+ " Primary: " + std::string (display.IsPrimary () ? " Yes" : " No" );
114119 std::cout << formatTableRow (primaryStr, tableWidth) << std::endl;
115120
116- // Format orientation
121+ // Format orientation using getter methods
117122 std::string orientationStr =
118- " Orientation: " + orientationToString (display.orientation );
123+ " Orientation: " + orientationToString (display.GetOrientation () );
119124 std::cout << formatTableRow (orientationStr, tableWidth) << std::endl;
120125
121- // Format refresh rate
126+ // Format refresh rate using getter methods
122127 std::string refreshStr =
123- " Refresh Rate: " + std::to_string (display.refreshRate ) + " Hz" ;
128+ " Refresh Rate: " + std::to_string (display.GetRefreshRate () ) + " Hz" ;
124129 std::cout << formatTableRow (refreshStr, tableWidth) << std::endl;
125130
126- if (display.bitDepth > 0 ) {
131+ // Format bit depth using getter methods
132+ int bitDepth = display.GetBitDepth ();
133+ if (bitDepth > 0 ) {
127134 std::string bitDepthStr =
128- " Bit Depth: " + std::to_string (display. bitDepth ) + " bits" ;
135+ " Bit Depth: " + std::to_string (bitDepth) + " bits" ;
129136 std::cout << formatTableRow (bitDepthStr, tableWidth) << std::endl;
130137 }
131138
132- if (!display.manufacturer .empty ()) {
133- std::string manufacturerStr = " Manufacturer: " + display.manufacturer ;
139+ // Format manufacturer using getter methods
140+ std::string manufacturer = display.GetManufacturer ();
141+ if (!manufacturer.empty ()) {
142+ std::string manufacturerStr = " Manufacturer: " + manufacturer;
134143 std::cout << formatTableRow (manufacturerStr, tableWidth) << std::endl;
135144 }
136145
137- if (!display.model .empty ()) {
138- std::string modelStr = " Model: " + display.model ;
146+ // Format model using getter methods
147+ std::string model = display.GetModel ();
148+ if (!model.empty ()) {
149+ std::string modelStr = " Model: " + model;
139150 std::cout << formatTableRow (modelStr, tableWidth) << std::endl;
140151 }
141152
@@ -170,7 +181,7 @@ int main() {
170181 if (displays.size () > 1 ) {
171182 std::cout << " 📱 SECONDARY DISPLAYS:" << std::endl;
172183 for (const auto & display : displays) {
173- if (!display.isPrimary ) {
184+ if (!display.IsPrimary () ) {
174185 printDisplayInfo (display);
175186 std::cout << std::endl;
176187 }
@@ -183,16 +194,19 @@ int main() {
183194 << cursorPos.y << " )" << std::endl;
184195 std::cout << std::endl;
185196
186- // Display summary statistics
197+ // Display summary statistics using getter methods
187198 double totalWidth = 0 , totalHeight = 0 ;
188- double minScaleFactor = displays[0 ].scaleFactor ;
189- double maxScaleFactor = displays[0 ].scaleFactor ;
199+ double minScaleFactor = displays[0 ].GetScaleFactor () ;
200+ double maxScaleFactor = displays[0 ].GetScaleFactor () ;
190201
191202 for (const auto & display : displays) {
192- totalWidth += display.size .width ;
193- totalHeight = std::max (totalHeight, display.size .height );
194- minScaleFactor = std::min (minScaleFactor, display.scaleFactor );
195- maxScaleFactor = std::max (maxScaleFactor, display.scaleFactor );
203+ Size size = display.GetSize ();
204+ double scaleFactor = display.GetScaleFactor ();
205+
206+ totalWidth += size.width ;
207+ totalHeight = std::max (totalHeight, size.height );
208+ minScaleFactor = std::min (minScaleFactor, scaleFactor);
209+ maxScaleFactor = std::max (maxScaleFactor, scaleFactor);
196210 }
197211
198212 const int summaryWidth = 60 ;
@@ -238,12 +252,23 @@ int main() {
238252 std::cout << " C API - Found " << display_list.count
239253 << " display(s):" << std::endl;
240254 for (size_t i = 0 ; i < display_list.count ; ++i) {
241- const native_display_t & display = display_list.displays [i];
255+ native_display_t display = display_list.displays [i];
242256 std::cout << " Display " << (i + 1 ) << " :" << std::endl;
243- std::cout << " Name: " << (display.name ? display.name : " Unknown" ) << std::endl;
244- std::cout << " ID: " << (display.id ? display.id : " Unknown" ) << std::endl;
245- std::cout << " Size: " << display.size .width << " x " << display.size .height << std::endl;
246- std::cout << " Primary: " << (display.is_primary ? " Yes" : " No" ) << std::endl;
257+
258+ // Use getter functions instead of direct struct access
259+ char * name = native_display_get_name (display);
260+ std::cout << " Name: " << (name ? name : " Unknown" ) << std::endl;
261+ native_display_free_string (name);
262+
263+ char * id = native_display_get_id (display);
264+ std::cout << " ID: " << (id ? id : " Unknown" ) << std::endl;
265+ native_display_free_string (id);
266+
267+ native_size_t size = native_display_get_size (display);
268+ std::cout << " Size: " << size.width << " x " << size.height << std::endl;
269+
270+ bool is_primary = native_display_is_primary (display);
271+ std::cout << " Primary: " << (is_primary ? " Yes" : " No" ) << std::endl;
247272 std::cout << std::endl;
248273 }
249274
0 commit comments