mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
demos: Add basic DPI handling.
This commit is contained in:
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
@ -31,6 +31,8 @@ struct demo
|
||||
|
||||
void *user_data;
|
||||
void (*idle_func)(struct demo *demo, void *user_data);
|
||||
|
||||
UINT (*GetDpiForSystem)(void);
|
||||
};
|
||||
|
||||
struct demo_window
|
||||
@ -48,6 +50,11 @@ struct demo_swapchain
|
||||
IDXGISwapChain3 *swapchain;
|
||||
};
|
||||
|
||||
static inline void demo_get_dpi(struct demo *demo, double *dpi_x, double *dpi_y)
|
||||
{
|
||||
*dpi_x = *dpi_y = demo->GetDpiForSystem();
|
||||
}
|
||||
|
||||
static inline struct demo_window *demo_window_create(struct demo *demo, const char *title,
|
||||
unsigned int width, unsigned int height, void *user_data)
|
||||
{
|
||||
@ -191,6 +198,11 @@ static inline void demo_process_events(struct demo *demo)
|
||||
}
|
||||
}
|
||||
|
||||
static inline UINT demo_GetDpiForSystem(void)
|
||||
{
|
||||
return 96;
|
||||
}
|
||||
|
||||
static inline bool demo_init(struct demo *demo, void *user_data)
|
||||
{
|
||||
WNDCLASSEXW wc;
|
||||
@ -215,6 +227,11 @@ static inline bool demo_init(struct demo *demo, void *user_data)
|
||||
demo->user_data = user_data;
|
||||
demo->idle_func = NULL;
|
||||
|
||||
if ((demo->GetDpiForSystem = (void *)GetProcAddress(GetModuleHandleA("user32"), "GetDpiForSystem")))
|
||||
SetProcessDPIAware();
|
||||
else
|
||||
demo->GetDpiForSystem = demo_GetDpiForSystem;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user