Skip to content

Commit

Permalink
1. Notify CEF about window's visible when each MainFrame load finished.
Browse files Browse the repository at this point in the history
2. Using XXX.XXX.XXX to manage version.
  • Loading branch information
winsoft666 committed Aug 31, 2020
1 parent e98111b commit 6e06e31
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
25 changes: 15 additions & 10 deletions src/QCefWidget/CefBrowserApp/QCefBrowserHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,18 +419,23 @@ void QCefBrowserHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
int httpStatusCode) {
CEF_REQUIRE_UI_THREAD();

if (pImpl_->getWidgetType() == WT_Widget) {
QCefWidget* p = qobject_cast<QCefWidget*>(pImpl_->getWidget());
if (p)
emit p->loadEnd(frame->IsMain(), httpStatusCode);
}
if (pImpl_) {
if (pImpl_->getWidgetType() == WT_Widget) {
QCefWidget* p = qobject_cast<QCefWidget*>(pImpl_->getWidget());
if (p)
emit p->loadEnd(frame->IsMain(), httpStatusCode);
}
#ifndef QT_NO_OPENGL
else if (pImpl_->getWidgetType() == WT_OpenGLWidget) {
QCefOpenGLWidget* p = qobject_cast<QCefOpenGLWidget*>(pImpl_->getWidget());
if (p)
emit p->loadEnd(frame->IsMain(), httpStatusCode);
}
else if (pImpl_->getWidgetType() == WT_OpenGLWidget) {
QCefOpenGLWidget* p = qobject_cast<QCefOpenGLWidget*>(pImpl_->getWidget());
if (p)
emit p->loadEnd(frame->IsMain(), httpStatusCode);
}
#endif
if (frame->IsMain()) {
pImpl_->mainFrameLoadFinishedNotify();
}
}
}

void QCefBrowserHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
Expand Down
9 changes: 9 additions & 0 deletions src/QCefWidget/Include/QCefVersion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef QCEF_VERSION_H_
#define QCEF_VERSION_H_
#pragma once

#define QCEF_VERSION_MAJOR 1
#define QCEF_VERSION_MINOR 0
#define QCEF_VERSION_PATCH 1

#endif // !QCEF_VERSION_H_
8 changes: 4 additions & 4 deletions src/QCefWidget/QCefWidgetImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,6 @@ void QCefWidgetImpl::browserCreatedNotify(CefRefPtr<CefBrowser> browser) {

pTopWidget_ = QCefManager::getInstance().addBrowser(
pWidget_, this, browser, browserSetting_.osrEnabled);

// 延时1000ms之后通知CEF当前是否隐藏
QTimer::singleShot(
1000, this, [this]() { visibleChangedNotify(pWidget_->isVisible()); });
}

void QCefWidgetImpl::browserClosingNotify(CefRefPtr<CefBrowser> browser) {
Expand Down Expand Up @@ -500,6 +496,10 @@ void QCefWidgetImpl::dpiChangedNotify() {
simulateResizeEvent();
}

void QCefWidgetImpl::mainFrameLoadFinishedNotify() {
visibleChangedNotify(pWidget_->isVisible());
}

bool QCefWidgetImpl::sendEventNotifyMessage(const QString& name,
const QCefEvent& event) {
if (!pQCefViewHandler_)
Expand Down
1 change: 1 addition & 0 deletions src/QCefWidget/QCefWidgetImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class QCefWidgetImpl : public QObject {
bool createDevTools(CefRefPtr<CefBrowser> targetBrowser);

void dpiChangedNotify();
void mainFrameLoadFinishedNotify();

void browserClosingNotify(CefRefPtr<CefBrowser> browser);
void browserCreatedNotify(CefRefPtr<CefBrowser> browser);
Expand Down

0 comments on commit 6e06e31

Please sign in to comment.