Skip to content

Commit 25afb3e

Browse files
Merge pull request #4 from El-GeorgesW/adding_windows_support
Added support for Windows
2 parents 5296aa7 + 21ce864 commit 25afb3e

29 files changed

+1457
-25
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ migrate_working_dir/
2121
# The .vscode folder contains launch configuration and tasks you configure in
2222
# VS Code which you may wish to be included in version control, so this line
2323
# is commented out by default.
24-
#.vscode/
24+
.vscode/
2525

2626
# Flutter/Dart/Pub related
2727
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- 🚫 Prevent users from taking screenshots.
88
- 📹 Detect and react to screen recording activity.
99
- 📱 Supports both Android and iOS platforms.
10+
- 💻 Supports Windows desktop platform.
1011

1112
---
1213

@@ -93,6 +94,12 @@ class _ScreenshotGuardExampleState extends State<ScreenshotGuardExample> {
9394

9495
- The plugin uses iOS system notifications to detect screenshot and screen recording activities.
9596

97+
### Windows
98+
99+
- The plugin uses the Windows SetWindowDisplayAffinity API to prevent screen capture and video recording.
100+
- The `SetWindowDisplayAffinity` API is specific to windows with the `WS_OVERLAPPEDWINDOW` style. Make sure your window meets this requirement.
101+
- In case of failure, the error returned can be checked in the logs to diagnose issues related to display affinity.
102+
96103
## API Reference
97104

98105
### Methods

example/.metadata

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "3e493a3e4d0a5c99fa7da51faae354e95a9a1abe"
8+
channel: "beta"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 3e493a3e4d0a5c99fa7da51faae354e95a9a1abe
17+
base_revision: 3e493a3e4d0a5c99fa7da51faae354e95a9a1abe
18+
- platform: windows
19+
create_revision: 3e493a3e4d0a5c99fa7da51faae354e95a9a1abe
20+
base_revision: 3e493a3e4d0a5c99fa7da51faae354e95a9a1abe
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/pubspec.lock

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ packages:
55
dependency: transitive
66
description:
77
name: async
8-
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
8+
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "2.11.0"
11+
version: "2.12.0"
1212
boolean_selector:
1313
dependency: transitive
1414
description:
1515
name: boolean_selector
16-
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
16+
sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
1717
url: "https://pub.dev"
1818
source: hosted
19-
version: "2.1.1"
19+
version: "2.1.2"
2020
characters:
2121
dependency: transitive
2222
description:
@@ -29,10 +29,10 @@ packages:
2929
dependency: transitive
3030
description:
3131
name: clock
32-
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
32+
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
3333
url: "https://pub.dev"
3434
source: hosted
35-
version: "1.1.1"
35+
version: "1.1.2"
3636
collection:
3737
dependency: transitive
3838
description:
@@ -53,18 +53,18 @@ packages:
5353
dependency: transitive
5454
description:
5555
name: fake_async
56-
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
56+
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
5757
url: "https://pub.dev"
5858
source: hosted
59-
version: "1.3.1"
59+
version: "1.3.2"
6060
file:
6161
dependency: transitive
6262
description:
6363
name: file
64-
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
64+
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
6565
url: "https://pub.dev"
6666
source: hosted
67-
version: "7.0.0"
67+
version: "7.0.1"
6868
flutter:
6969
dependency: "direct main"
7070
description: flutter
@@ -102,18 +102,18 @@ packages:
102102
dependency: transitive
103103
description:
104104
name: leak_tracker
105-
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
105+
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
106106
url: "https://pub.dev"
107107
source: hosted
108-
version: "10.0.7"
108+
version: "10.0.8"
109109
leak_tracker_flutter_testing:
110110
dependency: transitive
111111
description:
112112
name: leak_tracker_flutter_testing
113-
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
113+
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
114114
url: "https://pub.dev"
115115
source: hosted
116-
version: "3.0.8"
116+
version: "3.0.9"
117117
leak_tracker_testing:
118118
dependency: transitive
119119
description:
@@ -158,18 +158,18 @@ packages:
158158
dependency: transitive
159159
description:
160160
name: path
161-
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
161+
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
162162
url: "https://pub.dev"
163163
source: hosted
164-
version: "1.9.0"
164+
version: "1.9.1"
165165
platform:
166166
dependency: transitive
167167
description:
168168
name: platform
169-
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
169+
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
170170
url: "https://pub.dev"
171171
source: hosted
172-
version: "3.1.5"
172+
version: "3.1.6"
173173
plugin_platform_interface:
174174
dependency: transitive
175175
description:
@@ -182,10 +182,10 @@ packages:
182182
dependency: transitive
183183
description:
184184
name: process
185-
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
185+
sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d"
186186
url: "https://pub.dev"
187187
source: hosted
188-
version: "5.0.2"
188+
version: "5.0.3"
189189
screenshot_guard:
190190
dependency: "direct main"
191191
description:
@@ -226,10 +226,10 @@ packages:
226226
dependency: transitive
227227
description:
228228
name: string_scanner
229-
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
229+
sha256: "0bd04f5bb74fcd6ff0606a888a30e917af9bd52820b178eaa464beb11dca84b6"
230230
url: "https://pub.dev"
231231
source: hosted
232-
version: "1.3.0"
232+
version: "1.4.0"
233233
sync_http:
234234
dependency: transitive
235235
description:
@@ -266,10 +266,10 @@ packages:
266266
dependency: transitive
267267
description:
268268
name: vm_service
269-
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
269+
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
270270
url: "https://pub.dev"
271271
source: hosted
272-
version: "14.3.0"
272+
version: "14.3.1"
273273
webdriver:
274274
dependency: transitive
275275
description:

example/windows/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
flutter/ephemeral/
2+
3+
# Visual Studio user-specific files.
4+
*.suo
5+
*.user
6+
*.userosscache
7+
*.sln.docstates
8+
9+
# Visual Studio build-related files.
10+
x64/
11+
x86/
12+
13+
# Visual Studio cache files
14+
# files ending in .cache can be ignored
15+
*.[Cc]ache
16+
# but keep track of directories ending in .cache
17+
!*.[Cc]ache/

example/windows/CMakeLists.txt

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Project-level configuration.
2+
cmake_minimum_required(VERSION 3.14)
3+
project(screenshot_guard_example LANGUAGES CXX)
4+
5+
# The name of the executable created for the application. Change this to change
6+
# the on-disk name of your application.
7+
set(BINARY_NAME "screenshot_guard_example")
8+
9+
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10+
# versions of CMake.
11+
cmake_policy(VERSION 3.14...3.25)
12+
13+
# Define build configuration option.
14+
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15+
if(IS_MULTICONFIG)
16+
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17+
CACHE STRING "" FORCE)
18+
else()
19+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20+
set(CMAKE_BUILD_TYPE "Debug" CACHE
21+
STRING "Flutter build mode" FORCE)
22+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23+
"Debug" "Profile" "Release")
24+
endif()
25+
endif()
26+
# Define settings for the Profile build mode.
27+
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28+
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29+
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30+
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31+
32+
# Use Unicode for all projects.
33+
add_definitions(-DUNICODE -D_UNICODE)
34+
35+
# Compilation settings that should be applied to most targets.
36+
#
37+
# Be cautious about adding new options here, as plugins use this function by
38+
# default. In most cases, you should add new options to specific targets instead
39+
# of modifying this function.
40+
function(APPLY_STANDARD_SETTINGS TARGET)
41+
target_compile_features(${TARGET} PUBLIC cxx_std_17)
42+
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43+
target_compile_options(${TARGET} PRIVATE /EHsc)
44+
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45+
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
46+
endfunction()
47+
48+
# Flutter library and tool build rules.
49+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50+
add_subdirectory(${FLUTTER_MANAGED_DIR})
51+
52+
# Application build; see runner/CMakeLists.txt.
53+
add_subdirectory("runner")
54+
55+
56+
# Generated plugin build rules, which manage building the plugins and adding
57+
# them to the application.
58+
include(flutter/generated_plugins.cmake)
59+
60+
61+
# === Installation ===
62+
# Support files are copied into place next to the executable, so that it can
63+
# run in place. This is done instead of making a separate bundle (as on Linux)
64+
# so that building and running from within Visual Studio will work.
65+
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
66+
# Make the "install" step default, as it's required to run.
67+
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
68+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
69+
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
70+
endif()
71+
72+
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
73+
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
74+
75+
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
76+
COMPONENT Runtime)
77+
78+
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
79+
COMPONENT Runtime)
80+
81+
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
82+
COMPONENT Runtime)
83+
84+
if(PLUGIN_BUNDLED_LIBRARIES)
85+
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
86+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
87+
COMPONENT Runtime)
88+
endif()
89+
90+
# Copy the native assets provided by the build.dart from all packages.
91+
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
92+
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
93+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
94+
COMPONENT Runtime)
95+
96+
# Fully re-copy the assets directory on each build to avoid having stale files
97+
# from a previous install.
98+
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
99+
install(CODE "
100+
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
101+
" COMPONENT Runtime)
102+
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
103+
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
104+
105+
# Install the AOT library on non-Debug builds only.
106+
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
107+
CONFIGURATIONS Profile;Release
108+
COMPONENT Runtime)

0 commit comments

Comments
 (0)