SPE-2575:: Do not allow busy cursor logic in webview on linux

Allow changes of cursor only when panel is shown.
This commit is contained in:
David Kocik 2024-11-25 16:56:04 +01:00 committed by Lukas Matena
parent 47bba48b34
commit c8cac7f678
3 changed files with 55 additions and 25 deletions

View File

@ -106,13 +106,24 @@ void ConfigWizardWebViewPage::load_error_page() {
m_load_error_page = true; m_load_error_page = true;
} }
constexpr bool is_linux =
#if defined(__linux__)
true;
#else
false;
#endif
void ConfigWizardWebViewPage::on_idle(wxIdleEvent &WXUNUSED(evt)) { void ConfigWizardWebViewPage::on_idle(wxIdleEvent &WXUNUSED(evt)) {
if (!m_browser) if (!m_browser)
return; return;
if (m_browser->IsBusy()) { if (m_browser->IsBusy()) {
wxSetCursor(wxCURSOR_ARROWWAIT); if constexpr (!is_linux) {
wxSetCursor(wxCURSOR_ARROWWAIT);
}
} else { } else {
wxSetCursor(wxNullCursor); if constexpr (!is_linux) {
wxSetCursor(wxNullCursor);
}
if (!m_vetoed && m_load_error_page) { if (!m_vetoed && m_load_error_page) {
m_load_error_page = false; m_load_error_page = false;

View File

@ -148,14 +148,25 @@ WebViewDialog::~WebViewDialog()
{ {
} }
constexpr bool is_linux =
#if defined(__linux__)
true;
#else
false;
#endif
void WebViewDialog::on_idle(wxIdleEvent& WXUNUSED(evt)) void WebViewDialog::on_idle(wxIdleEvent& WXUNUSED(evt))
{ {
if (!m_browser) if (!m_browser)
return; return;
if (m_browser->IsBusy()) { if (m_browser->IsBusy()) {
wxSetCursor(wxCURSOR_ARROWWAIT); if constexpr (!is_linux) {
} else { wxSetCursor(wxCURSOR_ARROWWAIT);
wxSetCursor(wxNullCursor); }
} else {
if constexpr (!is_linux) {
wxSetCursor(wxNullCursor);
}
if (m_load_error_page) { if (m_load_error_page) {
m_load_error_page = false; m_load_error_page = false;
m_browser->LoadURL(GUI::format_wxstr("file://%1%/web/error_no_reload.html", boost::filesystem::path(resources_dir()).generic_string())); m_browser->LoadURL(GUI::format_wxstr("file://%1%/web/error_no_reload.html", boost::filesystem::path(resources_dir()).generic_string()));

View File

@ -218,6 +218,7 @@ void WebViewPanel::on_show(wxShowEvent& evt)
{ {
m_shown = evt.IsShown(); m_shown = evt.IsShown();
if (!m_shown) { if (!m_shown) {
wxSetCursor(wxNullCursor);
return; return;
} }
if (m_do_late_webview_create) { if (m_do_late_webview_create) {
@ -238,29 +239,36 @@ void WebViewPanel::on_idle(wxIdleEvent& WXUNUSED(evt))
{ {
if (!m_browser || m_do_late_webview_create) if (!m_browser || m_do_late_webview_create)
return; return;
if (m_browser->IsBusy()) {
wxSetCursor(wxCURSOR_ARROWWAIT);
} else {
wxSetCursor(wxNullCursor);
if (m_shown && m_load_error_page) { // The busy cursor on webview is switched off on Linux.
m_load_error_page = false; // Because m_browser->IsBusy() is almost always true on Printables / Connect.
if (m_load_default_url_on_next_error) { #ifndef __linux__
m_load_default_url_on_next_error = false; if (m_shown) {
load_default_url(); if (m_browser->IsBusy()) {
} else { wxSetCursor(wxCURSOR_ARROWWAIT);
load_url(GUI::format_wxstr("file://%1%/web/%2%.html", boost::filesystem::path(resources_dir()).generic_string(), m_error_html)); } else {
// This is a fix of broken message handling after error. wxSetCursor(wxNullCursor);
// F.e. if there is an error but we do AddUserScript & Reload, the handling will break. }
// So we just reset the handler here. }
if (!m_script_message_hadler_names.empty()) { #endif // !__linux__
m_browser->RemoveScriptMessageHandler(Slic3r::GUI::from_u8(m_script_message_hadler_names.front()));
m_browser->AddScriptMessageHandler(Slic3r::GUI::from_u8(m_script_message_hadler_names.front()));
}
if (m_shown && m_load_error_page && !m_browser->IsBusy()) {
m_load_error_page = false;
if (m_load_default_url_on_next_error) {
m_load_default_url_on_next_error = false;
load_default_url();
} else {
load_url(GUI::format_wxstr("file://%1%/web/%2%.html", boost::filesystem::path(resources_dir()).generic_string(), m_error_html));
// This is a fix of broken message handling after error.
// F.e. if there is an error but we do AddUserScript & Reload, the handling will break.
// So we just reset the handler here.
if (!m_script_message_hadler_names.empty()) {
m_browser->RemoveScriptMessageHandler(Slic3r::GUI::from_u8(m_script_message_hadler_names.front()));
m_browser->AddScriptMessageHandler(Slic3r::GUI::from_u8(m_script_message_hadler_names.front()));
} }
} }
} }
#ifdef DEBUG_URL_PANEL #ifdef DEBUG_URL_PANEL
m_button_stop->Enable(m_browser->IsBusy()); m_button_stop->Enable(m_browser->IsBusy());
#endif #endif