-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: master
Are you sure you want to change the base?
Content Privacy flag for Windows and MacOS #4241
Conversation
WalkthroughThis change introduces a new Changes
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
Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 issueUse Fully-Qualified Module Path
Defining the module as simplyprivatewindow
can lead to resolution conflicts. Per Go best practices, update themodule
directive to your repository path, for example:module github.com/wailsapp/wails/v2/examples/privatewindowThis 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 wrapperThe 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 optionThe 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
TheApp
,NewApp
,startup
, andGreet
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
inNewApp
(e.g.,ctx: context.Background()
) to prevent potential nil-context usage beforestartup
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 using
wails 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 canonicalArray.prototype.slice.call(arguments)
idiom
[eventName].slice.call(arguments)
works but is unnecessarily obscure and allocates a throw-away array just to fetch theslice
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
: DefaultuseDropTarget
when omitted
OnFileDrop
forwardsuseDropTarget
verbatim; when callers omit it the value becomesundefined
, which may differ from the intended defaulttrue
. 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
⛔ 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 using
wails 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 definedThe 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 codeThe build tag ensures this code only compiles on Windows platforms, which is correct for Windows API functionality.
9-10
: LGTM: Proper Windows API function loadingCorrectly loads the user32.dll library and retrieves the SetWindowDisplayAffinity procedure.
12-16
: LGTM: Well-defined Windows API constantsConstants 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 entriesThe .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 optionsThe 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 boolv2/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 existingbool2Cint
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 WindowsThe 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 withWDA_NONE
.v2/examples/privatewindow/frontend/src/style.css (1)
1-26
: LGTM: Well-structured CSS for the example applicationThe 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 projectThe 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
andCFBundleVersion
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 newcontentProtection
parameter, which implements the window content privacy feature for macOS. The parameter is correctly typed asint
for boolean representation (0 for false, non-zero for true) and positioned logically before the existingdevtoolsEnabled
parameter.The rename from
singleInstanceEnabled
tosingleInstanceLockEnabled
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.mLength of output: 851
Approve changes:
contentProtection
integrated and implemented correctlyVerified that the
Create
signature inv2/internal/frontend/desktop/darwin/Application.h
includes the newint contentProtection
parameter in the expected position, and that it is used appropriately inv2/internal/frontend/desktop/darwin/Application.m
(line 34). The rename fromsingleInstanceEnabled
tosingleInstanceLockEnabled
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 theCreate
parameter list betweenwindowIsTranslucent
anddevtoolsEnabled
. Please double-check that:
Application.h
was changed consistently (looks to be the case from the PR description).- 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' {} | headLength 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 neverLength of output: 208
Let’s inspect the full
C.Create
call to ensure the newcontentProtection
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.goLength of output: 1243
Let’s verify that the
Create
prototype inApplication.h
was updated to includecontentProtection
:
🏁 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 newcontentProtection
parameter
All occurrences of theCreate
call have been updated to match the revised Objective-C signature:• Application.h now declares
contentProtection
betweenwindowIsTranslucent
anddevtoolsEnabled
.
• window.go’sC.Create(...)
invocation includescontentProtection
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 bywails build
. Unless you intend to maintain this file by hand, keeping it verbatim avoids merge conflicts on futurewails 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
, andEnvironmentInfo
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 inruntime.js
.
59-87
: Logging function signatures are accurate
Each log level (LogPrint
,LogTrace
,LogDebug
,LogInfo
,LogWarning
,LogError
,LogFatal
) accepts a singlestring
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
, andWindowIsFullscreen
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
returningPromise<Screen[]>
andBrowserOpenURL
are correctly typed.
213-227
: Environment & lifecycle functions
Environment
,Quit
,Hide
, andShow
signatures align with the expected runtime methods.
229-236
: Clipboard API types
ClipboardGetText(): Promise<string>
andClipboardSetText(text: string): Promise<boolean>
accurately reflect asynchronous clipboard operations.
237-244
: Drag-and-drop typings
OnFileDrop
callback signature including(x, y, paths)
andOnFileDropOff
void return type are correct.
245-249
: Verify file resolution return type
CanResolveFilePaths()
returningboolean
is sensible, butResolveFilePaths(files: File[]): void
may not match the actual implementation (it likely returns resolved paths or a promise). Please confirm and update the return type toPromise<string[]>
or the appropriate type.v2/pkg/options/mac/mac.go (1)
21-21
: LGTM: Added ContentProtection option for macOSThe 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 entryThe 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 WindowsThe implementation correctly uses the Windows API
SetWindowDisplayAffinity
with theWDA_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 appThis 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.
v2/examples/privatewindow/frontend/wailsjs/runtime/runtime.d.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 featureThe 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 documentationThe 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 compatibilityThe
SetWindowDisplayAffinity
function correctly handles version compatibility by falling back toWDA_MONITOR
on older Windows versions that don't supportWDA_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
📒 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 optionThe default value of
false
for the ContentProtection option is appropriate as this maintains backward compatibility with existing applications.
121-121
: Consistent implementation across platformsGood 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 integrationThe 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 commentsThe 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 implementationThe
isWindowsVersionAtLeast
function is well-implemented, correctly handling major, minor, and build number comparisons in the proper order.
1-9
: Proper build constraints and importsThe build constraint ensures this code is only compiled on Windows platforms, and the imports are correctly specified.
|
Description
Adds content protection to Windows and MacOS Wails applications.
Implements feature request #4240
Type of change
How Has This Been Tested?
MacOS
A Wails test application was made with
ContentProtection
set totrue
, 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.
There is no Linux solution yet.
Test Configuration
Checklist:
website/src/pages/changelog.mdx
with details of this PRSummary by CodeRabbit
New Features
Documentation