8000 fix: `setContentProtection(true)` after hide on Windows by codebytere · Pull Request #45868 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: setContentProtection(true) after hide on Windows #45868

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

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

codebytere
Copy link
Member
@codebytere codebytere commented Mar 3, 2025

Description of Change

Fixes #45844.
Refs CL:5789117

This PR fixes an issue where setContentProtection(true) was reverted when a given window was hidden. This happened as a result of the above CL, which added logic to avoid setting content protection when a window was hidden. That wouldn't be an issue, except that we weren't using the upstream Widget functionality, and so when it went to ensure protection state after re-showing it, the status was incorrect. Fix this by leveraging upstream functionality. This PR additionally adds testing and a currently private getter function for content protection status so we can test and prevent regressions in the future. I'll look to expose that in a follow-up PR.

Checklist

Release Notes

Notes: Fixed an issue where setContentProtection(true) was reverted when a given window was hidden.

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/34-x-y PR should also be added to the "34-x-y" branch. target/35-x-y PR should also be added to the "35-x-y" branch. labels Mar 3, 2025
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Mar 3, 2025
@codebytere codebytere requested a review from clavin March 3, 2025 09:06
DWORD affinity = enable ? WDA_EXCLUDEFROMCAPTURE : WDA_NONE;
::SetWindowDisplayAffinity(hwnd, affinity);
if (!layered_) {
// Workaround to prevent black window on screen capture after hiding and
Copy link
Member Author

Choose a reason for hiding this comment

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

Tested to ensure no black window regression!

@codebytere codebytere force-pushed the test-content-protection branch from 9dcbe9a to 838ba0e Compare March 3, 2025 11:20
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Mar 4, 2025
@codebytere codebytere force-pushed the test-content-protection branch from 838ba0e to 5a7e873 Compare March 4, 2025 11:02
@jkleinsc jkleinsc merged commit 99c943d into main Mar 4, 2025
56 checks passed
@jkleinsc jkleinsc deleted the test-content-protection branch March 4, 2025 21:40
@release-clerk
Copy link
release-clerk bot commented Mar 4, 2025

Release Notes Persisted

Fixed an issue where setContentProtection(true) was reverted when a given window was hidden.

@trop
Copy link
Contributor
trop bot commented Mar 4, 2025

I have automatically backported this PR to "35-x-y", please check out #45889

@trop trop bot added in-flight/35-x-y and removed target/35-x-y PR should also be added to the "35-x-y" branch. labels Mar 4, 2025
@trop
Copy link
Contributor
trop bot commented Mar 4, 2025

I have automatically backported this PR to "34-x-y", please check out #45890

@trop trop bot added in-flight/34-x-y merged/35-x-y PR was merged to the "35-x-y" branch. merged/34-x-y PR was merged to the "34-x-y" branch. and removed target/34-x-y PR should also be added to the "34-x-y" branch. in-flight/35-x-y in-flight/34-x-y labels Mar 4, 2025
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
layered_ = true;
}
widget()->native_widget_private()->SetAllowScreenshots(!enable);

Choose a reason for hiding this comment

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

Great to see this issue being fixed! One question though, won't this change behavior since Chromium uses WDA_MONITOR instead of WDA_EXCLUDEFROMCAPTURE? here: https://source.chromium.org/chromium/chromium/src/+/main:ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc;l=1476?q=SetAllowScreenshots&ss=chromium%2Fchromium%2Fsrc&start=21

codebytere added a commit that referenced this pull request May 8, 2025
Fixes #45990

We previously made a change in #45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.
ckerr pushed a commit that referenced this pull request May 9, 2025
Fixes #45990

We previously made a change in #45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.
trop bot added a commit that referenced this pull request May 9, 2025
Fixes #45990

We previously made a change in #45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
trop bot added a commit that referenced this pull request May 9, 2025
Fixes #45990

We previously made a change in #45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
trop bot added a commit that referenced this pull request May 9, 2025
Fixes #45990

We previously made a change in #45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
jkleinsc pushed a commit that referenced this pull request May 9, 2025
Fixes #45990

We previously made a change in #45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
8000 jkleinsc pushed a commit that referenced this pull request May 9, 2025
Fixes #45990

We previously made a change in #45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
ckerr pushed a commit that referenced this pull request May 9, 2025
Fixes #45990

We previously made a change in #45868
to fix content protection being lost on hide and re-show. However, this
cause a breaking change where protected windows were made opaque black
instead of being hidden as before. This overrides relevant methods in
ElectronDesktopWindowTreeHostWin to restore the previous behavior.
without regressing the original issue.

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/34-x-y PR was merged to the "34-x-y" branch. merged/35-x-y PR was merged to the "35-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setContentProtection(true) is cleared by win.hide()
3 participants
0