fix(windows): prevent mouse click-through in fullscreen for transparent windows#5195
Conversation
…nt windows When a window with both Frameless and BackgroundType (transparent) options enters fullscreen, mouse clicks pass through to underlying windows because WS_EX_LAYERED uses alpha-based hit-testing where transparent pixels don't capture events. Fix by: 1. Removing WS_EX_TRANSPARENT alongside WS_EX_DLGMODALFRAME when entering fullscreen 2. Returning HTCLIENT from WM_NCHITTEST while in fullscreen mode to force all mouse events to be captured by the window Fixes #4408
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR preserves the transparent extended window style during fullscreen and short-circuits WM_NCHITTEST to HTCLIENT while fullscreen; adds a unit test for the hit-test decision and a changelog entry noting the Frameless+Transparent fullscreen click-through fix. ChangesFullscreen Click-Through Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
WS_EX_TRANSPARENTalongsideWS_EX_DLGMODALFRAMEwhen entering fullscreen mode to prevent layered window pass-throughHTCLIENTfromWM_NCHITTESTwhile in fullscreen mode to force mouse event capture regardless of alpha-based hit-testingThe root cause: When
FramelessandBackgroundType: Transparentare both set, the window hasWS_EX_LAYEREDwhich uses alpha-based hit-testing. In fullscreen, transparent pixels (alpha=0) pass mouse events through to underlying windows. By removingWS_EX_TRANSPARENTand overridingWM_NCHITTESTto returnHTCLIENT, all mouse events are captured.Fixes #4408
Test plan
TestFullscreenNCHitTestReturnsHTClient— verifies hit-test returns HTCLIENT in fullscreen, doesn't in normal modeGOOS=windows go build ./pkg/application/— compiles cleanlyFrameless: trueandBackgroundType: application.BackgroundTypeTransparent, enter fullscreen, verify clicks are capturedSummary by CodeRabbit
Bug Fixes
Tests