refactor: add NativeWindow::FromWidget() helper (#46917)
refactor: add NativeWindow::FromWidet() helper refactor: make kElectronNativeWindowKey a protected field
This commit is contained in:
parent
cb445b3bbd
commit
1f4f1b4afc
5 changed files with 20 additions and 12 deletions
|
|
@ -99,12 +99,11 @@ void WebContentsView::WebContentsDestroyed() {
|
|||
|
||||
void WebContentsView::OnViewAddedToWidget(views::View* observed_view) {
|
||||
DCHECK_EQ(observed_view, view());
|
||||
views::Widget* widget = view()->GetWidget();
|
||||
auto* native_window =
|
||||
static_cast<NativeWindow*>(widget->GetNativeWindowProperty(
|
||||
electron::kElectronNativeWindowKey.c_str()));
|
||||
|
||||
NativeWindow* native_window = NativeWindow::FromWidget(view()->GetWidget());
|
||||
if (!native_window)
|
||||
return;
|
||||
|
||||
// We don't need to call SetOwnerWindow(nullptr) in OnViewRemovedFromWidget
|
||||
// because that's handled in the WebContents dtor called prior.
|
||||
api_web_contents_->SetOwnerWindow(native_window);
|
||||
|
|
@ -114,11 +113,11 @@ void WebContentsView::OnViewAddedToWidget(views::View* observed_view) {
|
|||
|
||||
void WebContentsView::OnViewRemovedFromWidget(views::View* observed_view) {
|
||||
DCHECK_EQ(observed_view, view());
|
||||
views::Widget* widget = view()->GetWidget();
|
||||
auto* native_window = static_cast<NativeWindow*>(
|
||||
widget->GetNativeWindowProperty(kElectronNativeWindowKey.c_str()));
|
||||
|
||||
NativeWindow* native_window = NativeWindow::FromWidget(view()->GetWidget());
|
||||
if (!native_window)
|
||||
return;
|
||||
|
||||
native_window->RemoveDraggableRegionProvider(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue