mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-22 21:15:57 +00:00
Make totk.exe per-monitor DPI aware so fullscreen and the window use physical pixels
The manifest declared no DPI awareness, so Windows ran the process DPI-unaware: on a 4K monitor at 150% scale the fullscreen window and its swapchain were 2560x1440, the 4K game image was shrunk to it and Windows stretched the result back up, blurred (issues #25, #56, #31). The manifest now declares PerMonitorV2 (true/pm for older Windows 10). The window frame is measured at the window's DPI, a framed window keeps its client size when it moves to a monitor at another scale, WM_DPICHANGED takes the suggested rect or keeps fullscreen over the monitor, and window_size means screen pixels. The menu's minimum text size follows the window's DPI, and the text entry dialog is measured at the game window's DPI. --probe-dpi prints the process awareness and fails unless it is per-monitor v2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8eaf198443
commit
fcaecabad4
9 files changed
+121
-26
No files matched your search
+7
-2
@@ -171,8 +171,13 @@ static ImGuiStyle g_base_style; // the menu's style at 1080 lines
|
||||
static uint64_t g_last_ns;
|
||||
static uint64_t g_cost_ns, g_cost_frames; // CPU time of layout and recording while open, logged per 600 frames
|
||||
|
||||
// Sizes are tuned for 1080 lines and follow the window's height; under 720 lines they stay at the 720 size.
|
||||
static float menu_scale(uint32_t h) { return (h >= 720 ? h : 720) / 1080.0f; }
|
||||
// Sizes are tuned for 1080 lines and follow the window's height. Under 720 lines at 100% display scale they stay at the
|
||||
// 720 size; that floor grows with the window's DPI, so a small window on a 150% or 200% display (sizes are physical
|
||||
// pixels) still gets text as large as the display scale asks for.
|
||||
static float menu_scale(uint32_t h) {
|
||||
float least = 720.0f * (float)gfx_window_dpi() / 96.0f;
|
||||
return ((float)h >= least ? (float)h : least) / 1080.0f;
|
||||
}
|
||||
|
||||
// SavageWindRecomp's colours: dark green panels, gold accents.
|
||||
static void style_init(ImGuiStyle &s) {
|
||||
|
||||
@@ -59,6 +59,7 @@ void gfx_window_apply_settings(void); // TOTK_FULLSCREEN or TOTK_WINDOW_SIZE
|
||||
void gfx_window_request_close(void); // as the window's close button: the process ends
|
||||
int gfx_window_monitor_size(int *w, int *h); // pixels of the monitor the window is on; 0 when unknown
|
||||
double gfx_window_refresh_hz(void); // its refresh rate (TOTK_FPS_LIMIT=display); 0 when unknown
|
||||
unsigned gfx_window_dpi(void); // the window's DPI (96 at 100% display scale); any thread
|
||||
// The present mode the swapchain got, as a TOTK_VK_PRESENT value ("fifo" when mailbox is missing); "" before the first
|
||||
// swapchain. Any thread.
|
||||
const char *gfx_window_present_mode(void);
|
||||
|
||||
Reference in new issue
Block a user