Add ready-to-show event
This commit is contained in:
parent
2dc453b4be
commit
4d65af3c60
5 changed files with 29 additions and 0 deletions
|
@ -156,6 +156,10 @@ void Window::OnWindowHide() {
|
||||||
Emit("hide");
|
Emit("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::OnReadyToShow() {
|
||||||
|
Emit("ready-to-show");
|
||||||
|
}
|
||||||
|
|
||||||
void Window::OnWindowMaximize() {
|
void Window::OnWindowMaximize() {
|
||||||
Emit("maximize");
|
Emit("maximize");
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
void OnWindowFocus() override;
|
void OnWindowFocus() override;
|
||||||
void OnWindowShow() override;
|
void OnWindowShow() override;
|
||||||
void OnWindowHide() override;
|
void OnWindowHide() override;
|
||||||
|
void OnReadyToShow() override;
|
||||||
void OnWindowMaximize() override;
|
void OnWindowMaximize() override;
|
||||||
void OnWindowUnmaximize() override;
|
void OnWindowUnmaximize() override;
|
||||||
void OnWindowMinimize() override;
|
void OnWindowMinimize() override;
|
||||||
|
|
|
@ -560,6 +560,19 @@ void NativeWindow::BeforeUnloadDialogCancelled() {
|
||||||
window_unresposive_closure_.Cancel();
|
window_unresposive_closure_.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::DidFirstVisuallyNonEmptyPaint() {
|
||||||
|
// When there is a non-empty first paint, resize the RenderWidget to force
|
||||||
|
// Chromium to draw.
|
||||||
|
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||||
|
view->Show();
|
||||||
|
view->SetSize(GetContentSize());
|
||||||
|
|
||||||
|
// Emit the ReadyToShow event in next tick in case of pending drawing work.
|
||||||
|
base::MessageLoop::current()->PostTask(
|
||||||
|
FROM_HERE,
|
||||||
|
base::Bind(&NativeWindow::NotifyReadyToShow, GetWeakPtr()));
|
||||||
|
}
|
||||||
|
|
||||||
bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
|
bool NativeWindow::OnMessageReceived(const IPC::Message& message) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
|
IPC_BEGIN_MESSAGE_MAP(NativeWindow, message)
|
||||||
|
@ -601,6 +614,10 @@ void NativeWindow::NotifyWindowUnresponsive() {
|
||||||
OnRendererUnresponsive());
|
OnRendererUnresponsive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::NotifyReadyToShow() {
|
||||||
|
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnReadyToShow());
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
const SkBitmap& bitmap,
|
const SkBitmap& bitmap,
|
||||||
content::ReadbackResponse response) {
|
content::ReadbackResponse response) {
|
||||||
|
|
|
@ -275,6 +275,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
// content::WebContentsObserver:
|
// content::WebContentsObserver:
|
||||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||||
void BeforeUnloadDialogCancelled() override;
|
void BeforeUnloadDialogCancelled() override;
|
||||||
|
void DidFirstVisuallyNonEmptyPaint() override;
|
||||||
bool OnMessageReceived(const IPC::Message& message) override;
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -284,6 +285,9 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
// Dispatch unresponsive event to observers.
|
// Dispatch unresponsive event to observers.
|
||||||
void NotifyWindowUnresponsive();
|
void NotifyWindowUnresponsive();
|
||||||
|
|
||||||
|
// Dispatch ReadyToShow event to observers.
|
||||||
|
void NotifyReadyToShow();
|
||||||
|
|
||||||
// Called when CapturePage has done.
|
// Called when CapturePage has done.
|
||||||
void OnCapturePageDone(const CapturePageCallback& callback,
|
void OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
const SkBitmap& bitmap,
|
const SkBitmap& bitmap,
|
||||||
|
|
|
@ -48,6 +48,9 @@ class NativeWindowObserver {
|
||||||
// Called when window is hidden.
|
// Called when window is hidden.
|
||||||
virtual void OnWindowHide() {}
|
virtual void OnWindowHide() {}
|
||||||
|
|
||||||
|
// Called when window is ready to show.
|
||||||
|
virtual void OnReadyToShow() {}
|
||||||
|
|
||||||
// Called when window state changed.
|
// Called when window state changed.
|
||||||
virtual void OnWindowMaximize() {}
|
virtual void OnWindowMaximize() {}
|
||||||
virtual void OnWindowUnmaximize() {}
|
virtual void OnWindowUnmaximize() {}
|
||||||
|
|
Loading…
Reference in a new issue