Skip to content

Commit cf85652

Browse files
committed
reflect dpi change events appropriately in font size / window pos & size
1 parent f2d2804 commit cf85652

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/os/gfx/win32/os_gfx_win32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,14 @@ os_w32_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
548548
case WM_DPICHANGED:
549549
{
550550
F32 new_dpi = (F32)(wParam & 0xffff);
551+
RECT suggested_new_rect = *(RECT *)lParam;
551552
window->dpi = new_dpi;
553+
SetWindowPos(window->hwnd, 0,
554+
suggested_new_rect.left,
555+
suggested_new_rect.top,
556+
suggested_new_rect.right - suggested_new_rect.left,
557+
suggested_new_rect.bottom - suggested_new_rect.top,
558+
0);
552559
}break;
553560

554561
//- rjf: [file drop]

src/raddbg/raddbg_core.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5176,6 +5176,19 @@ rd_window_frame(void)
51765176
cfg_node_release(rd_state->cfg, cfg_node_child_from_string(window, str8_lit("maximized")));
51775177
}
51785178

5179+
//- rjf: DPI changes -> xform font size / window size
5180+
F32 dpi = os_dpi_from_window(ws->os);
5181+
if(dpi != ws->last_dpi)
5182+
{
5183+
fnt_reset();
5184+
F32 current_font_size = rd_font_size();
5185+
F32 new_font_size = current_font_size * (dpi / ws->last_dpi);
5186+
new_font_size = Clamp(6.f, new_font_size, 72.f);
5187+
CFG_Node *font_size_cfg = cfg_node_child_from_string_or_alloc(rd_state->cfg, window, str8_lit("font_size"));
5188+
cfg_node_new_replacef(rd_state->cfg, font_size_cfg, "%I64u", (U64)new_font_size);
5189+
ws->last_dpi = dpi;
5190+
}
5191+
51795192
//- rjf: commit position
51805193
Rng2F32 window_rect = os_rect_from_window(ws->os);
51815194
if(!is_fullscreen && !is_maximized && !is_minimized)

0 commit comments

Comments
 (0)