summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2023-11-27 10:34:56 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-11-28 09:36:08 +0100
commit8c727d1a9a8cfdc309896ed02c546e192e006575 (patch)
tree9fd555e28dd24e25360d14cfb583c9ef017e4622 /svtools
parentcd2ba8cd78c1cd66d5c74e5d35acdcda1bf5abbc (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 'svtools')
-rw-r--r--svtools/source/config/colorcfg.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx
index f2f142071a43..167dfa3337ad 100644
--- a/svtools/source/config/colorcfg.cxx
+++ b/svtools/source/config/colorcfg.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <unotools/configitem.hxx>
#include <unotools/confignode.hxx>
@@ -241,11 +242,28 @@ void ColorConfig_Impl::Load(const OUString& rScheme)
}
}
-void ColorConfig_Impl::Notify( const uno::Sequence<OUString>& )
+void ColorConfig_Impl::Notify(const uno::Sequence<OUString>& rProperties)
{
+ const bool bOnlyChangingCurrentColorScheme = rProperties.getLength() == 1 && rProperties[0] == "CurrentColorScheme";
+ const OUString sOldLoadedScheme = m_sLoadedScheme;
+
//loading via notification always uses the default setting
Load(OUString());
- NotifyListeners(ConfigurationHints::NONE);
+
+ // If the name of the scheme hasn't changed, then there is no change to the
+ // global color scheme name, but Kit deliberately only changed the then
+ // current document when it last changed, so there are typically a mixture
+ // of documents with the original 'light' color scheme and the last changed
+ // color scheme 'dark'. Kit then tries to set the color scheme again to the
+ // last changed color scheme 'dark' to try and update a 'light' document
+ // that had opted out of the last change to 'dark'. So tag such an apparent
+ // null change attempt with 'OnlyCurrentDocumentColorScheme' to allow it to
+ // go through, but identify what that change is for, so the other color
+ // config listeners for whom it doesn't matter, can ignore it as an
+ // optimization.
+ const bool bOnlyCurrentDocumentColorScheme = bOnlyChangingCurrentColorScheme && sOldLoadedScheme == m_sLoadedScheme &&
+ comphelper::LibreOfficeKit::isActive();
+ NotifyListeners(bOnlyCurrentDocumentColorScheme ? ConfigurationHints::OnlyCurrentDocumentColorScheme : ConfigurationHints::NONE);
}
void ColorConfig_Impl::ImplCommit()