diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-11-27 10:34:56 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-11-28 09:36:08 +0100 |
commit | 8c727d1a9a8cfdc309896ed02c546e192e006575 (patch) | |
tree | 9fd555e28dd24e25360d14cfb583c9ef017e4622 /sw | |
parent | cd2ba8cd78c1cd66d5c74e5d35acdcda1bf5abbc (diff) |
Always send theme-change in kit-mode even if the global theme is the same
Kit explicitly ignores changes to the global color scheme, except for the current ViewShell,
so an attempted change to the same global color scheme when the now current ViewShell ignored
the last change requires re-sending the change. In which case individual shells will have to
decide if this color-scheme change is a change from their perspective to avoid unnecessary
invalidations.
Add ConfigurationHints::OnlyCurrentDocumentColorScheme as the hint that
only the document color scheme has changed, so individual shells can see
if their document color scheme is different to this new color scheme and
not invalidate if unnecessary. So dark/light mode changes work properly
without reintroducing unwanted invalidations.
Change-Id: I5ebb4878694ceb6b9afe26286a30da06ea6ff3ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160002
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/app/apphdl.cxx | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index cd073097f771..cfb431092064 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -22,6 +22,7 @@ #include <config_wasm_strip.h> #include <comphelper/propertysequence.hxx> +#include <comphelper/servicehelper.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/event.hxx> #include <sfx2/objitem.hxx> @@ -31,6 +32,7 @@ #include <svl/whiter.hxx> #include <svl/stritem.hxx> #include <svl/voiditem.hxx> +#include <sfx2/lokhelper.hxx> #include <sfx2/request.hxx> #include <sfx2/fcontnr.hxx> #include <svl/ctloptions.hxx> @@ -70,6 +72,7 @@ #include <dbconfig.hxx> #include <mmconfigitem.hxx> #include <strings.hrc> +#include <unotxdoc.hxx> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdb/TextConnectionSettings.hpp> @@ -959,7 +962,7 @@ void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } } -void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, ConfigurationHints ) +void SwModule::ConfigurationChanged(utl::ConfigurationBroadcaster* pBrdCst, ConfigurationHints eHints) { if( pBrdCst == m_pUserOptions.get() ) { @@ -968,8 +971,8 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con else if ( pBrdCst == m_pColorConfig.get() ) { //invalidate only the current view in tiled rendering mode, or all views otherwise - bool bOnlyInvalidateCurrentView = comphelper::LibreOfficeKit::isActive(); - SfxViewShell* pViewShell = bOnlyInvalidateCurrentView ? SfxViewShell::Current() : SfxViewShell::GetFirst(); + const bool bKit = comphelper::LibreOfficeKit::isActive(); + SfxViewShell* pViewShell = bKit ? SfxViewShell::Current() : SfxViewShell::GetFirst(); while(pViewShell) { if(pViewShell->GetWindow()) @@ -981,24 +984,35 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con aNewOptions.SetThemeName(svtools::ColorConfig::GetCurrentSchemeName()); SwViewColors aViewColors(*m_pColorConfig); aNewOptions.SetColorConfig(aViewColors); - pSwView->GetWrtShell().ApplyViewOptions(aNewOptions); + const bool bChanged(aNewOptions != *pSwView->GetWrtShell().GetViewOptions()); + if (bChanged) + pSwView->GetWrtShell().ApplyViewOptions(aNewOptions); + else if (bKit) + { + SwXTextDocument* pModel = comphelper::getFromUnoTunnel<SwXTextDocument>(pViewShell->GetCurrentDocument()); + SfxLokHelper::notifyViewRenderState(pViewShell, pModel); + } - if (bOnlyInvalidateCurrentView) + if (bKit) { pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_APPLICATION_BACKGROUND_COLOR, aViewColors.m_aAppBackgroundColor.AsRGBHexString().toUtf8()); pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR, aViewColors.m_aAppBackgroundColor.AsRGBHexString().toUtf8()); } + + // if nothing changed, and the hint was OnlyCurrentDocumentColorScheme we can skip invalidate + const bool bSkipInvalidate = !bChanged && bKit && eHints == ConfigurationHints::OnlyCurrentDocumentColorScheme; + if (!bSkipInvalidate) + pViewShell->GetWindow()->Invalidate(); } - if(pSwView != nullptr || - dynamic_cast< const SwPagePreview *>( pViewShell ) != nullptr || - dynamic_cast< const SwSrcView *>( pViewShell ) != nullptr) + else if (dynamic_cast< const SwPagePreview *>( pViewShell ) != nullptr || + dynamic_cast< const SwSrcView *>( pViewShell ) != nullptr) { pViewShell->GetWindow()->Invalidate(); } } - if (bOnlyInvalidateCurrentView) + if (bKit) break; pViewShell = SfxViewShell::GetNext( *pViewShell ); } |