Skip to content

Commit 65d1185

Browse files
leaanthonyclaude
andcommitted
fix(windows): recalculate hit-test regions on DPI change for frameless windows
When a frameless transparent window is moved between monitors with different DPI settings, the hit-test regions weren't being recalculated, causing the right and bottom edges to become unresponsive to clicks. This fix adds the SWP_FRAMECHANGED flag to SetWindowPos in the WM_DPICHANGED handler for frameless windows, which triggers WM_NCCALCSIZE to recalculate the non-client area and hit-test regions. For frameless windows with decorations, the DWM frame is also re-extended into the client area to ensure proper window frame styling after the DPI change. Fixes #4691 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bf1173c commit 65d1185

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

v3/UNRELEASED_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ After processing, the content will be moved to the main changelog and this file
2323

2424
## Fixed
2525
<!-- Bug fixes -->
26+
- Fix frameless transparent window hit-test regions not updating after DPI change on Windows (#4691)
2627

2728
## Deprecated
2829
<!-- Soon-to-be removed features -->

v3/pkg/application/webview_window_windows.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,13 +1584,27 @@ func (w *windowsWebviewWindow) WndProc(msg uint32, wparam, lparam uintptr) uintp
15841584
case w32.WM_DPICHANGED:
15851585
if !w.ignoreDPIChangeResizing {
15861586
newWindowRect := (*w32.RECT)(unsafe.Pointer(lparam))
1587+
flags := w32.SWP_NOZORDER | w32.SWP_NOACTIVATE
1588+
// For frameless windows, include SWP_FRAMECHANGED to trigger WM_NCCALCSIZE
1589+
// and recalculate hit-test regions for proper mouse interaction after DPI change.
1590+
// See: https://github.com/wailsapp/wails/issues/4691
1591+
if w.parent.options.Frameless {
1592+
flags |= w32.SWP_FRAMECHANGED
1593+
}
15871594
w32.SetWindowPos(w.hwnd,
15881595
uintptr(0),
15891596
int(newWindowRect.Left),
15901597
int(newWindowRect.Top),
15911598
int(newWindowRect.Right-newWindowRect.Left),
15921599
int(newWindowRect.Bottom-newWindowRect.Top),
1593-
w32.SWP_NOZORDER|w32.SWP_NOACTIVATE)
1600+
flags)
1601+
// For frameless windows with decorations, re-extend the frame into client area
1602+
// to ensure proper window frame styling after DPI change.
1603+
if w.framelessWithDecorations() {
1604+
if err := w32.ExtendFrameIntoClientArea(w.hwnd, true); err != nil {
1605+
globalApplication.handleFatalError(err)
1606+
}
1607+
}
15941608
}
15951609
w.parent.emit(events.Windows.WindowDPIChanged)
15961610
}

0 commit comments

Comments
 (0)