feat: add webview-only transparency support for macOS#45
Open
clearlysid wants to merge 2 commits intomainfrom
Open
feat: add webview-only transparency support for macOS#45clearlysid wants to merge 2 commits intomainfrom
clearlysid wants to merge 2 commits intomainfrom
Conversation
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>
There was a problem hiding this comment.
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 theWebviewWindowExttrait 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.rsto 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
idis ambiguous and shadows the Cocoaidtype alias. Rename it to something likeview_ptrorwebview_objfor clarity.
let id = webview.inner() as *mut objc::runtime::Object;
src/lib.rs:209
- This new
make_webview_transparentmethod currently has no tests. Consider adding a unit or integration test (perhaps via a headless Cocoa environment or mocking) to validate thatdrawsBackgroundis toggled as expected.
fn make_webview_transparent(&self) -> Result<&WebviewWindow, Error> {
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add make_webview_transparent() method that makes only the webview background transparent while keeping the window opaque, providing more granular control over transparency.
🤖 Generated with Claude Code