fix: titlebar showing in content protected window (#47241)
Closes https://github.com/electron/electron/issues/47152.
This commit is contained in:
parent
c6f368acc6
commit
f89c2a0ef4
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(
|
||||
|
|
|
@ -52,8 +52,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