wails/v3/pkg/application/window.go
Lea Anthony 3f11d4e3fa
feat: Add Content Protection for Windows and macOS (#4485)
* feat: Add Content Protection for Windows and macOS

- Prevents window contents from being captured by screen recording/sharing software
- Windows: Uses WDA_EXCLUDEFROMCAPTURE on Windows 10 2004+, falls back to WDA_MONITOR
- macOS: Uses NSWindowSharingType to set window as read-only for screen sharing
- Added ContentProtectionEnabled option to WebviewWindowOptions
- Added SetContentProtection() method for runtime control
- Added comprehensive documentation and example usage

* fix changelog.mdx

* Misc fixes

* Misc fixes

* Update v3/pkg/w32/user32.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Remove debug line

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-08-09 17:12:39 +10:00

112 lines
2.7 KiB
Go

package application
import (
"unsafe"
"github.com/wailsapp/wails/v3/pkg/events"
)
type Callback interface {
CallError(callID string, result string, isJSON bool)
CallResponse(callID string, result string)
DialogError(dialogID string, result string)
DialogResponse(dialogID string, result string, isJSON bool)
}
type Window interface {
Callback
Center()
Close()
DisableSizeConstraints()
DispatchWailsEvent(event *CustomEvent)
EmitEvent(name string, data ...any)
EnableSizeConstraints()
Error(message string, args ...any)
ExecJS(js string)
Focus()
ForceReload()
Fullscreen() Window
GetBorderSizes() *LRTB
GetScreen() (*Screen, error)
GetZoom() float64
HandleDragAndDropMessage(filenames []string, dropZone *DropZoneDetails)
InitiateFrontendDropProcessing(filenames []string, x int, y int)
HandleMessage(message string)
HandleWindowEvent(id uint)
Height() int
Hide() Window
HideMenuBar()
ID() uint
Info(message string, args ...any)
IsFocused() bool
IsFullscreen() bool
IsIgnoreMouseEvents() bool
IsMaximised() bool
IsMinimised() bool
HandleKeyEvent(acceleratorString string)
Maximise() Window
Minimise() Window
Name() string
OnWindowEvent(eventType events.WindowEventType, callback func(event *WindowEvent)) func()
OpenContextMenu(data *ContextMenuData)
Position() (int, int)
RelativePosition() (int, int)
Reload()
Resizable() bool
Restore()
Run()
SetPosition(x, y int)
SetAlwaysOnTop(b bool) Window
SetBackgroundColour(colour RGBA) Window
SetFrameless(frameless bool) Window
SetHTML(html string) Window
SetMinimiseButtonState(state ButtonState) Window
SetMaximiseButtonState(state ButtonState) Window
SetCloseButtonState(state ButtonState) Window
SetMaxSize(maxWidth, maxHeight int) Window
SetMinSize(minWidth, minHeight int) Window
SetRelativePosition(x, y int) Window
SetResizable(b bool) Window
SetIgnoreMouseEvents(ignore bool) Window
SetSize(width, height int) Window
SetTitle(title string) Window
SetURL(s string) Window
SetZoom(magnification float64) Window
Show() Window
ShowMenuBar()
Size() (width int, height int)
OpenDevTools()
ToggleFullscreen()
ToggleMaximise()
ToggleMenuBar()
ToggleFrameless()
UnFullscreen()
UnMaximise()
UnMinimise()
Width() int
IsVisible() bool
Bounds() Rect
SetBounds(bounds Rect)
Zoom()
ZoomIn()
ZoomOut()
ZoomReset() Window
SetMenu(menu *Menu)
SnapAssist()
SetContentProtection(protection bool) Window
NativeWindow() unsafe.Pointer
SetEnabled(enabled bool)
Flash(enabled bool)
Print() error
RegisterHook(eventType events.WindowEventType, callback func(event *WindowEvent)) func()
shouldUnconditionallyClose() bool
// Editing methods
cut()
copy()
paste()
undo()
redo()
delete()
selectAll()
}