fix(darwin): add DisableEscapeExitsFullscreen opt-in to mac.Options - #5310
Conversation
Add DisableEscapeExitsFullscreen bool to mac.Options so apps can opt in to preventing the Escape key from exiting fullscreen mode, rather than having the behaviour applied unconditionally to all Wails v2 apps. The flag is threaded through the C bridge (window.go → Application.h/m → WailsContext.h/m) and stored as a property on WailsWindow so that cancelOperation: can check it before deciding whether to swallow the ESC event. Default is false, preserving the existing macOS behaviour for all apps that do not set the option. Fixes #4649.
|
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 (1)
WalkthroughAdds a macOS option and threads a new flag through Go and Objective‑C code to prevent the Escape key from exiting fullscreen, and implements an Objective‑C override to respect that flag per window. ChangesEscape Fullscreen Control
Sequence Diagram(s)sequenceDiagram
participant Go as Go (window.go)
participant C as C bridge (Application)
participant ObjC as ObjC (WailsContext / WailsWindow)
participant macOS as macOS window system
Go->>C: Call C.Create(..., disableEscapeExitsFullscreen)
C->>ObjC: CreateWindow(..., disableEscapeExitsFullscreen)
ObjC->>ObjC: Assign flag to mainWindow.disableEscapeExitsFullscreen
Note over ObjC,macOS: User presses Esc while fullscreen
macOS->>ObjC: cancelOperation: triggered
ObjC-->>macOS: if flag true && fullscreen -> ignore Esc (no exit)
ObjC-->>macOS: else -> call super (default behavior)
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.11.4)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. Review rate limit: 6/8 reviews remaining, refill in 13 minutes and 36 seconds.Comment |
There was a problem hiding this comment.
Pull request overview
Adds a macOS-only, opt-in switch in Wails v2 to prevent Escape from exiting fullscreen by conditionally swallowing cancelOperation: only when configured, restoring default macOS behavior for apps that don’t need the override.
Changes:
- Added
DisableEscapeExitsFullscreentov2/pkg/options/mac.Options. - Threaded the new flag through the Go → C bridge (
Create/CreateWindow) and applied it toWailsWindowto guard thecancelOperation:override. - Updated the existing manual test documentation for issue #4649.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
v2/pkg/options/mac/mac.go |
Introduces DisableEscapeExitsFullscreen option on macOS options. |
v2/internal/frontend/desktop/darwin/window.go |
Reads the option and passes it into the C Create call. |
v2/internal/frontend/desktop/darwin/Application.h |
Extends Create(...) signature to accept the new flag. |
v2/internal/frontend/desktop/darwin/Application.m |
Passes the new flag through to WailsContext CreateWindow. |
v2/internal/frontend/desktop/darwin/WailsContext.h |
Adds WailsWindow.disableEscapeExitsFullscreen and extends CreateWindow signature. |
v2/internal/frontend/desktop/darwin/WailsContext.m |
Guards cancelOperation: behavior based on the new flag and fullscreen state; assigns the flag to the window. |
v2/test/4649/test_esc_fullscreen.go |
Manual test guidance updates for the new opt-in behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…add `DisableEscapeExitsFullscreen` opt-in to `mac.Options`
fix(darwin): add
DisableEscapeExitsFullscreenopt-in tomac.OptionsPR #5242 overrides
cancelOperation:inWailsWindowunconditionally,which means Escape can never exit fullscreen for any Wails v2 app — even
ones that don't need that behaviour. This PR refactors the override to
be opt-in via a new Mac-only option.
What changed
v2/pkg/options/mac/mac.gov2/internal/frontend/desktop/darwin/WailsContext.m—cancelOperation:is guarded:The flag is threaded through the C bridge:
window.go→Application.h/.m(Create()signature) →WailsContext.h/.m(CreateWindow:signature +WailsWindowproperty).Behaviour
DisableEscapeExitsFullscreen: false(default)DisableEscapeExitsFullscreen: truekeydownhandlers still fireUsage
Files
v2/pkg/options/mac/mac.go— new option fieldv2/internal/frontend/desktop/darwin/window.go— read + pass to Cv2/internal/frontend/desktop/darwin/Application.h/.m— updatedCreate()signaturev2/internal/frontend/desktop/darwin/WailsContext.h/.m—WailsWindowproperty, conditional guard, updatedCreateWindow:signaturev2/test/4649/test_esc_fullscreen.go— updated test docsCloses #4649
Supersedes #5242
Summary by CodeRabbit
New Features
Tests