fix: titlebar showing in content protected window (#47266)
Closes https://github.com/electron/electron/issues/47152. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
7dd024a9dc
commit
f9b86609a9
2 changed files with 27 additions and 2 deletions
|
|
@ -143,11 +143,33 @@ bool ElectronDesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
|
|||
void ElectronDesktopWindowTreeHostWin::HandleVisibilityChanged(bool visible) {
|
||||
if (native_window_view_->widget())
|
||||
native_window_view_->widget()->OnNativeWidgetVisibilityChanged(visible);
|
||||
|
||||
if (visible)
|
||||
UpdateAllowScreenshots();
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostWin::SetAllowScreenshots(bool allow) {
|
||||
::SetWindowDisplayAffinity(GetAcceleratedWidget(),
|
||||
allow ? WDA_NONE : WDA_EXCLUDEFROMCAPTURE);
|
||||
if (allow_screenshots_ == allow)
|
||||
return;
|
||||
|
||||
allow_screenshots_ = allow;
|
||||
|
||||
// If the window is not visible, do not set the window display affinity
|
||||
// because `SetWindowDisplayAffinity` will attempt to compose the window,
|
||||
if (!IsVisible())
|
||||
return;
|
||||
|
||||
UpdateAllowScreenshots();
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostWin::UpdateAllowScreenshots() {
|
||||
bool allowed = views::DesktopWindowTreeHostWin::AreScreenshotsAllowed();
|
||||
if (allowed == allow_screenshots_)
|
||||
return;
|
||||
|
||||
::SetWindowDisplayAffinity(
|
||||
GetAcceleratedWidget(),
|
||||
allow_screenshots_ ? WDA_NONE : WDA_EXCLUDEFROMCAPTURE);
|
||||
}
|
||||
|
||||
void ElectronDesktopWindowTreeHostWin::OnNativeThemeUpdated(
|
||||
|
|
|
|||
|
|
@ -51,8 +51,11 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin,
|
|||
bool ShouldWindowContentsBeTransparent() const override;
|
||||
|
||||
private:
|
||||
void UpdateAllowScreenshots();
|
||||
|
||||
raw_ptr<NativeWindowViews> native_window_view_; // weak ref
|
||||
std::optional<bool> force_should_paint_as_active_;
|
||||
bool allow_screenshots_ = true;
|
||||
bool widget_init_done_ = false;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue