demos: Add basic DPI handling.

This commit is contained in:
Henri Verbeet
2025-03-17 16:52:55 +01:00
parent 21e08955d3
commit 110edf32d0
Notes: Henri Verbeet 2025-03-19 16:02:33 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1432
4 changed files with 39 additions and 0 deletions

View File

@@ -198,6 +198,20 @@ static inline xcb_screen_t *demo_get_screen(xcb_connection_t *c, int idx)
return NULL;
}
static inline void demo_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
{
xcb_screen_t *screen;
if (!(screen = demo_get_screen(demo->connection, demo->screen)))
{
*dpi_x = *dpi_y = 96.0;
return;
}
*dpi_x = screen->width_in_pixels * 25.4 / screen->width_in_millimeters;
*dpi_y = screen->height_in_pixels * 25.4 / screen->height_in_millimeters;
}
static inline struct demo_window *demo_window_create(struct demo *demo, const char *title,
unsigned int width, unsigned int height, void *user_data)
{