Skip to content

feat: add webview-only transparency support for macOS#45

Open
clearlysid wants to merge 2 commits intomainfrom
feat-v2
Open

feat: add webview-only transparency support for macOS#45
clearlysid wants to merge 2 commits intomainfrom
feat-v2

Conversation

@clearlysid
Copy link
Copy Markdown
Owner

Add make_webview_transparent() method that makes only the webview background transparent while keeping the window opaque, providing more granular control over transparency.

  • Add make_webview_transparent() method to WebviewWindowExt trait
  • Implement webview-only transparency using NSView drawsBackground property
  • Update example app to demonstrate webview transparency
  • Add transparent CSS styling to showcase the effect

🤖 Generated with Claude Code

Add make_webview_transparent() method that makes only the webview background transparent while keeping the window opaque, providing more granular control over transparency.

- Add make_webview_transparent() method to WebviewWindowExt trait
- Implement webview-only transparency using NSView drawsBackground property
- Update example app to demonstrate webview transparency
- Add transparent CSS styling to showcase the effect

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@clearlysid clearlysid requested a review from Copilot July 11, 2025 14:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new API to make only the webview background transparent on macOS while keeping the window decorations opaque, and updates the example app to showcase this feature.

  • Add make_webview_transparent() to the WebviewWindowExt trait and implement it using Cocoa’s KVC.
  • Update example application’s CSS and React component to demonstrate transparent webview regions.
  • Adjust the macOS window setup in main.rs to call the new API and tweak traffic light insets.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/lib.rs Defines and implements make_webview_transparent() in the trait, disabling the webview’s drawsBackground.
examples/tauri-app/src/styles.css Sets the app background to transparent and adds .transparent-demo styles for the demo section.
examples/tauri-app/src/App.tsx Inserts a new .transparent-demo block in the UI to showcase the transparency effect.
examples/tauri-app/src-tauri/src/main.rs Wraps the traffic-light inset call in a cfg block and invokes make_webview_transparent() on macOS.
Comments suppressed due to low confidence (2)

src/lib.rs:217

  • [nitpick] The variable name id is ambiguous and shadows the Cocoa id type alias. Rename it to something like view_ptr or webview_obj for clarity.
            let id = webview.inner() as *mut objc::runtime::Object;

src/lib.rs:209

  • This new make_webview_transparent method currently has no tests. Consider adding a unit or integration test (perhaps via a headless Cocoa environment or mocking) to validate that drawsBackground is toggled as expected.
    fn make_webview_transparent(&self) -> Result<&WebviewWindow, Error> {

Comment thread src/lib.rs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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