mirror of
https://github.com/electron/electron.git
synced 2026-01-28 08:48:14 -05:00
Move StoreFocus/RestoreFocus to BrowserWindow
This commit is contained in:
@@ -276,7 +276,6 @@ bool BrowserWindow::OnMessageReceived(const IPC::Message& message,
|
||||
void BrowserWindow::OnCloseContents() {
|
||||
if (!web_contents())
|
||||
return;
|
||||
Observe(nullptr);
|
||||
|
||||
// Close all child windows before closing current window.
|
||||
v8::Locker locker(isolate());
|
||||
@@ -296,6 +295,9 @@ void BrowserWindow::OnCloseContents() {
|
||||
|
||||
// Do not sent "unresponsive" event after window is closed.
|
||||
window_unresponsive_closure_.Cancel();
|
||||
|
||||
// Clear the web_contents() at last.
|
||||
Observe(nullptr);
|
||||
}
|
||||
|
||||
void BrowserWindow::OnRendererResponsive() {
|
||||
@@ -360,10 +362,20 @@ void BrowserWindow::OnWindowEndSession() {
|
||||
}
|
||||
|
||||
void BrowserWindow::OnWindowBlur() {
|
||||
web_contents()->StoreFocus();
|
||||
auto* rwhv = web_contents()->GetRenderWidgetHostView();
|
||||
if (rwhv)
|
||||
rwhv->SetActive(false);
|
||||
|
||||
Emit("blur");
|
||||
}
|
||||
|
||||
void BrowserWindow::OnWindowFocus() {
|
||||
web_contents()->RestoreFocus();
|
||||
auto* rwhv = web_contents()->GetRenderWidgetHostView();
|
||||
if (rwhv)
|
||||
rwhv->SetActive(true);
|
||||
|
||||
Emit("focus");
|
||||
}
|
||||
|
||||
|
||||
@@ -243,30 +243,10 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeMain:(NSNotification*)notification {
|
||||
content::WebContents* web_contents = shell_->web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
web_contents->RestoreFocus();
|
||||
|
||||
content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
|
||||
if (rwhv)
|
||||
rwhv->SetActive(true);
|
||||
|
||||
shell_->NotifyWindowFocus();
|
||||
}
|
||||
|
||||
- (void)windowDidResignMain:(NSNotification*)notification {
|
||||
content::WebContents* web_contents = shell_->web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
web_contents->StoreFocus();
|
||||
|
||||
content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
|
||||
if (rwhv)
|
||||
rwhv->SetActive(false);
|
||||
|
||||
shell_->NotifyWindowBlur();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user