Don't allow close
This commit is contained in:
@@ -58,6 +58,7 @@ public:
|
||||
private:
|
||||
void PlatformTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title);
|
||||
private:
|
||||
bool _allowClose = false;
|
||||
bool _isClosing;
|
||||
bool _active;
|
||||
std::shared_ptr<Api::CSiaDriveConfig> _siaDriveConfig;
|
||||
|
@@ -430,6 +430,9 @@ void CSiaDriveApp::OnContextCreated(
|
||||
this->SiaApiRefreshCallback(context, siaCurl, siaDriveConfig);
|
||||
}));
|
||||
_refreshThread->StartAutoThread();
|
||||
|
||||
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("notifyAllowClose");
|
||||
context->GetBrowser()->SendProcessMessage(PID_BROWSER, msg);
|
||||
}
|
||||
|
||||
void CSiaDriveApp::OnContextInitialized()
|
||||
|
@@ -155,6 +155,12 @@ bool CSiaDriveHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, C
|
||||
{
|
||||
json configDoc = json::parse(message->GetArgumentList()->GetString(0).ToString().c_str());
|
||||
_siaDriveConfig.reset(new CSiaDriveConfig(configDoc));
|
||||
return true;
|
||||
}
|
||||
else if (message->GetName() == "notifyAllowClose")
|
||||
{
|
||||
_allowClose = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -200,30 +206,35 @@ bool CSiaDriveHandler::DoClose(CefRefPtr<CefBrowser> browser)
|
||||
{
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
if (!_isClosing && (_browserList.size() == 1))
|
||||
{
|
||||
if (!_siaDriveConfig->GetCloseToTray() || g_trayClose)
|
||||
{
|
||||
// Set a flag to indicate that the window close should be allowed.
|
||||
_isClosing = true;
|
||||
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("shutdownServices");
|
||||
browser->SendProcessMessage(PID_RENDERER, msg);
|
||||
}
|
||||
else if (_siaDriveConfig->GetCloseToTray())
|
||||
if (_allowClose)
|
||||
{
|
||||
if (!_isClosing && (_browserList.size() == 1))
|
||||
{
|
||||
if (!_siaDriveConfig->GetCloseToTray() || g_trayClose)
|
||||
{
|
||||
// Set a flag to indicate that the window close should be allowed.
|
||||
_isClosing = true;
|
||||
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("shutdownServices");
|
||||
browser->SendProcessMessage(PID_RENDERER, msg);
|
||||
}
|
||||
else if (_siaDriveConfig->GetCloseToTray())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
::ShowWindow(browser->GetHost()->GetWindowHandle(), SW_HIDE);
|
||||
::ShowWindow(browser->GetHost()->GetWindowHandle(), SW_HIDE);
|
||||
#else
|
||||
a
|
||||
a
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// Allow the close. For windowed browsers this will result in the OS close
|
||||
// event being sent.
|
||||
return _active;
|
||||
}
|
||||
|
||||
// Allow the close. For windowed browsers this will result in the OS close
|
||||
// event being sent.
|
||||
return _active;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSiaDriveHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser)
|
||||
|
Reference in New Issue
Block a user