Skip to content

Content Privacy flag for Windows and MacOS #4241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

Taiterbase
Copy link

@Taiterbase Taiterbase commented Apr 25, 2025

Description

Adds content protection to Windows and MacOS Wails applications.

Implements feature request #4240

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

MacOS

A Wails test application was made with ContentProtection set to true, and screen recording software was run capturing the entire screen.
When the flag was set to true, the window application was hidden from screen capturing, like screen sharing in Google Meets, OBS, Zoom, and Mac's screenshotting tool.
When the flag was set to false or unset, the window application was visible in all the above softwares.

Windows

Not tested yet.

Linux

No solution for Linux yet.

  • Windows
  • macOS
  • Linux

There is no Linux solution yet.

Test Configuration

# Wails
Version | v2.10.1


# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | MacOS                                                                                                                       |
| Version      | 15.3.2                                                                                                                      |
| ID           | 24D81                                                                                                                       |
| Go Version   | go1.24.2                                                                                                                    |
| Platform     | darwin                                                                                                                      |
| Architecture | arm64                                                                                                                       |
| CPU 1        | Apple M1 Max                                                                                                                |
| CPU 2        | Apple M1 Max                                                                                                                |
| GPU          | Chipset Model: Apple M1 Max Type: GPU Bus: Built-In Total Number of Cores: 32 Vendor: Apple (0x106b) Metal Support: Metal 3 |
| Memory       | 32GB                                                                                                                        |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────┐
| Dependency                | Package Name | Status    | Version       |
| Xcode command line tools  | N/A          | Installed | 2409          |
| Nodejs                    | N/A          | Installed | 22.14.0       |
| npm                       | N/A          | Installed | 10.9.2        |
| *Xcode                    | N/A          | Installed | 16.3 (16E140) |
| *upx                      | N/A          | Available |               |
| *nsis                     | N/A          | Available |               |
|                                                                      |
└────────────────────── * - Optional Dependency ───────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Introduced a new ContentProtection option for Windows and Mac, allowing users to prevent application windows from being captured by screen sharing or recording software.
  • Documentation

    • Updated the changelog and reference documentation to include details and usage instructions for the new ContentProtection option on both Windows and Mac platforms.

Copy link
Contributor

coderabbitai bot commented Apr 25, 2025

Walkthrough

This change introduces a new ContentProtection option for both Windows and MacOS platforms. It updates platform-specific option structs to include a boolean ContentProtection field, modifies window creation logic to apply content protection settings, and adds OS-specific implementations to prevent window content from being captured by screen recording or sharing software. Documentation and changelog entries are updated to reflect the new feature, and new helper functions and methods are added for controlling window display affinity on Windows and window sharing type on MacOS.

Changes

Files/Paths Change Summary
v2/pkg/options/mac/mac.go
v2/pkg/options/windows/windows.go
Added ContentProtection boolean field to Mac and Windows options structs.
v2/internal/frontend/desktop/darwin/Application.h
v2/internal/frontend/desktop/darwin/Application.m
Updated Create function signature to include contentProtection parameter; on MacOS, sets window sharing type if enabled.
v2/internal/frontend/desktop/darwin/window.go Passes contentProtection flag from frontend options to the native window creation function on MacOS.
v2/internal/frontend/desktop/windows/winc/w32/wda.go New file: Implements SetWindowDisplayAffinity for controlling window capture on Windows, including Windows version checks.
v2/internal/frontend/desktop/windows/winc/controlbase.go Added SetContentProtection(enable bool) method to set window display affinity for content protection.
v2/internal/frontend/desktop/windows/window.go Applies content protection by calling SetWindowDisplayAffinity if the option is enabled in Windows options.
website/docs/reference/options.mdx Updated documentation to describe the new ContentProtection option for Mac and Windows, with usage details and examples.
website/src/pages/changelog.mdx Added changelog entry for the new ContentProtection feature, referencing the relevant PR and contributor.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant Options as Platform Options
    participant Window as OS Window
    participant OS as Operating System

    App->>Options: Read ContentProtection flag
    App->>Window: Create window with ContentProtection option
    alt On MacOS
        Window->>OS: Set NSWindow sharingType to NSWindowSharingNone if ContentProtection enabled
    else On Windows
        Window->>OS: Call SetWindowDisplayAffinity with WDA_EXCLUDEFROMCAPTURE if ContentProtection enabled
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Add a boolean ContentProtection flag to Windows and Mac options structs (#4240)
If ContentProtection is true, hide window from screen recording/sharing on Windows and MacOS (#4240)
Default behavior: window is shown normally if ContentProtection is unset or false (#4240)

Suggested labels

awaiting feedback

Suggested reviewers

  • leaanthony

Poem

A secret window, hidden from sight,
Protected from capture, both day and night.
Mac and Windows now keep things unseen,
With a flag so simple, yet powers so keen.
🐇✨
Now share your screen with peace of mind—
Your private apps, the world won’t find!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12244fd and 174dfec.

📒 Files selected for processing (1)
  • website/src/pages/changelog.mdx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • website/src/pages/changelog.mdx

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Taiterbase Taiterbase marked this pull request as ready for review April 25, 2025 23:17
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (1)
v2/examples/privatewindow/go.mod (1)

1-38: ⚠️ Potential issue

Use Fully-Qualified Module Path
Defining the module as simply privatewindow can lead to resolution conflicts. Per Go best practices, update the module directive to your repository path, for example:

module github.com/wailsapp/wails/v2/examples/privatewindow

This ensures correct module resolution and avoids ambiguity.

🧹 Nitpick comments (12)
v2/internal/frontend/desktop/windows/winc/w32/w32.go (1)

18-24: Consider enhancing error handling in the Windows API wrapper

The function ignores the error returned by the syscall, which is common for Windows API wrappers but could be improved for better diagnostics.

-func SetWindowDisplayAffinity(hwnd uintptr, affinity uint32) bool {
-	ret, _, _ := procSetWindowDisplayAffinity.Call(
+func SetWindowDisplayAffinity(hwnd uintptr, affinity uint32) (bool, error) {
+	ret, _, err := procSetWindowDisplayAffinity.Call(
		hwnd,
		uintptr(affinity),
	)
-	return ret != 0
+	// Windows syscall errors are only meaningful when the call fails
+	if ret == 0 {
+		return false, err
+	}
+	return true, nil
}
v2/examples/privatewindow/frontend/package.json (1)

1-13: Consider updating Vite for better security and features.

The package.json file is correctly configured for a basic Vite application. However, Vite v3.0.7 is quite outdated (current version is v5.x). Consider updating to a more recent version for security patches and improved features.

  "devDependencies": {
-    "vite": "^3.0.7"
+    "vite": "^5.0.0"
  }
v2/examples/privatewindow/README.md (1)

1-12: Consider adding more context about the ContentPrivacy option

The README provides clear steps to test the feature, but could benefit from a brief explanation of what the ContentPrivacy option is and how it works (e.g., explaining that it prevents window contents from being captured during screen recording).

 # README

 This is an example application showcasing the ContentPrivacy option.
+
+The ContentPrivacy option allows an application window to be hidden from screen recording and sharing software. When enabled, the window's contents won't appear in screenshots, screen recordings, or screen sharing applications, providing enhanced privacy for sensitive information.

 1. `wails build`
 2. run the new binary in `./build/bin/`
 3. start screen recording software (Google Meet, Zoom, OBS, native screen recording software)
 4. the window won't appear during capture

 This works with many screen recording software applications. If Zoom still shows the application, 
 this option will need to be selected for it to respect window filtering. `Settings > Share Screen > Advanced > Screen capture mode > Advanced capture with window filtering`
v2/examples/privatewindow/main.go (1)

33-38: Consider adding a comment explaining the ContentProtection flag.

The content protection feature is correctly enabled for both macOS and Windows. However, adding a brief comment explaining what this flag does would improve code clarity and assist future developers.

		Mac: &mac.Options{
+			// Prevents the window from being captured in screenshots and recordings
			ContentProtection: true,
		},
		Windows: &windows.Options{
+			// Prevents the window from being captured in screenshots and recordings
			ContentProtection: true,
		},
v2/examples/privatewindow/frontend/src/app.css (1)

1-54: Improve Accessibility and Theming Support
The stylesheet covers core UI elements well. To enhance usability and maintainability:

  • Add focus outlines for .btn and .input to support keyboard navigation.
  • Introduce CSS variables for colors (e.g., --btn-bg, --input-bg) to simplify theming and future updates.
  • Verify hover gradient and text color meet WCAG contrast ratios.
  • Consider :disabled and :active states for buttons if needed.
v2/examples/privatewindow/app.go (1)

1-28: Backend App Structure Is Correct
The App, NewApp, startup, and Greet methods align with Wails conventions. A couple of optional improvements:

  • Document the startup method’s role in initializing runtime hooks for new contributors.
  • Consider initializing ctx in NewApp (e.g., ctx: context.Background()) to prevent potential nil-context usage before startup is called.
v2/examples/privatewindow/build/README.md (3)

7-9: Consider using consistent list markers.

The unordered lists in this document use dashes (-) in some places and asterisks (*) in others. For better markdown consistency, consider using the same list marker style throughout the document.

-* bin - Output directory
-* darwin - macOS specific files
-* windows - Windows specific files
+- bin - Output directory
+- darwin - macOS specific files
+- windows - Windows specific files

21-21: Add missing comma in the sentence.

For better readability, add a comma before "but" in this sentence.

-- `Info.dev.plist` - same as the main plist file but used when building using `wails dev`.
+- `Info.dev.plist` - same as the main plist file, but used when building using `wails dev`.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~21-~21: Possible missing comma found.
Context: ...dev.plist- same as the main plist file but used when building usingwails dev`. ...

(AI_HYDRA_LEO_MISSING_COMMA)

🪛 markdownlint-cli2 (0.17.2)

21-21: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)


34-34: Add hyphen to "right-click".

"Right-click" should be hyphenated when used as a verb.

-  as well as the application itself (right click the exe -> properties -> details)
+  as well as the application itself (right-click the exe -> properties -> details)
🧰 Tools
🪛 LanguageTool

[grammar] ~34-~34: The verb “right-click” is spelled with a hyphen.
Context: ...r, as well as the application itself (right click the exe -> properties -> details) - `wa...

(CLICK_HYPHEN)

v2/examples/privatewindow/build/windows/installer/project.nsi (1)

69-71: Signing capabilities are ready for implementation.

The script includes commented-out commands for signing both the installer and uninstaller. Consider implementing code signing for production builds to improve security and user trust.

Would you like help with implementing the code signing process for your Windows installer?

v2/examples/privatewindow/frontend/wailsjs/runtime/runtime.js (2)

55-58: Use the canonical Array.prototype.slice.call(arguments) idiom
[eventName].slice.call(arguments) works but is unnecessarily obscure and allocates a throw-away array just to fetch the slice function. Prefer the standard, self-documenting form:

-    let args = [eventName].slice.call(arguments);
+    const args = Array.prototype.slice.call(arguments);

(No behavioural change, slightly less GC churn and easier to read.)


221-223: Default useDropTarget when omitted
OnFileDrop forwards useDropTarget verbatim; when callers omit it the value becomes undefined, which may differ from the intended default true. A safe default keeps the public API predictable:

-export function OnFileDrop(callback, useDropTarget) {
-    return window.runtime.OnFileDrop(callback, useDropTarget);
+export function OnFileDrop(callback, useDropTarget = true) {
+    return window.runtime.OnFileDrop(callback, useDropTarget);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4788263 and d2b2288.

⛔ Files ignored due to path filters (5)
  • v2/examples/privatewindow/build/appicon.png is excluded by !**/*.png
  • v2/examples/privatewindow/build/windows/icon.ico is excluded by !**/*.ico
  • v2/examples/privatewindow/frontend/src/assets/fonts/nunito-v16-latin-regular.woff2 is excluded by !**/*.woff2
  • v2/examples/privatewindow/frontend/src/assets/images/logo-universal.png is excluded by !**/*.png
  • v2/examples/privatewindow/go.sum is excluded by !**/*.sum
📒 Files selected for processing (33)
  • v2/examples/privatewindow/.gitignore (1 hunks)
  • v2/examples/privatewindow/README.md (1 hunks)
  • v2/examples/privatewindow/app.go (1 hunks)
  • v2/examples/privatewindow/build/README.md (1 hunks)
  • v2/examples/privatewindow/build/darwin/Info.dev.plist (1 hunks)
  • v2/examples/privatewindow/build/darwin/Info.plist (1 hunks)
  • v2/examples/privatewindow/build/windows/info.json (1 hunks)
  • v2/examples/privatewindow/build/windows/installer/project.nsi (1 hunks)
  • v2/examples/privatewindow/build/windows/installer/wails_tools.nsh (1 hunks)
  • v2/examples/privatewindow/build/windows/wails.exe.manifest (1 hunks)
  • v2/examples/privatewindow/frontend/index.html (1 hunks)
  • v2/examples/privatewindow/frontend/package.json (1 hunks)
  • v2/examples/privatewindow/frontend/src/app.css (1 hunks)
  • v2/examples/privatewindow/frontend/src/assets/fonts/OFL.txt (1 hunks)
  • v2/examples/privatewindow/frontend/src/main.js (1 hunks)
  • v2/examples/privatewindow/frontend/src/style.css (1 hunks)
  • v2/examples/privatewindow/frontend/wailsjs/go/main/App.d.ts (1 hunks)
  • v2/examples/privatewindow/frontend/wailsjs/go/main/App.js (1 hunks)
  • v2/examples/privatewindow/frontend/wailsjs/runtime/package.json (1 hunks)
  • v2/examples/privatewindow/frontend/wailsjs/runtime/runtime.d.ts (1 hunks)
  • v2/examples/privatewindow/frontend/wailsjs/runtime/runtime.js (1 hunks)
  • v2/examples/privatewindow/go.mod (1 hunks)
  • v2/examples/privatewindow/main.go (1 hunks)
  • v2/examples/privatewindow/wails.json (1 hunks)
  • v2/internal/frontend/desktop/darwin/Application.h (1 hunks)
  • v2/internal/frontend/desktop/darwin/Application.m (2 hunks)
  • v2/internal/frontend/desktop/darwin/window.go (2 hunks)
  • v2/internal/frontend/desktop/windows/winc/controlbase.go (1 hunks)
  • v2/internal/frontend/desktop/windows/winc/w32/w32.go (1 hunks)
  • v2/internal/frontend/desktop/windows/window.go (1 hunks)
  • v2/pkg/options/mac/mac.go (1 hunks)
  • v2/pkg/options/windows/windows.go (1 hunks)
  • website/src/pages/changelog.mdx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (8)
v2/internal/frontend/desktop/windows/window.go (1)
v2/internal/frontend/desktop/windows/winc/w32/w32.go (2)
  • SetWindowDisplayAffinity (18-24)
  • WDA_EXCLUDEFROMCAPTURE (15-15)
v2/examples/privatewindow/frontend/wailsjs/go/main/App.d.ts (1)
v2/examples/privatewindow/frontend/wailsjs/go/main/App.js (1)
  • Greet (5-7)
v2/internal/frontend/desktop/darwin/window.go (1)
v2/internal/frontend/desktop/darwin/Application.h (1)
  • Create (20-20)
v2/examples/privatewindow/main.go (2)
v2/examples/privatewindow/app.go (2)
  • NewApp (14-16)
  • App (9-11)
v2/pkg/options/options.go (1)
  • RGBA (108-113)
v2/internal/frontend/desktop/windows/winc/controlbase.go (1)
v2/internal/frontend/desktop/windows/winc/w32/w32.go (3)
  • SetWindowDisplayAffinity (18-24)
  • WDA_EXCLUDEFROMCAPTURE (15-15)
  • WDA_NONE (13-13)
v2/examples/privatewindow/frontend/src/main.js (1)
v2/examples/privatewindow/frontend/wailsjs/go/main/App.js (1)
  • Greet (5-7)
v2/examples/privatewindow/app.go (1)
v2/examples/privatewindow/frontend/wailsjs/go/main/App.js (1)
  • Greet (5-7)
v2/examples/privatewindow/frontend/wailsjs/runtime/runtime.d.ts (4)
v2/examples/privatewindow/frontend/wailsjs/runtime/runtime.js (52)
  • EventsEmit (55-58)
  • EventsOn (43-45)
  • EventsOnMultiple (39-41)
  • EventsOnce (51-53)
  • EventsOff (47-49)
  • LogPrint (11-13)
  • LogTrace (15-17)
  • LogDebug (19-21)
  • LogError (31-33)
  • LogFatal (35-37)
  • LogInfo (23-25)
  • LogWarning (27-29)
  • WindowReload (60-62)
  • WindowReloadApp (64-66)
  • WindowSetAlwaysOnTop (68-70)
  • WindowSetSystemDefaultTheme (72-74)
  • WindowSetLightTheme (76-78)
  • WindowSetDarkTheme (80-82)
  • WindowCenter (84-86)
  • WindowSetTitle (88-90)
  • WindowFullscreen (92-94)
  • WindowUnfullscreen (96-98)
  • WindowIsFullscreen (100-102)
  • WindowSetSize (108-110)
  • WindowGetSize (104-106)
  • WindowSetMaxSize (112-114)
  • WindowSetMinSize (116-118)
  • WindowSetPosition (120-122)
  • WindowGetPosition (124-126)
  • WindowHide (128-130)
  • WindowShow (132-134)
  • WindowMaximise (136-138)
  • WindowToggleMaximise (140-142)
  • WindowUnmaximise (144-146)
  • WindowIsMaximised (148-150)
  • WindowMinimise (152-154)
  • WindowUnminimise (156-158)
  • WindowIsMinimised (168-170)
  • WindowIsNormal (172-174)
  • WindowSetBackgroundColour (160-162)
  • ScreenGetAll (164-166)
  • BrowserOpenURL (176-178)
  • Environment (180-182)
  • Quit (184-186)
  • Hide (188-190)
  • Show (192-194)
  • ClipboardGetText (196-198)
  • ClipboardSetText (200-202)
  • OnFileDrop (221-223)
  • OnFileDropOff (228-230)
  • CanResolveFilePaths (232-234)
  • ResolveFilePaths (236-238)
v2/internal/frontend/runtime/desktop/events.js (1)
  • data (105-105)
v2/internal/binding/generate_test.go (1)
  • B (22-24)
v2/internal/frontend/runtime/desktop/draganddrop.js (1)
  • files (136-136)
🪛 LanguageTool
v2/examples/privatewindow/frontend/src/assets/fonts/OFL.txt

[typographical] ~9-~9: If you want to indicate numerical ranges or time ranges, consider using an en dash.
Context: ...------ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 -----------------------...

(DASH_RULE)

v2/examples/privatewindow/build/README.md

[uncategorized] ~21-~21: Possible missing comma found.
Context: ...dev.plist- same as the main plist file but used when building usingwails dev`. ...

(AI_HYDRA_LEO_MISSING_COMMA)


[grammar] ~34-~34: The verb “right-click” is spelled with a hyphen.
Context: ...r, as well as the application itself (right click the exe -> properties -> details) - `wa...

(CLICK_HYPHEN)

🪛 markdownlint-cli2 (0.17.2)
v2/examples/privatewindow/build/README.md

20-20: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)


21-21: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)


29-29: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)


32-32: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)


33-33: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)


35-35: Unordered list style
Expected: asterisk; Actual: dash

(MD004, ul-style)

🔇 Additional comments (39)
v2/examples/privatewindow/frontend/wailsjs/runtime/package.json (1)

1-24: LGTM: Package configuration is properly defined

The package.json file for the Wails JavaScript runtime is well-structured with appropriate metadata for the package. It includes all necessary fields like name, version, description, entry points, repository information, and licensing.

v2/internal/frontend/desktop/windows/winc/w32/w32.go (3)

1-2: LGTM: Appropriate build tag for Windows-specific code

The build tag ensures this code only compiles on Windows platforms, which is correct for Windows API functionality.


9-10: LGTM: Proper Windows API function loading

Correctly loads the user32.dll library and retrieves the SetWindowDisplayAffinity procedure.


12-16: LGTM: Well-defined Windows API constants

Constants are properly defined with their correct hex values. The comment about Windows 10 2004+ compatibility for WDA_EXCLUDEFROMCAPTURE is helpful.

v2/examples/privatewindow/.gitignore (1)

1-3: LGTM: Appropriate .gitignore entries

The .gitignore file correctly excludes build artifacts and dependency directories that shouldn't be committed to version control.

v2/pkg/options/windows/windows.go (1)

64-64: LGTM: ContentProtection option added to Windows options

The new ContentProtection boolean field is correctly integrated into the Windows Options struct, aligning with the PR's objective to add content privacy features.

Consider adding a documentation comment to explain the purpose and behavior of this option, similar to other fields in this struct.

+// ContentProtection when set to true prevents the window from being captured or recorded
+// by screen recording software on Windows 10 version 2004 and later.
 ContentProtection    bool
v2/examples/privatewindow/frontend/wailsjs/go/main/App.js (1)

1-8: LGTM!

This is a correctly auto-generated Wails binding file that provides the JavaScript interface to the Go backend's Greet function. No issues to report.

v2/examples/privatewindow/frontend/index.html (1)

1-12: LGTM!

The HTML structure is correct and properly configured with appropriate meta tags, viewport settings, and the application mount point. The script tag correctly loads the main module.

v2/internal/frontend/desktop/darwin/window.go (3)

66-66: LGTM!

The declaration of the contentProtection variable alongside other window configuration variables is properly implemented, following the existing pattern in the codebase.


120-120: LGTM!

Correctly implementing the ContentProtection feature by converting the boolean flag to C integer format using the existing bool2Cint helper function.


126-126: LGTM!

The contentProtection parameter is properly passed to the C.Create function, maintaining consistency with how other window configuration parameters are handled.

Based on the provided context from Application.h, this implementation will correctly set the appropriate window sharing type on macOS to prevent screen recording/capture when the flag is enabled.

v2/internal/frontend/desktop/windows/winc/controlbase.go (1)

173-179: LGTM: Content protection implementation for Windows

The implementation correctly leverages the Windows API to enable/disable screen capture protection by setting the appropriate window display affinity. When enabled, the window will be excluded from screen captures using the WDA_EXCLUDEFROMCAPTURE flag, and when disabled, it reverts to normal behavior with WDA_NONE.

v2/examples/privatewindow/frontend/src/style.css (1)

1-26: LGTM: Well-structured CSS for the example application

The CSS provides a clean, modern styling foundation for the example application with appropriate contrast, font loading, and layout.

v2/examples/privatewindow/wails.json (1)

1-13: LGTM: Well-configured example project

The wails.json configuration file includes all the necessary settings for the example application, including proper schema reference, naming, build commands, and author information.

v2/examples/privatewindow/build/windows/info.json (1)

1-15: Well-structured Windows application metadata template.

The JSON configuration correctly defines Windows executable metadata with appropriate template variables that will be substituted during the build process.

v2/examples/privatewindow/build/windows/wails.exe.manifest (1)

1-15: Well-configured Windows application manifest.

The manifest correctly sets up assembly identity, dependencies, and DPI awareness. Good practice providing both legacy and modern DPI settings for cross-version Windows compatibility.

v2/examples/privatewindow/build/darwin/Info.dev.plist (1)

1-69: Development Info.plist Template Looks Solid
The plist follows Apple’s recommended structure and includes required metadata placeholders. No critical issues found.

  • Optionally, add a NSPrincipalClass key if you need a custom AppDelegate.
v2/examples/privatewindow/build/darwin/Info.plist (1)

1-64: Production Info.plist Template Is Well-Formed
This template mirrors the development version with dynamic placeholders. It’s ready for production use.

  • Verify that your CFBundleShortVersionString and CFBundleVersion align with App Store or distribution guidelines if you plan to publish.
v2/examples/privatewindow/frontend/src/assets/fonts/OFL.txt (1)

1-93: License file looks good.

This is a standard SIL Open Font License Version 1.1 file for the Nunito font. Including this license file is necessary for proper compliance when distributing the font with your application.

🧰 Tools
🪛 LanguageTool

[typographical] ~9-~9: If you want to indicate numerical ranges or time ranges, consider using an en dash.
Context: ...------ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 -----------------------...

(DASH_RULE)

v2/internal/frontend/desktop/darwin/Application.h (1)

20-20:

✅ Verification successful

Function signature updated correctly with the new content protection parameter.

The Create function signature has been appropriately modified to include the new contentProtection parameter, which implements the window content privacy feature for macOS. The parameter is correctly typed as int for boolean representation (0 for false, non-zero for true) and positioned logically before the existing devtoolsEnabled parameter.

The rename from singleInstanceEnabled to singleInstanceLockEnabled also improves clarity.


🏁 Script executed:

#!/bin/bash
# Check if this parameter is used correctly in the implementation file
grep -n "contentProtection" v2/internal/frontend/desktop/darwin/Application.m

Length of output: 851


Approve changes: contentProtection integrated and implemented correctly

Verified that the Create signature in v2/internal/frontend/desktop/darwin/Application.h includes the new int contentProtection parameter in the expected position, and that it is used appropriately in v2/internal/frontend/desktop/darwin/Application.m (line 34). The rename from singleInstanceEnabled to singleInstanceLockEnabled is also clear and consistent.

v2/examples/privatewindow/build/windows/installer/project.nsi (1)

1-114: The NSIS installer script looks well-structured and complete.

The script provides a complete installation process for the Windows application with proper architecture detection, WebView2 runtime installation, file association handling, and uninstallation capabilities. It correctly leverages shared functionality from the wails_tools.nsh include file and provides commented sections for future enhancements like code signing and EULA inclusion.

v2/internal/frontend/desktop/darwin/Application.m (1)

17-17:

✅ Verification successful

Confirm downstream prototype updates after parameter insertion
contentProtection was inserted into the Create parameter list between windowIsTranslucent and devtoolsEnabled. Please double-check that:

  1. Application.h was changed consistently (looks to be the case from the PR description).
  2. All CGO invocations that marshal arguments from Go into this function were regenerated – otherwise every subsequent argument will shift and you’ll see hard-to-trace UI bugs (e.g. devtoolsEnabled suddenly becomes the window’s start-state).
    If the Go side is still calling the pre-existing signature, a build will succeed but runtime behaviour will be corrupted.

🏁 Script executed:

#!/bin/bash
# List Objective-C symbols to ensure the new symbol length matches Go imports
rg --files-with-matches -t go -N 'Create(' | xargs -I{} sed -n '1,120p' {} | head

Length of output: 150


Let’s retry finding the CGO calls with a correctly escaped regex:


🏁 Script executed:

#!/bin/bash
# Search for CGO invocations of the Create function in Go code
rg -n 'C\.Create\(' --color never

Length of output: 208


Let’s inspect the full C.Create call to ensure the new contentProtection arg is present in the correct position:


🏁 Script executed:

#!/bin/bash
# Show the full CGO Create invocation around line 124
sed -n '118,140p' v2/internal/frontend/desktop/darwin/window.go

Length of output: 1243


Let’s verify that the Create prototype in Application.h was updated to include contentProtection:


🏁 Script executed:

#!/bin/bash
# Show the Create signature in Application.h to confirm the new parameter order
sed -n '1,200p' v2/internal/frontend/desktop/darwin/Application.h | grep -n 'Create('

Length of output: 821


CGO Create invocation correctly updated with new contentProtection parameter
All occurrences of the Create call have been updated to match the revised Objective-C signature:

• Application.h now declares contentProtection between windowIsTranslucent and devtoolsEnabled.
• window.go’s C.Create(...) invocation includes contentProtection in the same position.

No further changes required.

v2/examples/privatewindow/build/windows/installer/wails_tools.nsh (1)

181-203: Auto-generated installer script – no manual changes necessary
The NSIS macros match the patterns generated by wails build. Unless you intend to maintain this file by hand, keeping it verbatim avoids merge conflicts on future wails build runs.

v2/examples/privatewindow/frontend/wailsjs/runtime/runtime.d.ts (12)

1-9: Approve file header
The ASCII art banner and copyright notice are clear and informative.


11-33: Interface declarations are well-defined
Position, Size, Screen, and EnvironmentInfo capture the required window and environment metadata.


35-57: Event API typings look correct
All event-related functions (EventsEmit, EventsOn, EventsOnMultiple, EventsOnce, EventsOff, EventsOffAll) align with the patterns in runtime.js.


59-87: Logging function signatures are accurate
Each log level (LogPrint, LogTrace, LogDebug, LogInfo, LogWarning, LogError, LogFatal) accepts a single string argument as expected.


88-114: Window reload and theme functions
WindowReload, WindowReloadApp, and the theme setters (WindowSetSystemDefaultTheme, WindowSetLightTheme, WindowSetDarkTheme) match the documented runtime behaviors.


115-134: Fullscreen and sizing methods are correct
WindowCenter, WindowSetTitle, WindowFullscreen, WindowUnfullscreen, and WindowIsFullscreen have appropriate parameter and return types.


135-202: Comprehensive window management API
All methods for resizing, positioning, maximising/minimising, background colour, and state queries appear consistent with their JavaScript counterparts.


201-211: Screen enumeration and browser API
ScreenGetAll returning Promise<Screen[]> and BrowserOpenURL are correctly typed.


213-227: Environment & lifecycle functions
Environment, Quit, Hide, and Show signatures align with the expected runtime methods.


229-236: Clipboard API types
ClipboardGetText(): Promise<string> and ClipboardSetText(text: string): Promise<boolean> accurately reflect asynchronous clipboard operations.


237-244: Drag-and-drop typings
OnFileDrop callback signature including (x, y, paths) and OnFileDropOff void return type are correct.


245-249: Verify file resolution return type
CanResolveFilePaths() returning boolean is sensible, but ResolveFilePaths(files: File[]): void may not match the actual implementation (it likely returns resolved paths or a promise). Please confirm and update the return type to Promise<string[]> or the appropriate type.

v2/pkg/options/mac/mac.go (1)

21-21: LGTM: Added ContentProtection option for macOS

The addition of the ContentProtection boolean field to the macOS options struct allows for preventing application windows from being captured by screen recording software. This implementation aligns with the Windows implementation and provides a consistent cross-platform API.

website/src/pages/changelog.mdx (1)

29-29: LGTM: Well-documented changelog entry

The changelog entry clearly describes the new feature, its purpose, and attributes the contribution appropriately. This maintains a good documentation trail for users upgrading to this version.

v2/internal/frontend/desktop/windows/window.go (1)

134-136: LGTM: Proper implementation of content protection for Windows

The implementation correctly uses the Windows API SetWindowDisplayAffinity with the WDA_EXCLUDEFROMCAPTURE flag to prevent the window content from being captured by screen recording software. This is placed in a logical location in the window creation flow, after handling translucency options and before handling window icon options.

v2/examples/privatewindow/frontend/wailsjs/go/main/App.d.ts (1)

1-4: LGTM: Auto-generated TypeScript declarations for the example app

This auto-generated TypeScript declaration file provides type safety for frontend calls to the backend Greet method, which is part of the example application demonstrating the content protection feature.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
website/docs/reference/options.mdx (2)

618-628: Good documentation for the new ContentProtection feature

The documentation clearly explains the purpose and behavior of the ContentProtection option for Windows, including the different behaviors based on Windows versions.

However, there are a couple of minor formatting issues to fix:

-On Windows it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`. 
-For Windows 10 version 2004 and later the window will be completely removed from capture. 
+On Windows, it calls SetWindowDisplayAffinity with `WDA_EXCLUDEFROMCAPTURE`. 
+For Windows 10 version 2004 and later, the window will be completely removed from capture. 
🧰 Tools
🪛 LanguageTool

[typographical] ~622-~622: It is considered good style to insert a comma after introductory phrases with dates or proper nouns.
Context: ...ing captured by other applications. On Windows it calls SetWindowDisplayAffinity with ...

(IN_NNP_COMMA)


[uncategorized] ~623-~623: A comma might be missing here.
Context: ...TURE`. For Windows 10 version 2004 and later the window will be completely removed f...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


939-947: Correct macOS spelling in ContentProtection documentation

The documentation clearly explains the purpose and behavior of the ContentProtection option for macOS.

There's a small spelling issue to correct:

-On MacOS it sets the NSWindow's sharingType to NSWindowSharingNone, removing the window from capture entirely. 
+On macOS, it sets the NSWindow's sharingType to NSWindowSharingNone, removing the window from capture entirely. 
🧰 Tools
🪛 LanguageTool

[grammar] ~943-~943: The operating system from Apple is written “macOS”.
Context: ...ing captured by other applications. On MacOS it sets the NSWindow's sharingType to N...

(MAC_OS)

v2/internal/frontend/desktop/windows/winc/w32/wda.go (1)

37-47: Properly implemented fallback mechanism for compatibility

The SetWindowDisplayAffinity function correctly handles version compatibility by falling back to WDA_MONITOR on older Windows versions that don't support WDA_EXCLUDEFROMCAPTURE.

However, consider adding error handling for the Windows API call:

-	ret, _, _ := procSetWindowDisplayAffinity.Call(
+	ret, _, err := procSetWindowDisplayAffinity.Call(
 		hwnd,
 		uintptr(affinity),
 	)
+	if ret == 0 {
+		// log.Debug("SetWindowDisplayAffinity failed:", err)
+	}
 	return ret != 0
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2b2288 and 303e071.

📒 Files selected for processing (2)
  • v2/internal/frontend/desktop/windows/winc/w32/wda.go (1 hunks)
  • website/docs/reference/options.mdx (4 hunks)
🧰 Additional context used
🪛 LanguageTool
website/docs/reference/options.mdx

[typographical] ~622-~622: It is considered good style to insert a comma after introductory phrases with dates or proper nouns.
Context: ...ing captured by other applications. On Windows it calls SetWindowDisplayAffinity with ...

(IN_NNP_COMMA)


[uncategorized] ~623-~623: A comma might be missing here.
Context: ...TURE`. For Windows 10 version 2004 and later the window will be completely removed f...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[grammar] ~943-~943: The operating system from Apple is written “macOS”.
Context: ...ing captured by other applications. On MacOS it sets the NSWindow's sharingType to N...

(MAC_OS)

🔇 Additional comments (6)
website/docs/reference/options.mdx (2)

76-76: Proper default value for ContentProtection option

The default value of false for the ContentProtection option is appropriate as this maintains backward compatibility with existing applications.


121-121: Consistent implementation across platforms

Good job maintaining consistent option naming and default value across both Windows and macOS platforms.

v2/internal/frontend/desktop/windows/winc/w32/wda.go (4)

11-14: Well-structured Windows API integration

The code correctly sets up access to the Windows API function and retrieves the Windows version information at package initialization time.


15-19: Good constant definitions with clear comments

The constants are well-defined with appropriate values. The comment for WDA_EXCLUDEFROMCAPTURE helpfully indicates this is for Windows 10 2004 and newer versions.


21-35: Robust version checking implementation

The isWindowsVersionAtLeast function is well-implemented, correctly handling major, minor, and build number comparisons in the proper order.


1-9: Proper build constraints and imports

The build constraint ensures this code is only compiled on Windows platforms, and the imports are correctly specified.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
44.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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.

1 participant