diff --git a/src/win32/gui.zig b/src/win32/gui.zig index bc9091a..e880972 100644 --- a/src/win32/gui.zig +++ b/src/win32/gui.zig @@ -198,7 +198,6 @@ const State = struct { pid: thespian.pid, render_state: render.WindowState, scroll_delta: isize = 0, - last_sizing_edge: ?win32.WPARAM = null, bounds: ?WindowBounds = null, }; fn stateFromHwnd(hwnd: win32.HWND) *State { @@ -1036,15 +1035,17 @@ fn WndProc( return 0; }, win32.WM_SIZING => { + const rect: *win32.RECT = @ptrFromInt(@as(usize, @bitCast(lparam))); + const dpi = win32.dpiFromHwnd(hwnd); + const font = getFont(dpi, getFontSize(), getFontFace()); + const cell_size = font.getCellSize(i32); + const new_rect = calcWindowRect(dpi, rect.*, wparam, cell_size); const state = stateFromHwnd(hwnd); - state.last_sizing_edge = wparam; - return 0; - }, - win32.WM_EXITSIZEMOVE => { - const state = stateFromHwnd(hwnd); - state.bounds = null; - updateWindowSize(hwnd, state.last_sizing_edge, &state.bounds); - state.last_sizing_edge = null; + state.bounds = .{ + .token = new_rect, + .rect = rect.*, + }; + rect.* = new_rect; return 0; }, win32.WM_DISPLAYCHANGE => {