refactor: add NativeWindow::FromWidget() helper (#46917)

refactor: add NativeWindow::FromWidet() helper

refactor: make kElectronNativeWindowKey a protected field
This commit is contained in:
Charles Kerr
2025-05-05 09:27:41 -05:00
committed by GitHub
parent cb445b3bbd
commit 1f4f1b4afc
5 changed files with 20 additions and 12 deletions

View File

@@ -284,6 +284,13 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) {
Show();
}
// static
NativeWindow* NativeWindow::FromWidget(const views::Widget* widget) {
DCHECK(widget);
return static_cast<NativeWindow*>(
widget->GetNativeWindowProperty(kNativeWindowKey.c_str()));
}
void NativeWindow::SetSize(const gfx::Size& size, bool animate) {
SetBounds(gfx::Rect(GetPosition(), size), animate);
}