Skip to content

feat(v3): add mac.DisableEscapeExitsFullscreen opt-in for fullscreen Esc#5307

Merged
leaanthony merged 1 commit into
masterfrom
agent/engineer-mac/b91b5d98
May 3, 2026
Merged

feat(v3): add mac.DisableEscapeExitsFullscreen opt-in for fullscreen Esc#5307
leaanthony merged 1 commit into
masterfrom
agent/engineer-mac/b91b5d98

Conversation

@leaanthony

@leaanthony leaanthony commented May 3, 2026

Copy link
Copy Markdown
Member

Summary

Ports DisableEscapeExitsFullscreen from v2 (PR #5242) to v3.

When Mac.DisableEscapeExitsFullscreen: true, the Escape key is swallowed while the window is fullscreen, allowing web content (modals, custom Esc handlers) to consume it. Default false preserves standard macOS behaviour (Esc exits fullscreen) for all existing apps.

Implementation

cancelOperation: override on WebviewWindow checks both the flag and NSWindowStyleMaskFullScreen before deciding whether to call [super cancelOperation:sender]:

- (void) cancelOperation:(id)sender {
    if (self.disableEscapeExitsFullscreen &&
        (self.styleMask & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) {
        return;
    }
    [super cancelOperation:sender];
}

Files changed (4, +22/-0)

File Change
v3/pkg/application/webview_window_options.go Added DisableEscapeExitsFullscreen bool to MacWindow struct
v3/pkg/application/webview_window_darwin.h Added @property BOOL disableEscapeExitsFullscreen to WebviewWindow
v3/pkg/application/webview_window_darwin.m Added cancelOperation: override
v3/pkg/application/webview_window_darwin.go Added C bridge windowSetDisableEscapeExitsFullscreen(); called at window creation when flag is true

Usage

app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
    Mac: application.MacWindow{
        // When true: Esc is swallowed while fullscreen so web content can handle it.
        // Default false → standard macOS behaviour (Esc exits fullscreen).
        DisableEscapeExitsFullscreen: true,
    },
})

Notes

  • Default false — zero breaking change for existing apps.
  • This is a 1-for-1 port of the v2 implementation (commit eaf56c932) already reviewed and merged via PR fix(v2): Prevent Esc from exiting fullscreen on macOS #5242.
  • Build verified: go build ./v3/pkg/application — clean, no errors or warnings.

Ports v2 PR #5242.

Summary by CodeRabbit

  • New Features
    • Added a new macOS configuration option to prevent the Escape key from exiting fullscreen mode, enabling custom fullscreen behavior handling on supported platforms.

Add DisableEscapeExitsFullscreen bool to MacWindow options so apps can
opt in to preventing the Escape key from exiting fullscreen mode, allowing
web content (e.g. modals with Esc-to-close behaviour) to handle Esc
without triggering the macOS system behaviour that exits the fullscreen
window.

The flag is stored as a BOOL property on WebviewWindow (the custom
NSWindow subclass) and checked in a cancelOperation: override: when the
window is fullscreen and the flag is true, the Esc keypress is swallowed;
otherwise the default macOS behaviour is preserved via [super
cancelOperation:sender].

Default false, so all existing apps are unaffected.

Ports v2 PR #5242 to v3.
Copilot AI review requested due to automatic review settings May 3, 2026 00:29
@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 62114f5a-8483-43b8-9a98-b6894994a60d

📥 Commits

Reviewing files that changed from the base of the PR and between 19398e4 and dc896f6.

📒 Files selected for processing (4)
  • v3/pkg/application/webview_window_darwin.go
  • v3/pkg/application/webview_window_darwin.h
  • v3/pkg/application/webview_window_darwin.m
  • v3/pkg/application/webview_window_options.go

Walkthrough

This PR adds the DisableEscapeExitsFullscreen feature for macOS, allowing developers to prevent the Escape key from exiting fullscreen mode. A new configuration option flows through to Objective-C where an interceptor method conditionally blocks the cancel action when fullscreen is active.

Changes

Disable Escape Exits Fullscreen (macOS)

Layer / File(s) Summary
Configuration Option
v3/pkg/application/webview_window_options.go
MacWindow gains a new DisableEscapeExitsFullscreen bool field to control the behavior.
Objective-C Property & Interface
v3/pkg/application/webview_window_darwin.h
WebviewWindow declares a new @property BOOL disableEscapeExitsFullscreen;.
Core Interception Logic
v3/pkg/application/webview_window_darwin.m
WebviewWindow overrides -cancelOperation: to suppress the Escape action when disableEscapeExitsFullscreen is enabled and the window is in fullscreen mode.
Go-to-Objective-C Bridge & Initialization
v3/pkg/application/webview_window_darwin.go
Exported C function windowSetDisableEscapeExitsFullscreen forwards the setting to the Objective-C window; macosWebviewWindow.run() calls it during startup when the option is enabled.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop, skip, and escape—not quite!
When fullscreen dreams need Escape's might,
We swallow the key, let web content play,
While macOS behavior stays out of the way.
Thumper approves this cross-layer delight! 🎹✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is comprehensive but does not follow the required template structure; it lacks a 'Fixes #' issue reference, Type of change checklist selection, How Has This Been Tested section with OS checkboxes, and the required checklist items. Add 'Fixes #' reference, select the 'New feature' checkbox, include 'How Has This Been Tested' section with OS checkboxes, and complete all required checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a new macOS-specific option to disable Escape exiting fullscreen, with concise language and no unnecessary noise.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/engineer-mac/b91b5d98

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.

❤️ Share
Review rate limit: 6/8 reviews remaining, refill in 12 minutes and 27 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in macOS window option in v3 to prevent the Escape key from exiting fullscreen, allowing web content (e.g., modals/custom handlers) to consume Esc while fullscreen, while preserving default macOS behavior for existing apps.

Changes:

  • Added MacWindow.DisableEscapeExitsFullscreen option to v3 window options.
  • Added a disableEscapeExitsFullscreen property to the WebviewWindow (NSWindow subclass) on macOS.
  • Implemented a cancelOperation: override (and Go↔ObjC bridge) to swallow Esc only when fullscreen and the option is enabled.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
v3/pkg/application/webview_window_options.go Exposes the new macOS option on MacWindow.
v3/pkg/application/webview_window_darwin.h Adds the ObjC WebviewWindow BOOL property backing the behavior.
v3/pkg/application/webview_window_darwin.m Implements cancelOperation: to conditionally swallow Esc while fullscreen.
v3/pkg/application/webview_window_darwin.go Adds cgo bridge setter and wires the option into window creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leaanthony leaanthony merged commit 712d35a into master May 3, 2026
61 checks passed
@leaanthony leaanthony deleted the agent/engineer-mac/b91b5d98 branch May 3, 2026 02:30
leaanthony pushed a commit to jes0131/wails that referenced this pull request May 3, 2026
… mac.DisableEscapeExitsFullscreen opt-in for fullscreen Esc
@coderabbitai coderabbitai Bot mentioned this pull request May 7, 2026
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants